Leonard Rosenthol wrote:
> On Nov 22, 2007, at 3:48 AM, Craig Ringer wrote:
>> I'm having a bit of trouble with some PDF code, and was hoping for a
>> helping hand. The following code is the the end of the content stream
>> for PDF Reference 1.5 (v5) page 89:
>>
>> q
>> 232.5 281.5 147.5 245.975 re
>> W n
>> 0.5 w
>> 232.75 527.225 147 -245.475 re
>> S
>> EMC
>> Q
>>
>> ... and as far as I can tell it's not valid, since the EMC operator for
>> closing a BMC/BDC/EMC scope appears inside a q/Q scope.
> 
>     Technically, it's valid - but it is definitely problematic!   I
> would consider it a bug in the program that produced the PDF.
> 
>     Might be worth trying to do a "look ahead" on the content stream
> when 'out of sync' operators appear like this and fixing it...

For a relatively simple case like this, yes, it's easy enough to look
ahead for more closing context operators and reorder them - because
there are no other operators in between. It gets harder when there are
other operators between the mis-nested pair, because it's not clear what
the intent is - and I'm seeing a bit of that, too.

For example, in code like:

q
% blah
BT
% blah
Q
% If there are operators here, what context applies?
ET

Did they mean:

q
% blah
BT
% blah
ET
Q
BT
% problem operators
ET

?

It's certainly not safe to just assume they did. Also, what if it's not
BT/ET that's misnested, but some context where the opening operator
takes arguments? Can we just clone the arguments?       

>> I'm also seeing lots of issues in other files where PdfContentsTokenizer
>> claims that there are indirect references in the content stream.
> 
>     Can you provide an example?

It turns out to be a PdfContentsTokenizer bug. The following stream, for
example, will fail at 'RG'.

q 0.1 0 0 0.1 0 0 cm
/R7 gs
0.118389 w
1 i
1 1 1 RG

... because the sequence `1 1 R' is parsed as a reference.

I'd say PdfTokenizer needs to make sure there's no more to the token
before assuming it's a reference.  I've committed a change (r756) that
should take care of it.

--
Craig Ringer

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to