You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by José Rodolfo Carrijo de Freitas <jo...@softplan.com.br> on 2010/07/21 16:22:10 UTC

New image on the same place of a old one.

Hello,

 

I’ve been trying to make some changes on the size of pdfs.

My first step on my strategy was to extract all images from the pdf and
compact them.

I made it successfully.

Now, What I need to do is to replace the image ‘I’ with the compressedImage
‘CI’ using the same graphicstate, so visually the pdf would be the same(or
almost), the difference: with lower quality images.

 

I tried to createOutputStream on the image and read the stream of the
compacted one.

 

I tried to drawImage with the contentStream, but it seemed that it printed
both images. And besides, I didn’t manage a way to get the graphicstate of
the “old” image.

 

I tried to set a new Image, which obviously would not work, but I had to
try, just in case.

 

Now What I’m trying to do:

 

Pass the dictionary tree for a new PDDocument and replace the image
resources with the compacted files, and save this new document.

However I don’t know how I can get this tree.

 

So I was wondering if you guys can give me some light.

 

Thank you.