We’ve been trying to make a new PDF file, which we planned to have a row of the repeated same images from a different PDF source. 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
Could you tell us how to solve this prblem? (I attached the test image (image1.pdf) in the sample code folder(Test1)
As far as I know, PDFNet SDK cannot copy elements. But, we want to have each element repeatedly printed in a new PDF file after collecting and analysing each element from an original PDF file. Would you let us know how to solve this issue? It seems that the attached sample code doesn’t really help you to understand but I attached it anyway. When I run a sample code afer building it, memory access violation error occurs. And if I try to process everything in one single function in order not to making errors, I’ve got a new blank PDF file.
Each pdftron::PDF::Image object is created within the context of PDFDoc or SDFDoc. Thus you would need to create a new Image within tar_doc, 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.
But, we want to have each element repeatedly
printed in a new PDF file after collecting and
analysing each element from an original PDF file.
As before, possibly the easiest way would be to copy the page over (as shown in http://www.pdftron.com/pdfnet/samplecode.html#PDFPage) and then use ElementEdit (http://www.pdftron.com/pdfnet/samplecode.html#ElementEdit) to edit the content.
You can certainly re-use the same object multiple times in a page — for example, you can show one image multiple times (as shown in http://www.pdftron.com/pdfnet/samplecode.html#ElementBuilder