• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

iText problem

exel

n00b
Joined
Jan 21, 2006
Messages
48
Hello,

I am having problems with iText .
iText is a library that allows you to generate PDF files in Java.
I looked through some examples on the site and I am having troubles with this:

Code:
<%@
page import="java.io.*,
			 com.lowagie.text.*,
			 com.lowagie.text.pdf.*"
%><%
//
// Template JSP file for iText
// by Tal Liron
//

response.setContentType( "application/pdf" );

// step 1: creation of a document-object
Document document = new Document();

// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer

ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter.getInstance( document, buffer );

// step 3: we open the document
document.open();

// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));

// step 5: we close the document
document.close();

// step 6: we output the writer as bytes to the response output
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
%>

I have Tomcat 5.5 installed and whenever I run this jsp program,
I am getting a few errors that are saying:

"An error occurred at line: 5 in the jsp file: /helloPDF.jsp
Generated servlet error:
Document cannot be resolved to a type"

I think the errors are generated because it can't find
com.lowagie.text.* and com.lowagie.text.pdf.*

I placed the .jsp file inside C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT folder
but where should I place com.lowagie.text.* and com.lowagie.text.pdf.* ?

Thanks,
 
You should place your libraries in WEB-INF/libs or TOMCAT_HOME/shared/libs

--KK
 
KingKaeru said:
You should place your libraries in WEB-INF/libs or TOMCAT_HOME/shared/libs

--KK

After I place the library in WEB-INF/libs, I get this error:

ExceptionConverter: java.io.IOException: The document has no pages.

JSP is frustrating :(
 
Back
Top