Bug forwarded from Evince: http://bugzilla.gnome.org/show_bug.cgi?id=552875 "Please describe the problem: Saving a copy of a PDF document works fine. But as soon as you enter something into a form field and then save a copy, only the form fields including their data are saved into the copy. The whole background is omitted however. This might work for printing only the entered data but not for keeping the document including the data. Without the background the document is useless Steps to reproduce: 1. Open a PDF with forms 2. Enter something 3. Save a copy Actual results: Evince only saves form fields and data. Expected results: Evince should also save the background. Does this happen every time? Yes" A test case can be found attached to the original bug report.
The PDF is encrypted ( /Encrypt 954 0 R ) and we don't take that into account it, so that's why the rest of the document "disappears", with iff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 19bb933..6c79fb6 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -836,7 +836,7 @@ void PDFDoc::writeTrailer (Guint uxrefOffset, int uxrefSize, OutStream* outStr, obj1.initString(new GooString((const char*)digest, 16)); //create ID array - Object obj2,obj3,obj4; + Object obj2,obj3,obj4,obj5; obj2.initArray(xref); if (incrUpdate) { @@ -868,6 +868,12 @@ void PDFDoc::writeTrailer (Guint uxrefOffset, int uxrefSize, OutStream* outStr, if (incrUpdate) { obj1.initInt(xref->getLastXRefPos()); trailerDict->set("Prev", &obj1); + + xref->getTrailerDict()->dictLookupNF("Encrypt", &obj5); + if (!obj5.isNull()) + { + trailerDict->set("Encrypt", &obj5); + } } outStr->printf( "trailer\r\n"); writeDictionnary(trailerDict, outStr); the effect is exactly the opposite, the PDF is not destroyed, but our added things don't get rendered because they are not encrypted. We might want to just "return false" if the PDF is encrypted, at least don't destroy the docuemnt, what do you say?
Changing the subject, for now i've disabled saving when the object has an Encrypt, we need to work on writing encrypted data.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/308.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.