A Quick way to copy Page Labels from one PDF document to another.

Q: I've been doing some testing with the copying of PDF files. Is there
any
way of preserving the PDF's label information when performing a copy of
pages? I'm currently using an iterative approach to manually reset the
labels after copying and importing the pages I want to the new PDFDoc
object, but I thought I would check to see if there is a simpler way.
---

A: you can copy the entire PageLabel structure from one document to
another as follows:

Obj* l1 = doc1.GetRoot().FindObj("PageLabels");
If (l1 == null) return; // no labels in the input doc

// Copy the page labels structure to another document
Obj* doc2root = doc2.GetRoot();
Obj* l2 = doc2.GetSDFDoc().ImportObj(l1, true);
doc2root.Put("PageLabels", l2);

Of course, if the 'logical' sequence of pages is different in the
destination document this may not be very useful and in this case you
would be better off creating each label from scratch.