The resulting PDF has the content that was added just to page 0 on pages 1 and 2 as well.
I understand that this might be intended behavior for some (to have multiple pages in a PDF reference the same backing data), however I want to import this page multiple times and then have each of these pages be individual pages with separate content after they've been imported.
One option is to add a boolean flag to ImportPage() where you can specify if you want the page to be duplicated or not (e.g. ImportPage( ImportContext ctx, int srcno, int dstno, boolean duplicate )).
Actually I have tried that, but I ran into a different issue:
The resulting PDF (newPdf) becomes very large. It seems to be that the "context" of the original PDF is added to newPdf multiple times (each time ImportStart() is called). I'm guessing this includes things like embedded fonts, but I'm not sure what else.
Can the behavior of ImportStart() be fixed so that it can detect if the resources for the imported page have already been added to the PDF that's being imported into, and not add them? Or in some way not duplicate the resources?
Or even if you added a boolean parameter to ImportStart() or ImportPage() (I'm not sure which one would be the most appropriate) that specifies whether or not the resources should be included, then the caller can just keep track if the note has already been imported from. For example:
ImportPage( ImportContext ctx, int srcno, int dstno, boolean importResources )
If true is passed in, the behavior would be the same as the current behavior. If false is passed in, then the resources would not be copied to the destination PDF. Ideally, it could just be detected if the resources already have been imported/copied and the boolean parameter would not be needed.
Alternatively, ImportPage() could take a boolean parameter to specify if the page should be referenced or copied. For example:
ImportPage( ImportContext ctx, int srcno, int dstno, boolean copyPage )
If false is passed in, the behavior would be the same as the current behavior. If true is passed in, then in the event that the page has already been imported into the destination PDF, a copy of the imported page would be made in the destination PDF rather than only a reference to the same page.