To remove, or overwrite an object in pdfbox, the solution I found was one
which uses the PDFStreamParser.
Basically, you parse the stream to tokens, update them (you can for instance
remove it, or change something in the token), and then write a new stream
based on the tokens you have, using ContentStreamWriter.
A good example is found on ReplaceStrings.java.



-----Mensagem original-----
De: José Rodolfo Carrijo de Freitas [mailto:[email protected]] 
Enviada em: quinta-feira, 14 de outubro de 2010 10:39
Para: [email protected]
Assunto: RES: Julien Plée solution to overwrite image

Well, that could be a little problem, cause I cannot convert the tiff file,
I need to keep it with minimized size.
And for black and white images, it’s the best format.
I´m trying to use the features of the PDCCitt class, I´ll post here when I
find a solution.

Thanks,
José


-----Mensagem original-----
De: Julien Plée [mailto:[email protected]] 
Enviada em: quinta-feira, 14 de outubro de 2010 10:12
Para: [email protected]
Assunto: Re: Julien Plée solution to overwrite image

Hello José,

I don't know much about image handling in PDF... But it looks like it  
only handles JPEG or PNG.
If you want to embed images from another format, you first have to  
convert it.
Thought I'm not familiar with this task so you'll have to take a look  
on tools capable of this task.

Julien PLÉE
7 Avenue Barthélemy Salettes et Jean-Marie Manset
31320 Castanet-Tolosan
France
+33 6.50.00.60.48

Le 14 oct. 10 à 14:59, José Rodolfo Carrijo de Freitas a écrit :

> On Aug 28, Julien Plée posted a solution to overwrite an image, it  
> seems to
> work perfectly.
>
> But there is a problem with tiff images, maybe because with tiff we  
> should
> use RandomAccessFile.
>
>
>
> Have someone made a hack so that the solution can be extended to tiff
> images?
>
>
>
>
>
> InputStream newStream = new FileInputStream(inFile);
>
>                               OutputStream embeddedStream =
> im.getCOSStream().createFilteredStream();
>
>                               int bSize = 10240;
>
>                               byte[] b = new byte[bSize];
>
>                               int bytesRead = 0;
>
>                               while ((bytesRead = newStream.read(b, 0,
> bSize)) > -1) {
>
>                                                
> embeddedStream.write(b, 0,
> bytesRead);
>
>                               }
>
>                               embeddedStream.close();
>
>
>


Reply via email to