[pdftex] Reference to objects in outlines.

Paul Isambert zappathustra at free.fr
Sun Jan 16 20:32:00 CET 2011


[Sorry Heiko, 6 hours later I realize that I've sent the answer to you 
instead of the list.]

Le 16/01/2011 14:32, Heiko Oberdiek a écrit :

>  On Sun, Jan 16, 2011 at 02:22:02PM +0100, Paul Isambert wrote:
>
>>  When you create a bookmark with a user action instead of a goto,
>>  pdfTeX stores the action in an object and refers to it in the
>>  outline dictionary. For instance
>>
>>  \pdfoutline user {<<   /S/URI /URI (http://www.tug.org)>>}{Go to TUG!}
>>
>>  produces an object with the action dictionary:
>>
>>  1 0 obj
>>  <<   /S/URI /URI (http://www.tug.org)>>
>>  endobj
>>
>>  and in the outline dictionary it refers to it:
>>
>>  ...
>>  /A 1 0 R
>>  ...
>>
>>  This is fine, except when you want to refer to an action dictionary
>>  you have defined yourself. Suppose for instance that object 1 was
>>  created independantly. I can't make \pdfoutline refer to that
>>  action, because it must be fed an action dictionary, not a reference
>>  to such a dictionary.
>  Workarounds:
>
>>  The best I can do is use a unexisting named
>>  action (because PDF allows that) with a /Next field pointing to my
>>  object:
>>
>>  \pdfoutline user {<<   /S/Named /N/NoAction /Next 1 0 R>>}{Go to TUG!}
>>  This works, but I find it terribly unelegant. Is there another way?
>  * Empty JavaScript action, "terribly unelegant" the same way as
>     an unexisting named action.
>
>  * Copy the contents of your action object in the user argument.
>     It might need two passes, if the contents of the action object
>     is not yet known.
>       Then you have at least the object semantics you really want.
>     However, the object representation is not very efficient because
>     of the duplicated object. But these duplicates can be removed
>     by post-processing the PDF file by a stupid optimizer that does
>     not know the semantics of the objects. (In the other cases above
>     the optimizer would need to know that the object is an action
>     and that /NoAction is not a known action and that the action
>     object can therefore be replaced by the reference in /Next.)

That might be the "better" solution, since I've just observed some
viewers (at least Sumatra) don't understand /Next actions.
However, I hate to have to retain the object's contents, use a double
pass and/or post-process.
So I'll be happy with a pdfTeX (or LuaTeX) patch (see below) :)


>>  I.e. (I suppose) can we have chains of references in PDF, so that
>>  the object to which the outline points would be no more than a
>>  reference to another object (the action I have defined)?
>  An indirect object must not be a object reference.
>
>  Possible solutions at pdfTeX level:
>
>  * Syntax extension to pdfTeX:
>     An action can also be an object reference, e.g.:
>     <action spec>   := "user"<user-action spec>
>                    | "goto"<goto-action spec>
>                    | "thread"<thread-action spec>
>                    | "ref"<number>
>     <user-action spec>   :=<general text>
>     ...
>
>  * Alternatively the context of<user-action spec>
>     is interpreted differently if the contents matches the
>     pattern in Perl syntax: /^(\d+) 0 R$/.
>     Then the reference with object number $1 is directly be
>     used to specify the action instead of creating a new
>     action object with the contents of<user-action spec>.

Actually a simple patch would be that pdfTeX doesn't export the action,
i.e. it just produces /A<action>. Then you can use both:

\pdfoutline user {1 0 R}{...}
\pdfoutline user {<<  ...>>}{...}

and the outline's contents would be:

...
/A<reference or dictionary>
...

That would be fully backward compatible. Any idea why pdfTeX does the
indirect reference thing in the first place?

(By the way, the pdfTeX manual should be slightly amended again, just to
mention that<user action>  differ in \pdfstartlink and \pdfoutline; in
the first case you have to add /A, or anything else -- so you can write
/A 1 0 R --, whereas \pdfoutline does it automatically, which makes
sense since an outline has either a /D or /A field.)

Thanks Heiko,
Paul



More information about the pdftex mailing list