Including PDF images with page /Metadata streams
Hi, (corresponding bug report for LaTeX: https://tex.stackexchange.com/questions/585289/corrupt-pdf-with-includegraph... ) when LuaTeX includes a PDF file in which a Page object contains a Metadata stream, then the output is a invalid PDF file since LuaTeX adds the stream inline into the directory instead of adding a reference. plain LuaTeX example: Download page.pdf from https://bitbucket.org/longwayahead/latex-problem/src/master/ and then compile with plain LuaTeX: \saveimageresource{./page.pdf} \useimageresource\lastsavedimageresourceindex \bye The issue can be fixed by removing a single character: In pdftoepdf.c, line 875 a comment correctly mentions that indirection has to be preserved, but for this to work the previous ppdict_rget_obj has to be replaced with ppdict_get_obj to ensure that indirections are not already resolved. Best regards, Marcel diff --git a/source/texk/web2c/luatexdir/image/pdftoepdf.c b/source/texk/web2c/luatexdir/image/pdftoepdf.c index 78dab3a37..ca68ba8dc 100644 --- a/source/texk/web2c/luatexdir/image/pdftoepdf.c +++ b/source/texk/web2c/luatexdir/image/pdftoepdf.c @@ -864,15 +864,15 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info) if (obj != NULL && obj->type != PPREF) { formatted_warning("pdf inclusion","/Metadata must be indirect object"); } /* copy selected items in Page dictionary */ for (i = 0; pagedictkeys[i] != NULL; i++) { - obj = ppdict_rget_obj(pageDict, pagedictkeys[i]); + obj = ppdict_get_obj(pageDict, pagedictkeys[i]); if (obj != NULL) { pdf_add_name(pdf, pagedictkeys[i]); /* preserves indirection */ copyObject(pdf, pdf_doc, obj); }
On Sun, Feb 28, 2021 at 5:01 PM Marcel Fabian Krüger
Hi,
(corresponding bug report for LaTeX: https://tex.stackexchange.com/questions/585289/corrupt-pdf-with-includegraph... )
when LuaTeX includes a PDF file in which a Page object contains a Metadata stream, then the output is a invalid PDF file since LuaTeX adds the stream inline into the directory instead of adding a reference.
plain LuaTeX example: Download page.pdf from https://bitbucket.org/longwayahead/latex-problem/src/master/ and then compile with plain LuaTeX:
\saveimageresource{./page.pdf} \useimageresource\lastsavedimageresourceindex \bye
The issue can be fixed by removing a single character: In pdftoepdf.c, line 875 a comment correctly mentions that indirection has to be preserved, but for this to work the previous ppdict_rget_obj has to be replaced with ppdict_get_obj to ensure that indirections are not already resolved.
Best regards, Marcel
diff --git a/source/texk/web2c/luatexdir/image/pdftoepdf.c b/source/texk/web2c/luatexdir/image/pdftoepdf.c index 78dab3a37..ca68ba8dc 100644 --- a/source/texk/web2c/luatexdir/image/pdftoepdf.c +++ b/source/texk/web2c/luatexdir/image/pdftoepdf.c @@ -864,15 +864,15 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info) if (obj != NULL && obj->type != PPREF) { formatted_warning("pdf inclusion","/Metadata must be indirect object"); } /* copy selected items in Page dictionary */ for (i = 0; pagedictkeys[i] != NULL; i++) { - obj = ppdict_rget_obj(pageDict, pagedictkeys[i]); + obj = ppdict_get_obj(pageDict, pagedictkeys[i]); if (obj != NULL) { pdf_add_name(pdf, pagedictkeys[i]); /* preserves indirection */ copyObject(pdf, pdf_doc, obj); }
_______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-luatex
confirmed. -- luigi
participants (2)
-
luigi scarso
-
Marcel Fabian Krüger