diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 3b3752f..3a62e5a 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -641,6 +641,8 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) Ref *refPage = getCatalog()->getPageRef(pageNo); Object page; getXRef()->fetch(refPage->num, refPage->gen, &page); + oldRefNum = refPage->num; + newRefNum = rootNum + 2; if (!(f = fopen(name->getCString(), "wb"))) { error(errIO, -1, "Couldn't open file '{0:t}'", name); @@ -1430,7 +1432,17 @@ void PDFDoc::markDictionnary (Dict* dict, XRef * xRef, XRef *countRef, Guint num { Object obj1; for (int i=0; igetLength(); i++) { - markObject(dict->getValNF(i, &obj1), xRef, countRef, numOffset); + const char *key = dict->getKey(i); + if (strcmp(key, "Annots") != 0) { + markObject(dict->getValNF(i, &obj1), xRef, countRef, numOffset); + } else { + Object annotsObj; + dict->getValNF(i, &annotsObj); + if (!annotsObj.isNull()) { + markAnnotations(&annotsObj, xRef, countRef, 0, oldRefNum, newRefNum); + annotsObj.free(); + } + } obj1.free(); } } diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index fdb7f3b..69e889d 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -338,6 +338,9 @@ private: #if MULTITHREADED GooMutex mutex; #endif +public: + int oldRefNum; + int newRefNum; }; #endif diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index b53e497..c953336 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -129,6 +129,8 @@ int main (int argc, char *argv[]) } pages.push_back(page); offsets.push_back(numOffset); + docs[i]->oldRefNum = refPage->num; + docs[i]->newRefNum = refPage->num; docs[i]->markPageObjects(pageDict, yRef, countRef, numOffset); Object annotsObj; pageDict->lookupNF("Annots", &annotsObj);