[NTG-pdftex] PDF inclusion with annotations

Martin Schroeder ms@artcom-gmbh.de
Thu, 10 Jul 2003 14:01:10 +0200


On 2003-05-23 01:06:17 +0200, Andreas Matthias wrote:
> Last month on pdftex mailing list we had a short discussion, whether
> annotations of external PDFs could be copied when including PDFs.
> I gave it a try and now I have a first partial success. The code
> is far from being complete and there are still a lot of bugs in it.
> Nevertheless I think it is the right time now to show you the code,
> so we can discuss whether this is the right way to go on.
> 
> You can download the patches at:
> 
> http://stud3.tuwien.ac.at/~e9225580/pdftex-1.10b-incl-annot.tar.bz2

Andreas,
thank you very much for your patch (and sorry for the long
silence [and the argument lately]).

> (1)While reading the image (function read_pdf_info), the annotations
> of this image are read, too, and a map with all relevant details
> about the annotations is set up. (2)While writing the reference
> (/Im1 Do) to the content stream (function out_image), a dummy
> annotation node is created to get a correct /Annots array. Those
> dummy annotations nodes are caught during module @<Flush out PDF
> annotations@> and are just delete; no dummy annotation object it
> written out. (3)Eventually in function epdf_write all annotation
> objects of this image are copied are written out.

I must confess I have not cared for annotations yet so I just
hope that this is correct (it certainly sounds so) and leave that
to the experts.

> Another important this which happens within the function out_image,
> is the calculation to the new coordinates of the annotation's /Rect.
> There are no big problems if an images is scaled with the help of
> <rule spec> of \pdfximage. But their are a lot of problems if
> macro packages do something like \pdfliteral{.5 0 0 .5 0 0 cm}
> for scaling and similar things for rotating images. To calculate
> the coordinates of /Rect, pdftex must know exactly which coordinate
> transformations are actually taking place. So I introduced two
> new primitives: \pdfsetctm and \pdfresetctm. 

This I find much more interesting. 

[...]

> Since TeX does not have a function to scan floating-point numbers,
> I used scan_dimen as a work around to scan the arguments of \pdfsetctm.
> That's why you must write
> 
>    \pdfsetctm 0bp 1bp -1bp 0bp 0bp
> 
> so far. It should be no problem to change this in the future.

This could be added.

I'm not going to add the patch to the distribution now but think
it's an improvement we should want; what do the others say?

Best regards
        Martin
-- 
               Martin Schröder, MS@ArtCom-GmbH.DE
     ArtCom GmbH, Lise-Meitner-Str 5, 28359 Bremen, Germany
          Voice +49 421 20419-44 / Fax +49 421 20419-10