We’ve been trying to make a new PDF file, copying an image from one document to another. We wrote a sample code to test on copying images. But the code kept giving us exception and didn’t work what we planned it to work. This is what was shown on the screen.
Message: Objects cannot belong to different documents
Conditional expression: this_doc == obj->GetDoc()
Filename : Dict.cpp
Function : trn::SDF::Dict::Put
Linenumber : 104
Each pdftron::PDF::Image object is created within the context of PDFDoc or SDFDoc. Thus you would need to create a new Image within the target document, using Image::Create:
Alternately, you could copy the entire page over to the new document (as shown in http://www.pdftron.com/pdfnet/samplecode.html#PDFPage), then copy the Image between pages.