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