Dear Paulo,
Let me explain the error more in detail. Here is the JSP (test.jsp) code:
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="iso-8859-1" %>
<%@ page import="java.io.*" %>
<%@ page import="com.lowagie.text.*,com.lowagie.text.pdf.*" %>
<html>
<head>
<title>TEST</title>
</head>
<body>
<p>
<FONT SIZE="+2">Ohhh It is a test!</font>
</p>
<%
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("test3.pdf"));
// step 3: we open the document
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
%>
</body>
</html>
The web sever is JRUN4. After I try to open this test.jsp page, JRUN gives this error
message:
Helvetica not found as resource.
Error: Helvetica not found as resource.
And Internet Explorer gives no error. When I try to open the generated test3.pdf with
Acrobat 5.0,unfortunately Acrobat gives the following error message:
There was an error opening this document. This file cannot be opened because
it has no pages
It should be noted that if the sample code is in the form of Java application, it
gives no error, and the generated PDF file can be opened correctly.
Therefore, my question is what happens to JSP?
Regards,
Peter
----- Original Message -----
From: "Paulo Soares" <[EMAIL PROTECTED]>
To: "Peter Zhou" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, August 16, 2002 6:10 PM
Subject: Re: [iText-questions] Open PDF-file error: it has no pages
> Works for me. Are you sure no exception is thrown even in close()?
>
> Best Regards,
> Paulo Soares
>
> ----- Original Message -----
> From: "Peter Zhou" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 16, 2002 7:33
> Subject: [iText-questions] Open PDF-file error: it has no pages
>
>
> > Hi iText developers,
> >
> > I try to open the generated PDF file with Acrobat 5.0, but it fails. The
> > Acrobat 5.0 gives the following error message:
> > there was an error opening this document. This file cannot
> > be opened because it has no pages
> >
> > Here is the code to generate the PDF file:
> >
> > // step 1: creation of a document-object
> > Document document = new Document(PageSize.A4, 50, 50, 50, 50);
> > try {
> > // step 2:
> > // we create a writer that listens to the document
> > PdfWriter writer = PdfWriter.getInstance(document, new
> > FileOutputStream("Chap1110.pdf"));
> > // step 3: we open the document
> > document.open();
> > // step 4:
> > // we add some content
> > for (int k = 1; k <= 10; ++k) {
> > document.add(new Paragraph("This document has the
> > logical page numbers: i,ii,iii,iv,1,2,3,A-8,A-9,A-10\nReal page " + k));
> > document.newPage();
> > }
> > PdfPageLabels pageLabels = new PdfPageLabels();
> > pageLabels.addPageLabel(1,
> > PdfPageLabels.LOWERCASE_ROMAN_NUMERALS);
> > pageLabels.addPageLabel(5,
> > PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
> > pageLabels.addPageLabel(8,
> > PdfPageLabels.DECIMAL_ARABIC_NUMERALS, "A-", 8);
> > writer.setPageLabels(pageLabels);
> > }
> > catch (Exception de) {
> > de.printStackTrace();
> > }
> >
> > // step 5: we close the document
> > document.close();
> >
> >
> >
> > Thanks in advance
> > Peter
> �+,~w�zf��+,��좷�o#�
>���h~�Z�Ʀz�]q�e�'xg�jw����~��DA!��l��0�)醉�q�&�����(��~��{Z�}�{[��t�7�����ب�ɚ�X��X��$��ڮz�b�{%��l���q���z�m��?�X���(��~��zw��X�����b��?�ױ����ب�