How to remove images which are repeatedly used and replace with reusable images

175 views
Skip to first unread message

Raju

unread,
Jun 3, 2010, 3:06:23 PM6/3/10
to PDFTron PDFNet SDK
I have a file which has the same images on alternate pages.

I want to create this image only once and reuse it on the alternate
pages instead of embedding it on every page.

Also how to find out if this image is reused or is embedded for every
page.

A sample code in VB will help greatly

Thanks

Support

unread,
Jun 3, 2010, 8:27:41 PM6/3/10
to PDFTron PDFNet SDK

You would create image only once (using pdftron.PDF.Image.Create()).
You can keep the resulting image as a member variable in your class
and reuse to create any number of image elements on different pages.
All elements will refer to the same embedded image. This is
illustrated at the beginning of ElementBuilder sample project (http://
www.pdftron.com/pdfnet/samplecode.html#ElementBuilder).

You can determine if different image elements point to the same
embedded image by comparing they object numbers (e.g. image_element.
GetXObject().GetObjNum()). You can also find which images are used on
a given page by enumerating images stored in page resource dictionary
(page.GetResourceDict().Get("XObject").Value()).

Jagan

unread,
Jun 4, 2010, 10:22:23 AM6/4/10
to pdfne...@googlegroups.com
Hi
Thank you you somuch for the response.
I am now able to get the object number but got stuck on replacing the content. also how do i delete the objects which are no more in used in the document
Thanks

--
You received this message because you are subscribed to the "PDFTron PDFNet SDK" group. To post to this group, send email to sup...@pdftron.com
To unsubscribe from this group, send email to pdfnet-sdk-...@googlegroups.com. For more information, please visit us at http://www.pdftron.com

Support

unread,
Jun 4, 2010, 12:54:58 PM6/4/10
to PDFTron PDFNet SDK

You can replce an old image with a new one using sdfdoc.Swap(). For
example:

pdfdoc.GetSDFDoc().Swap(image1.GetSDFObj().GetObjNum(),
image2.GetSDFObj().GetObjNum());

For more examples you can search for swap or "Image Replace" in this
forum.

Object that are no longer in use are utomatically deleted if you are
saving the file using linearization or unused object remove mode
(these are flags you can pass in doc.Save() method).
> > SDK" group. To post to this group, send email to supp...@pdftron.com
> > To unsubscribe from this group, send email to
> > pdfnet-sdk-...@googlegroups.com. For more information, please
> > visit us athttp://www.pdftron.com- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages