Weird problem solved ... actually was not iText the problem. It looked
like but was the way in which I was streaming out the temp file after
creating the PDF - in other words my stupidity :) 

BTW .. any idea if iText will ever support PDF linearization ? That will
be a very useful feature especially for cases like this when you
generate the PDF on the fly from a servlet.

And many thanks to Bruno and all .. This lib rocks. I am generating
monster PDF's with it - over 10K pages - only text but still it works
like a charm ... unless you don't do a beginner mistake as I did today
and not observe the thing :) .. At least I have an excuse .. was Monday
:) 

Calin


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Morar,
Calin (IT)
Sent: Monday, March 20, 2006 4:05 PM
To: [email protected]
Subject: [iText-questions] Incomplete PDF

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
--------------------------------------------------------

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

Reply via email to