Page 1 of 1

Extract and replace image in existing PDF

Posted: Tue Aug 14, 2012 11:20 am
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.

Re: Extract and replace image in existing PDF

Posted: Tue Aug 14, 2012 2:15 pm
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

Re: Extract and replace image in existing PDF

Posted: Wed Aug 15, 2012 10:53 am
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.

Re: Extract and replace image in existing PDF

Posted: Wed Aug 15, 2012 12:58 pm
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