Comment 1 for bug 299409

Revision history for this message
In , Albert Astals Cid (aacid) wrote :

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?