[pdftex] pdfximage minor bug

Ricardo Sanchez Carmenes carmenes at bioinf.medicina.uniovi.es
Thu Nov 15 17:35:41 CET 2001


Hello to all (and hello to Thanh, if you are reading!)

I have found a bug in the current pdftex regarding pdf image inclusion.
If we try to reload the same one-page external pdf file, pdftex crashes.
The bug is present since changes were introduced, around may, in the file
pdftoepdf.cc to reuse imported pdf files, producing smaller pdf outputs.

To reproduce the miss-behaviour, try to compile this short test:

%%%%%%%%%% pdfxbug.tex %%%%%%%%%%%%
\pdfximage width  5cm {fig.pdf}$$\pdfrefximage\pdflastximage$$
\pdfximage width 10cm {fig.pdf}$$\pdfrefximage\pdflastximage$$
\bye
%%%%%%%% end of testfile %%%%%%%%%

Be sure that "fig.pdf" is any one-page pdf figure or document.
The bug will no appear with non-pdf figures, nor with multipage
pdf input files.

The cause of pdftex crash is that, to allow reusing the pdf object,
pdftex needs to preserve the "PdfDocument" allocated data, but this
are destroyed when the pdf file is a one-page document. Of course,
this would never happen with macro packages that take over control
of pdfximage's, such as graphics or context (which explains why the
bug was unoticed till now); nevertheless, it remains as a (minor) bug.

The following patch solves the bug, although I ignore if it may have
any undesirable side-effect:


--- src/texk/web2c/pdftexdir/pdftoepdf.cc	Sun Aug  5 18:03:04 2001
+++ new/texk/web2c/pdftexdir/pdftoepdf.cc	Wed Nov 14 01:46:40 2001
@@ -751,10 +751,15 @@
 // optimization, we do delete it if it's a one-page document.
 void epdf_delete()
 {
+// This optimization is not useful, because we may need to re-import
+// the one-page document with a different scalling, therefore, it is
+// always unsafe to delete the document (RSC 13/11/2001).
+/*
     PdfDocument *pdf_doc = (PdfDocument *) epdf_doc;
     xref = pdf_doc->xref;
     if (pdf_doc->doc->getCatalog()->getNumPages() == 1)
 	delete_document(pdf_doc);
+*/
 }

 // Called when PDF embedding system is finalized.



Regards,
Ricardo.




More information about the pdftex mailing list