Hi,

I have a situation here.  The pdf document is being created and
displayed through the servlet.   Any contenty added through
pdfContentByte is not shown in the servlet output.  

The code is listed below.  Can someone tell me what I am doing wrong
here?  

Thanks in advance for your help.

regards
Murali Thirumalai



Document doc = new Document(PageSize.LETTER.rotate());
PdfWriter writer = PdfWriter.getInstance(doc, new
FileOutputStream("HTRSCertificates.pdf"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(doc, baos);          
doc.open();
PdfContentByte cb = writer.getDirectContentUnder();
doc.add(Chunk.NEWLINE);
doc.add(new Chunk("Test content"));
helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
// step 4: adding content
for (int i=0; i<list1.size();i++) 
{
    cb.beginText();
    p1 = (Participant) list1.get(i);
    cb.setFontAndSize(helv,24);
    Font font = new Font(helv, 12, Font.ITALIC);
    doc.add(new Chunk(p1.getFirstName()+' ' + p1.getLastName()));
    cb.showTextAlignedElement.ALIGN_CENTER,p1.getFirstName()+' ' +
p1.getLastName(), doc.getPageSize().width() / 2, 350, 0);
cb.showTextAligned(Element.ALIGN_CENTER, clsDt,
doc.getPageSize().width() / 2, 250, 0);
   cb.endText();
   if (i<list1.size()-1) doc.newPage();
      } 
            // step 5: closing the document
doc.close();
PdfWriter.getInstance(doc, baos);
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate, post-check=0,
pre-check=0");
response.setHeader("Pragma", "public");
// setting the content type
response.setContentType("application/pdf");
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();


regards,
Murali Thirumalai
Consulting Engagement Manager-Information Technology
Office of the Attorney General

                
                    CONFIDENTIALITY NOTICE

The information contained in this communication from the
Office of the New Jersey Attorney General is privileged
and confidential and is intended for the sole use of the
persons or entities who are the addressees.  If you are not
an intended recipient of this e-mail, the dissemination, 
distribution, copying or use of the information it contains
is strictly prohibited. If you have received this communication
in error, please immediately contact the Office of the Attorney
General at (609) 292-4925 to arrange for the return of this information.



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to