I've followed the tutorial instructions and other
instructions elsewhere but I'm always getting a blank
page.... and yes, I am calling the
response.setContentLength()..

Is there anything wrong or missing in my Action
class's execute():

public ActionForward execute(
                ActionMapping mapping,
                ActionForm form,
                HttpServletRequest request,
                HttpServletResponse response)
                throws Exception
    {
        Document myDoc = new
Document(PageSize.LETTER.rotate(), 0, 0, 0, 0);
        ByteArrayOutputStream pdfStream = new
ByteArrayOutputStream();
        PdfWriter writer = null;

        try {


            //writer = PdfWriter.getInstance(myDoc,
new FileOutputStream("MYTEST.pdf"));
            writer = PdfWriter.getInstance(myDoc,
pdfStream);

            myDoc.addTitle("My PDF Test");
            myDoc.addSubject("My PDF Subject");

            myDoc.open();

            Paragraph paragraph = new Paragraph();
           
paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
            for (int i = 0; i < 20; i++) {
                paragraph.add("TESTING PDF FILE BODY
TEXT TESTING PDF FILE BODY TEXT TESTING PDF FILE BODY
TEXT TESTING PDF FILE BODY TEXT");
            }
            myDoc.add(paragraph);

            myDoc.close();

           
response.setContentType("application/pdf");

           
response.setContentLength(pdfStream.size());

            ServletOutputStream sos;

            sos = response.getOutputStream();

            sos.write(pdfStream.toByteArray());
            //pdfStream.writeTo(sos);


            sos.flush();

        } catch (DocumentException de){} 
        catch (IOException io){}

        return null;

    }


Do I need to setup my action entry in
struts-config.xml in any special way?  I mean, the
forward shouldn't matter since I'm not actually
forwarding to any .jsp file.  I'm directly streaming
the dynamically created PDF in memory to the response.

Also, the file IS created when I swap FileOutputStream
for the ByteArrayOutputStream.

Any help is much appreciated, and TIA.




        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to