A Cheung wrote:
> Hello,
> I have spent quite a while investigating the 
> automated removal/replacement of images in a PDF. (ex: 100 page pdf, 1 
> image per page needs replacing, but each page also has text which I want 
> to keep)
>  
> Strategy 1: 
> Find the XObject, KillIindirect() it, remove it from the XObject Dictionary.

Won't work.

You can't remove an image stream if it's referred to, for instance
from a Resources dictionary of a page.

You can't remove an object /Im0 from the Resources dictionary,
if you don't remove the /Im0 Do from the content stream.

This is way to complicated for what you need.

> Strategy 2: Replace it,
>  
> Similar to http://1t3xt.info/examples/browse/?page=example&id=421 
> <http://1t3xt.info/examples/browse/?page=example&id=421>

This is a better strategy, but the example only works for JPEG images.

> Is there some newer process that makes this easy?  Snippets of existing 
> code?

This is an update of the example you refer to:
http://itextpdf.com/examples/index.php?page=example&id=286

Instead of using the old image to "resize" the image, you need
to create the BufferedImage and use drawString() instead of
drawRenderedImage(). You may also want to create another type
of image, for instance a PNG instead of a JPEG, in which case
you'll need to use a different Filter and stuff.

Retrieving the text from the original image isn't possible.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to