stamp.getWriter().setCloseStream(false);

Paulo

----- Original Message ----- 
From: "Patrick Herber" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, August 27, 2006 1:41 PM
Subject: [iText-questions] PdfStamper.close() and ZipOutputStream


> Hello!
>
> I'm using iText to put a watermark on existings PDF files.
>
> Here this function, which add the watermark on each page
> (I've used the example from the online tutorial):
>
> protected void writePdfWithWatermark(InputStream is,
> OutputStream os) throws Exception {
> PdfReader reader = new PdfReader(is);
> PdfStamper stamp = new PdfStamper(reader, os);
> // for each page add a watermark [...]
> stamp.close();
> }
>
> My application has also a function that allow the users to ZIP more files.
> For this function I use the class java.util.zip.ZipOutputStream.
> Here an extract of it:
>
> ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
> zos.setMethod(ZipOutputStream.DEFLATED);
> zos.setLevel(9);
> for (int i = 0; i < files.length; i++) {
> // skipped [...]
> addZipEntry(path, name, time, zos);
> // CALL THE WATERMARK FUNCTION
> writePdfWithWatermark(fis, zos);
> zos.closeEntry();
> }
>
> Now the problem I'm experiencing is that the method stamp.close() (last 
> line
> of the writePdfWithWatermark method) seems also to close the underlying
> OutputStream (in this case the ZipOutputStream), which here should not
> happen (since other files could also be added to the ZIP archive).
> If I leave this line than I get a ZIP file containing also the first PDF
> file.
> If I comment the stamp.close() line, than the ZIP file is complete but the
> generated PDF file is not "valid".
>
> Is there a way to close the document without closing the outputstream?
>
> Thanks a lot for any suggestion.
> Regards,
> Patrick
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job 
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to