Thanks Sean,
I tried modifying the code per the example http://www.pjug.org/PDFServlet.java. Still No Luck.
Here is the code I have right now.
=====
package com.iamnpf.penapp;
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import com.iamnpf.global.*;
import atg.servlet.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
public class PAParticipantStatement extends DynamoServlet {
public PAParticipantStatement() {}
public void service (DynamoHttpServletRequest request,
DynamoHttpServletResponse response)
throws ServletException, IOException
{
final String strFilename = "PAParticipantStatement_" + System.currentTimeMillis() + ".pdf";
String strContentDispValue = "inline; filename=" + strFilename;
DocumentException ex = null;
ByteArrayOutputStream baosPDF = null;
try {
baosPDF = generatePDFDocumentBytes();
response.setHeader("Cache-control", "must-revalidate");
response.setHeader("Content-disposition",strContentDispValue);
response.setContentType("application/pdf");
byte[] yaPDFDocument = baosPDF.toByteArray();
response.setContentLength(yaPDFDocument.length);
ServletOutputStream sos = null;
sos = response.getOutputStream();
sos.write(yaPDFDocument);
sos.flush();
}
catch(DocumentException de) {
de.printStackTrace();
}
catch(IOException ioe) {
ioe.printStackTrace();
}
}
protected ByteArrayOutputStream generatePDFDocumentBytes()
throws DocumentException
{
Font myFont1 = FontFactory.getFont(FontFactory.HELVETICA, 11, Font.NORMAL,new Color(0,0,0));
String string1 = "Participant's Statement";
String string2 = "Please read this statement carefully before signing.";
Chunk chunk1 = new Chunk(string1,myFont1);
Chunk chunk2 = new Chunk(string2,myFont1);
Paragraph para1 = new Paragraph(chunk1);
Paragraph para2 = new Paragraph(chunk2);
para1.setAlignment(1);
Document document = new Document();
ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
PdfWriter docWriter = null;
try
{
docWriter = PdfWriter.getInstance(document, baosPDF);
document.setPageSize(PageSize.A4);
document.open();
document.add(para1);
document.add(new Paragraph("\n"));
document.add(para2);
document.add(new Paragraph("\n"));
document.close();
}
catch (DocumentException dex)
{
baosPDF.reset();
throw dex;
}
finally
{
if (document != null)
{
document.close();
}
if (docWriter != null)
{
docWriter.close();
}
}
if (baosPDF.size() < 1)
{
throw new DocumentException(
"document has "
+ baosPDF.size()
+ " bytes");
}
return baosPDF;
}
}
=====
Regards,
Ishaq.
Attention NRIs! Send money to India. Do it in a jiffy! ------------------------------------------------------- This SF.net email is sponsored by: eBay Get office equipment for less on eBay! http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
