Hello all,
I am experiencing a very weird behavior when I am creating a PDF
document using iText 1.4 (latest release). I use the API in a servlet to
generate PDF on the fly with very good results but now I've hit a
problem which is driving me nuts - I write the PDF directly in the
servlet output stream the PDF is created OK with no problems (all
content is present) if I write the same PDF (using the same exact code)
but in a FileOutputStream the last pages of the PDF get created with
size 0x0 points ( I mean a very tiny page) and no content while the
beginning of the PDF is OK up to a certain page. Even more odd I have
this showing up in PDF's that are generating 60+ pages while some PDF's
with over 1K pages are OK.
I posted bellow the code in both cases:
1) Using the servlet output stream
Document doc = new Document(PageSize.LETTER, ...margins ...);
PDFWriter writer = PDFWriter.getInstance(doc,
response.getOutputStream());
doc.open()
.. add PDF content here ...
doc.close();
writer.flush()
writer.close()
2) Using file output stream
Document doc = new Document(PageSize.LETTER, ...margins ...);
FileOutputStream fos = new FileOutputStream("/file/name/file.pdf")
PDFWriter writer = PDFWriter.getInstance(doc, fos);
doc.open()
.. add PDF content here ...
doc.close();
writer.flush()
writer.close()
Like I said version 2) seems to not write the last pages in the file.
>From whet I've seen in the code and in docs the Document.close() method
forces writing/flushing of the PDF content in the output stream. I tried
all kind of things even delays (Thread.sleep() :) ) before
Flush and close. No matter what I do the last pages are all created but
they have 0x0 points and no content, and I am sure 100% the
pages/content are being added because it works when I user the servlet
output stream and I have tons of logging to catch where the problem
appears.
Any ideas are welcome.
Thanks
Calin
--------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does
not waive confidentiality or privilege, and use is prohibited.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions