[NTG-pdftex] pdfannot in xform

Heiko Oberdiek oberdiek@uni-freiburg.de
Fri, 2 Jul 2004 15:13:37 +0200


Hello Hans,

On Fri, Jul 02, 2004 at 02:08:02PM +0200, Hans Hagen wrote:

> Heiko Oberdiek wrote:
> 
> >On Fri, Jul 02, 2004 at 09:40:57AM +0200, Hans Hagen wrote:
> >
> > 
> >
> >>Currently, when one tries to include page 10 of a 9 page document, pdftex 
> >>quits. 
> >>   
> >>
> >
> >Before trying, the first page can be included in a box, then
> >\pdflastximagespages is available for testing whether the
> >intended inclusion page is valid. (Documents with zero pages
> >cannot handled this way.)
> > 
> >
> testing is an option fo rexisting files, but it's not that user 
> friendly; 

I would not consider the current low level interface of image
inclusion as "user friendly". This should be done at macro level:
  graphicx/pdftex.def for plain/latex and your interface in
  ConTeXt.

> my main point is that pdftex shoul dnot quit on such 
> situations and definietly not end up in some funny mode (as it does now) 
> and produce an invalid file (in batch mode).

I agree.

> indeed the problem is most prominent with non existing files;

This case is handled by LaTeX's graphics.sty, it calls the LaTeX
kernel macro \IfFileExists.

> >>Is it possible to continue and return an empty xform with say 
> >>3.141592pt by 3.141592pt dimensions?
> >
> >Instead of checking two dimensions, it should be easier to check
> >whether the page is not greater than \pdflastximagepages.
> >Then no funny value is needed for the dimensions, 0pt, 1pt, 1bp,
> >1in can be used.
> > 
> >
> i was thinking about one of those; i dislike the 1 inch, zero dimensions 
> are not always accepted by acrobat (one of those persistent bugs); 1pt is 
> ok for me (i liked the pi -)

It costs a lot of time to write pi as decimal number ... ;-)

Perhaps someone will update the documentation of pdfTeX.
1pt is easier to explain as 3.141592pt:
* Why not 3.14159pt:
  \newdimen\foo
  \foo=3.141592pt
  \showthe\foo
  % 3.14159pt
  \newdimen\bar
  \bar=3.14159pt
  \ifdim\foo=\bar
    \message{EQUAL}
  \else
    \message{NOT EQUAL}
  \fi
  % EQUAL
* Testing for such a value implicates that then this value is
  forbidden for pdf page sizes. This complicates the documentation
  and this limitation is not necessary at all (\pdflastximagepages
  is much better here).

Behaviour of pdfTeX for pdf image inclusion:

DEFAULT  := -1 or 0 (see below)
Continue := Continue with empty xform object with dimension 1pt x 1pt.

if PDFFileExists
    if PageNumber < 1
        \pdflastximagepages = DEFAULT
        Warning "Invalid page number"
        Continue
    elsif PageNumber > \pdflastximagepages
        \pdflastximagepages is set
        Warning "Page number to large (out of range)
        Continue
    else
        \pdflastximagepages is set
        image is included
    fi
else
    Warning "PDF file does not exist"
    \pdflastximagepages = DEFAULT
    Continue
fi

Thus \pdflastximagepages = DEFAULT means:
"pdf file is not read" because of:
* No \pdfximage command, program start
* Invalid page number in previous call of \pdfximage
* Call with valid page number, but pdf file does not exist.

The value DEFAULT can be discussed. I have not found in the
pdf specification that pdf files with zero pages are forbidden.
Therefore I would prefer "-1", but the current default at
program start is "0".

Yours sincerely
  Heiko <oberdiek@uni-freiburg.de>