diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index b35090c..33e2efe 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -109,10 +109,12 @@ int main (int argc, char *argv[]) yRef->add(0, 65535, 0, gFalse); PDFDoc::writeHeader(outStr, majorVersion, minorVersion); - // handle OutputIntents, AcroForm & OCProperties + // handle OutputIntents, AcroForm, OCProperties, Outlines & Names Object intents; Object afObj; Object ocObj; + Object outlines; + Object names; if (docs.size() >= 1) { Object catObj; docs[0]->getXRef()->getCatalog(&catObj); @@ -127,6 +129,14 @@ int main (int argc, char *argv[]) if (!ocObj.isNull() && ocObj.isDict()) { docs[0]->markPageObjects(ocObj.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } + catDict->lookup("Outlines", &outlines); + if (!outlines.isNull() && outlines.isDict()) { + docs[0]->markPageObjects(outlines.getDict(), yRef, countRef, 0, refPage->num, refPage->num); + } + catDict->lookup("Names", &names); + if (!names.isNull() && names.isDict()) { + docs[0]->markPageObjects(names.getDict(), yRef, countRef, 0, refPage->num, refPage->num); + } if (intents.isArray() && intents.arrayGetLength() > 0) { for (i = 1; i < (int) docs.size(); i++) { Object pagecatObj, pageintents; @@ -261,6 +271,18 @@ int main (int argc, char *argv[]) PDFDoc::writeObject(&ocObj, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); ocObj.free(); } + // insert Outlines + if (!outlines.isNull() && outlines.isDict()) { + outStr->printf(" /Outlines "); + PDFDoc::writeObject(&outlines, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + outlines.free(); + } + // insert Names + if (!names.isNull() && names.isDict()) { + outStr->printf(" /Names "); + PDFDoc::writeObject(&names, outStr, yRef, 0, NULL, cryptRC4, 0, 0, 0); + names.free(); + } outStr->printf(">>\nendobj\n"); objectsCount++;