johnwhitington / cpdf-source

PDF Command Line Tools Source
GNU Affero General Public License v3.0
227 stars 26 forks source link

-rotate-contents problem in awlogo.pdf #12

Open johnwhitington opened 10 years ago

johnwhitington commented 10 years ago
<bug>
      <bug_id>438</bug_id>

      <creation_ts>2013-08-02 12:38</creation_ts>
      <short_desc>-rotate-contents problem in awlogo.pdf</short_desc>
      <delta_ts>2013-08-05 05:17:24</delta_ts>
      <reporter_accessible>1</reporter_accessible>
      <cclist_accessible>1</cclist_accessible>
      <classification_id>1</classification_id>
      <classification>Unclassified</classification>
      <product>cpdf</product>
      <component>cpdf</component>
      <version>unspecified</version>
      <rep_platform>PC</rep_platform>
      <op_sys>Mac OS</op_sys>
      <bug_status>ASSIGNED</bug_status>

      <priority>P5</priority>
      <bug_severity>major</bug_severity>
      <target_milestone>---</target_milestone>

      <everconfirmed>1</everconfirmed>
      <reporter name="John Whitington">john@coherentgraphics.co.uk</reporter>
      <assigned_to name="John Whitington">john@coherentgraphics.co.uk</assigned_to>

      <estimated_time>0.00</estimated_time>
      <remaining_time>0.00</remaining_time>
      <actual_time>0.00</actual_time>

      <long_desc isprivate="0">
        <who name="John Whitington">john@coherentgraphics.co.uk</who>
        <bug_when>2013-08-02 12:38:03</bug_when>
        <thetext>Butterfly looks wrong...</thetext>
      </long_desc>
      <long_desc isprivate="0">
        <who name="John Whitington">john@coherentgraphics.co.uk</who>
        <bug_when>2013-08-02 12:39:42</bug_when>
        <thetext>Pretty sure this used to work -- check with cpdf 1.6!</thetext>
      </long_desc>
      <long_desc isprivate="0">
        <who name="John Whitington">john@coherentgraphics.co.uk</who>
        <bug_when>2013-08-05 05:17:24</bug_when>
        <thetext>Not a regression. Fix for 1.8.</thetext>
      </long_desc>

</bug>
johnwhitington commented 5 years ago

The two files in question here are:

  1. awlogo.pdf. This has been reduced to reduced/awlogo.pdf. It uses a Soft mask of a patterm from the main resource dict. The pattern gets transformed, but it looks like it shouldn't be? Or the soft mask contents stream needs transforming too, to match? Probably that.

  2. shadingfail.pdf. This uses Op_sh which has different rules about transformations than pattern spaces. It looks like it is transformed twice as much as it should be. May need to transform the shadings back? Not yet reduced.

We have fixed up cpdf to deal with patterns in Xobject resources dictionaries at least, so there is some progress on this tedious issue.

johnwhitington commented 5 years ago

Or the soft mask contents stream needs transforming too, to match? Probably that.

No. This moves the rectangle, not the shading. I'm at a loss to see how we are supposed to know not to transform this particular pattern because it's used in a soft mask! Back to the other file for now.

johnwhitington commented 5 years ago

Perhaps email Martin Wüthner about this?

johnwhitington commented 5 years ago

Which other files use patterns in soft masks like the awlogo.pdf file does?

johnwhitington commented 5 years ago

Consider this comment from

https://bugs.ghostscript.com/show_bug.cgi?id=701181

quote:

The problem with Patterns is that they take their CTM from the 'enclosing context', not the 'current' context, that is the CTM at the start of the page/form, not the CTM at the time the pattern is drawn. If we remove the pointless Group from the first form, the problem goes away, because the pdfwrite output no longer needs to emit a Group in its own output (which it does with a Form XObject).

johnwhitington commented 5 years ago

Two classes of problem remain. What, if anything, do we need to do with Op_sh shadings?

What do we do about SMasks? (awlogo.pdf)

Unfortunately, shadingfail.pdf has both smasks and Op_sh, so I think we need smaller example files to get to the bottom of this. It may be that the problems in shadingfail.pdf are all Smask related, just like the ones in awlogo.pdf, and so the Op_Sh shadings don't need to be touched at all? Because they are in the current context, not, as the ghostscript notes above, like patterns -- which are in the 'enclosing context'.

So, fixing reduced/awlogo.pdf should fix shadingfail.pdf too?

johnwhitington commented 5 years ago

Anyway, this is enough for 2.3, absent a customer complaint.

johnwhitington commented 1 year ago

We now have a customer complaint. Looking again for v2.6

johnwhitington commented 1 year ago

Have now fixed up the rest of the inversions for patterns, including in XObjects with Xobjects inside them. The customer's file is fixed. So, the remaining problems are with awlogo.pdf and ShadingFail.pdf, which use shadings not pattern-dictionary patterns.

johnwhitington commented 1 year ago

awlogo.pdf now fixed, by excluding from consideration for transformation patterns which are not used directly in a page or its xobjects. shadingfail.pdf still broken.

johnwhitington commented 1 year ago

Shadingfail.pdf is about soft masks or xobject inheritence - we have removed the shading from the stripped example now...

johnwhitington commented 1 year ago

All known files now work.

There is a probable issue with inheritance amongst xobjects, but we do not have a triggering file yet.

So, parking this issue, but leaving it open until the next time we have a failing file.

johnwhitington commented 1 year ago

Test with -stamp-as-xobject.