Hello, On Fri, Jul 02, 2004 at 03:56:14PM +0200, Hans Hagen wrote:
this sounds ok to me (an option is: -1 does not exist and -2 invalid)
A pdf file can indeed contain zero pages (for instance a xfdf file, or a file with only templates), so we should stick to <0 values
Variant a) with -1 (not exist) and -2 (invalid)
===============================================
Behaviour of pdfTeX for pdf image inclusion:
NO_PDF_FILE := -1
INVALID_PAGE := -2 // page <= 0
Initialization: \pdflastximagepages := NO_PDF_FILE
Continue := Continue with empty xform object with dimension 1bp x 1bp.
// 1bp because it avoids zero and possible problems and
// the output is small (/BBox [0 0 1 1])
if PDFFileExists
if PageNumber < 1
\pdflastximagepages = INVALID_PAGE
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 = NO_PDF_FILE
Continue
fi
Failure/Success checking:
if \pdflastximagepages = -1
* PDF file does not exist
elsif \pdflastximagepages = -2
* Page number too small
elsif [page] > \pdflastximagepages
* Page number too large
else
* Success
fi
We need the page number for checking, so we can also drop the
second magic number:
Variant b) with -1 (unknown)
============================
Behaviour of pdfTeX for pdf image inclusion:
UNKNOWN := -1
Initialization: \pdflastximagepages := UNKNOWN
Continue := Continue with empty xform object with dimension 1bp x 1bp.
// 1bp because it avoids zero and possible problems and
// the output is small (/BBox [0 0 1 1])
if PDFFileExists
if PageNumber < 1
\pdflastximagepages = UNKNOWN
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 = UNKNOWN
Continue
fi
Failure/Success checking:
if [page] < 1
* Page number too small
elsif \pdflastximagepages = -1
* PDF file does not exist
elsif [page] > \pdflastximagepages
* Page number too large
else
* Success
fi
or with optimization for success:
if [page] < 1
* Page number too small
elsif [page] > \pdflastximagepages
if \pdflastximagepages = -1
* PDF file does not exist
else
* Page number too large
fi
else
* Success
fi
I would prefer variant b) because it reduces the needed magic numbers.
Yours sincerely
Heiko