How can I copy an image from one document to another?

37 views
Skip to first unread message

Aaron

unread,
Jun 11, 2014, 5:43:01 PM6/11/14
to pdfne...@googlegroups.com
Q:

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.

Exception:
         Message: Objects cannot belong to different documents
         Conditional expression: this_doc == obj->GetDoc()
         Filename   : Dict.cpp
         Function   : trn::SDF::Dict::Put
         Linenumber : 104

A:

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:

http://www.pdftron.com/pdfnet/PDFNetC/d2/d12/classpdftron_1_1_p_d_f_1_1_image.html

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. 


Reply all
Reply to author
Forward
0 new messages