Extract and replace image in existing PDF

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
marcovdlinden
User
Posts: 45
Joined: Thu May 06, 2010 7:40 am

Extract and replace image in existing PDF

Post by marcovdlinden »

We would like to extract, modify (color corrections), and replace one or more images in an existing PDF.

We're having some difficulty figuring out which set of functions can do all 3.
With 3 being:
1. Extract image and image data (location on page, etc)
2. Delete old image
3. Insert new (modified) image
or step 2 and 3 together in a 'replace' call?

Any suggestions would be appreciated.

Edit:
Related question, off coarse we found some functions but one of the problems we are having is that they do not return background/watermark image that appear on a specific page in the PDF.
Marco
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Extract and replace image in existing PDF

Post by Tracker Supp-Stefan »

Hello Marco,

You can use our PDF Tools SDK's XCPRO40 LIB Functions high level methods to extract image content from a given PDF file and page, but you will then need to recreate that page using the PXCLIB40 LIB Functions - save the newly generated page, and then replace the old one in your document using the XCPRO40 LIB methods again.

The background/watermark might not be an image object but rather a vector one - and that's why you are not getting the desired result.

Best,
Stefan
marcovdlinden
User
Posts: 45
Joined: Thu May 06, 2010 7:40 am

Re: Extract and replace image in existing PDF

Post by marcovdlinden »

Hi Stefan,

So if I understand correctly the only way is to recreate the PDF page object for object.
And when we are recreating image objects apply our image modifications before adding them to the new page.
And then replace the old page with the new page.

This sounds like a lot of work prone to mistakes/omissions, is there an easy way to re-create the page and intercept the Image creations?
Or do you have examples that create a copy of a page in this way?

note: after further investigation the images that were giving problems appeared to be vector based images, as you said.
Marco
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Extract and replace image in existing PDF

Post by Tracker Supp-Stefan »

Hi Marco,

I just discussed that with one of our devs and here is his reply:
The only correct way is to use the low-level API to replace image object content, all other ways may produce incorrect result.
For example we might have image covering the whole page, but it is clipped, so cover only small part of it. It is no problem to extract it, but there are no Hi-Level API functions to replace the image. Placing it in same position will not always produce acceptable result because content drawing order will be changed.


Best,
Stefan
Post Reply