Try it with the code I proposed, don't complicate. Also make sure that you 
add something to the page like a doc.add(new Paragraph("hello")) after open.

Paulo

----- Original Message ----- 
From: "Feld, David E" <[EMAIL PROTECTED]>
To: "Post all your questions about iText here" 
<[email protected]>
Sent: Thursday, May 03, 2007 6:18 PM
Subject: Re: 
[iText-questions]ExceptionConverter:java.io.IOException:Thedocument has no 
pages.


>
> This is what I have:
>
> try {
> ...
> Log..."Start Open"
> try
> {
>     doc.open();
> }
>  catch (Exception e)
>            {
>     Log..."Printing Stack Trace for doc.open"
>                e.printStackTrace();
>            }
> Log..."End Open"
> ...
> }
> catch (Exception e)
> {
>      Log..."Printing Stack Trace for overall method"
>      e.printStackTrace();
> }
> finally {
> Log..."Start Close"
> try
> {
>     doc.close();
> }
>  catch (Exception e)
>            {
>     Log..."Printing Stack Trace for doc.close"
>                e.printStackTrace();
>     Log..."Printing exception info: "+e.toString()
>            }
>         }
>
> The output is the following:
> -----------------------
> Start Open
> Start Close
> Printing Stack Trace for doc.close
> Printing exception info: EXCEPTION INFO: ExceptionConverter:
> java.io.IOException: The document has no pages.
> -----------------------
>
> I don't understand why the open does not produce any info in this
> particular layout? What would be the difference if I do move the close()
> to be right below  it?
>
> Thanks,
>
> Dave
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Paulo Soares
> Sent: Wednesday, May 02, 2007 7:02 PM
> To: Post all your questions about iText here
> Subject: Re:
> [iText-questions]ExceptionConverter:java.io.IOException:Thedocument has
> no pages.
>
> You have something like this:
>
> try {
> ...
> doc.open();
> ...
> }
> finally {
> doc.close();
> }
>
> You should have:
>
> try {
> ...
> doc.open();
> ...
> doc.close();
> }
> catch (Exception e){
> e.printStackTrace();
> }
>
> Paulo
>
> ----- Original Message ----- 
> From: "Feld, David E" <[EMAIL PROTECTED]>
> To: "Post all your questions about iText here"
> <[email protected]>
> Sent: Thursday, May 03, 2007 12:43 AM
> Subject: Re:
> [iText-questions]ExceptionConverter:java.io.IOException:Thedocument has
> no
> pages.
>
>
>> > You are seeing the exception thrown by close but there was an
>> exception
>>> before that that caused the finally block. That's where the real
> error
>> is.
>> That is correct.  The original exception came from doc.open() which is
>> what I stated earlier.
>>
>>> No. Unless you catch the original exception it will remain a mistery.
>> I am catching the original exception.  The exception text is
>> "ExceptionConverter:java.io.IOException:Thedocument has no pages" and
> it
>> has no stack trace associated with this exception.
>>
>>
>> Thanks,
>>
>> Dave
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of
>> Paulo Soares
>> Sent: Wednesday, May 02, 2007 6:02 PM
>> To: Post all your questions about iText here
>> Subject: Re:
>> [iText-questions]ExceptionConverter:java.io.IOException:Thedocument
> has
>> no pages.
>>
>>
>> ----- Original Message ----- 
>> From: "Feld, David E" <[EMAIL PROTECTED]>
>> To: "Post all your questions about iText here"
>> <[email protected]>
>> Sent: Wednesday, May 02, 2007 11:15 PM
>> Subject: Re: [iText-questions]
>> ExceptionConverter:java.io.IOException:Thedocument has no pages.
>>
>>
>>>I have  a debug statement after every line of code and the last debug
>>> statement that gets printed out is the one right before doc.open()
> and
>>> the one right after it does not get printed.  Part of our execption
>>> handling is that we do close it in the finally block.  So, the
> close()
>>> would get called but the exception still occurs at this line
>> initially.
>>>
>>
>> You are seeing the exception thrown by close but there was an
> exception
>> before that that caused the finally block. That's where the real error
>> is.
>>
>>> Do you know the root cause of this exception? Is there an issue with
>> the
>>
>> No. Unless you catch the original exception it will remain a mistery.
>>
>>> itext jar?
>>
>> iText 1.2 is more than two years old. There were 23 releases since
> that.
>> If
>> there was an issue, nobody will remember.
>>
>> Paulo
>>
>>>
>>> Thanks,
>>>
>>> Dave
>>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED] On Behalf Of
>>> Paulo Soares
>>> Sent: Wednesday, May 02, 2007 4:52 PM
>>> To: Post all your questions about iText here
>>> Subject: Re: [iText-questions] ExceptionConverter:
>>> java.io.IOException:Thedocument has no pages.
>>>
>>> That error can only occur at doc.close(). Check that you are not
>>> ignoring
>>> exceptions.
>>>
>>> Paulo
>>>
>>> ----- Original Message ----- 
>>> From: "Feld, David E" <[EMAIL PROTECTED]>
>>> To: <[email protected]>
>>> Sent: Wednesday, May 02, 2007 9:31 PM
>>> Subject: [iText-questions] ExceptionConverter: java.io.IOException:
>>> Thedocument has no pages.
>>>
>>>
>>>
>>> Hi,
>>>
>>> I am receiving the following error:
>>>
>>> ExceptionConverter: java.io.IOException: The document has no pages.
>>>
>>> When attempting to call the following code:
>>>
>>> ByteArrayOutputStream ba = new
>>> ByteArrayOutputStream();
>>> Document doc = new Document();
>>> PdfWriter docWriter=PdfWriter.getInstance(doc,
>>> ba);
>>> PdfDocEvents events = new PdfDocEvents();
>>> docWriter.setPageEvent(events);
>>> doc.setPageSize(PageSize.LETTER);
>>> doc.setMargins(36, 36, 48, 36);
>>> String imageFolder =
>>> configuration.getEnvironmentProperty(FwConstants.IMAGE_FOLDER);
>>> Image checkMark = Image.getInstance(imageFolder
>>> + AppConstants.ICON_CHECK_PDF_IMG);
>>> Image logo = Image.getInstance(imageFolder +
>>> AppConstants.ACCESS_LOGO_IMG);
>>> logo.setAlignment(Image.LEFT);
>>> logo.scaleAbsoluteHeight(50);
>>> logo.scalePercent(50);
>>> SimpleDateFormat formatter = new
>>> SimpleDateFormat("MM/dd/yyyy hh:mm a");
>>> Date toDay = new Date();
>>> Chunk chunk = new Chunk(logo,0,-45);
>>> HeaderFooter header = new HeaderFooter(new
>>> Phrase(chunk),false);
>>> header.setAlignment(Element.ALIGN_LEFT);
>>> header.setBorder(Rectangle.NO_BORDER);
>>> doc.setHeader(header);
>>> doc.open();
>>>
>>> The error occurs when doc.open() is called.  This is running in a
>>> clustered environment on WAS 6.0.  The itext jar is itext-1.2.jar and
>> it
>>> was placed in a shared library on the WAS server.  We have no idea
> why
>>> this is happening.  Please, let me know what I can look at or what I
>> am
>>> doing wrong?
>>>
>>> This is not occuring on the local environment, it is only occuring on
>>> this deployed environment.
>>>
>>> Thanks,
>>> David Feld


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to