On Nov 8, 2007, at 11:08 AM, Craig Ringer wrote:
> "PDF has no concept of an operand stack as PostScript has. In PDF, all
> of the operands needed by an operator must immediately precede that
> operator. Operators do not return results, and operands cannot be left
> over when an operator finishes execution."
>
> I realised before that that was how it commonly worked out, but I
> didn't
> realise it was a hard rule; I'd always assumed there was a stack.
>
That's a slightly misleading statement.
There is a stack that is used FOR EACH OPERATOR. But while
Postscript maintains the stack between operators, PDF processing
clears that stack after each operator.
> That means that a tree representation of a content stream would be
> very
> boring and simple - just:
>
Tree representation is of the operators in relation to the grouping
conditions...
q
m
l
l
f
BMC
BT
Tf
TJ
ET
EMC
Q
> ... which might be just as well represented by something like a
> list/vector of pairs, where each pair describes an operator and an
> array
> of zero or more PdfVariant arguments.
>
Each operator would indeed have an array of operands (as PdfVariant
arguments).
HOWEVER, by the time you get things into the DL - you need to have
moved from the "raw PDF coding" to internal state, with higher level
constructs including current & stored graphic states, etc.
> Stream operations would seem to be equally simple - accumulate
> variants
> until you hit a keyword, then return the keyword and an array of
> arguments to it.
>
Yup!
> I've put together a quick reader based on Dom's code that can be
> used to
> read a content stream an operator at a time, returning a pair
> containing
> the string representation of the operator and a vector of PdfVariant
> operands. There's also a simple function to accumulate the lot of them
> if you want to read a whole stream at once.
>
Perfect.
Leonard
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users