[pdftex] pdf objects with references to each other?

Hans Hagen pragma at wxs.nl
Sat Mar 30 13:23:40 CET 2002


At 09:11 PM 3/30/2002 +1100, Robert Howlett wrote:

> > You can use a pdf object without referencing:
> >
> > \setbox0=\hbox{Click}
> > \edef\APNrule{width\the\wd0 height\the\ht0 depth\the\dp0}
> > \immediate\pdfxform0
> > \edef\APNobj{\the\pdflastxform}
> >
> > \pdfobj{}%
> > \pdfannot ... {%
> >   /Subtype/Popup%
> >   /Parent \the\numexpr\pdflastobj+2\relax\space 0 R%
> >   /Open false%
> >   /C[0 1 1]%
> > }%
> > \pdfannot\APNrule{%
> >   /Subtype/Text%
> >   /Popup \the\pdflastannot\space 0 R%
> >   /C[0 1 1]%
> >   /T(...)%
> >   /Contents(...)%
> >   /AP<</N \APNobj\space 0 R>>%
> > }
> >
> > Without e-TeX: \pdflastobj has to be stored in a counter
> > register after \pdfobj{} and the register is then
> > incremented by 2 and is used in the next \pdfannot command
> > instead of \numexpr.
> >
> > Yours sincerely
> >   Heiko <oberdiek at uni-freiburg.de>
> >
>
>Many thanks.
>I had wondered if something like this might work, but I
>was worried that something like \pdflastobj+2 could
>hit upon a number that had already been used somehow,
>if pdftex's method for choosing object numbers was
>a bit complicated.

(1) it's best to treat object numbers kind of neutral, i.e. when you store 
them in a counter, it does not matter how pdftex increments them

(2) making macros depend on such things as inc(2) is definitely a bad idea, 
since this magic 2 is not documented and cannot be considered a fixed feature

(3) it happens that object refs are numbers, but in a more advanced sheme 
they could as well be token lists representing the object number and 
revision number i.e. \the\pdflastobj expanding to something "0 10" or "2 40"

(4) also, if for some reason (say a user error) a page break occurs between 
two pdfobj/anots, or some kind of other resource is inserted (one never 
knows), this method can lead to interesting effects

(5) so, carying over in a macro is a bit better than incrementing

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma at wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                                   fall-back web server: 
www.pragma-ade.nl
-------------------------------------------------------------------------




More information about the pdftex mailing list