reena wadhwa wrote:
> Hi all,
>
> I am using iText.jar to generate PDFs and facing a strnge issue. If the
> data has two or more than two riws then PDF gets generated correctly
> ,but if it has single row then it gives error saying "File does not
> start with '%PDF-' ".
The "cause" you mention (having less than two rows) is not directly
responsible for the consequence (the file doesn't start with %PDF).
People have been generating PDFs with tables that have only one row
without any problem.
What probably happens is: an error is thrown and you "eat" the error,
causing a file with size 0 to be created, or a 404 web page (HTML
instead of PDF), or even something else.
I am 99.99% sure that this is not an iText problem, but for instance:
> *if* (!_caption.equals(LHConstants.EMPTY_STRING)) {
This could cause a NullPointerException if _caption == null.
It would be better to use
LHConstants.EMPTY_STRING.equals(_caption)
because EMPTY_STRING is probably a public static final that is different
from null. In this better version, it doesn't matter if _caption is null.
> Can anyone help me here.
This is impossible. We don't have access to your system, nor to your
complete code. You need to debug your code yourself.
Start by looking at the file that is generated. If you open it in a text
editor, does it start with '%PDF-'? Probably not. What does it start
with? Maybe it starts with <html> or maybe there aren't any bytes in the
file. Or maybe it's something else. YOU are the only one who can check
this. We can't do this for you.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/