Yes, I am doing a response.setContentType("application/pdf");

Here is the Java Code (I have taken out a lot of document.add's for email size):

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.droplet.DropletException;
import atg.droplet.ErrorMessageForEach;

import atg.servlet.*;

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

public class PANotMarriedStatement extends DynamoServlet {

  public PANotMarriedStatement() {}


  public void service (DynamoHttpServletRequest request,
                       DynamoHttpServletResponse response)
       throws ServletException, IOException
  {

  Font myFont1 = FontFactory.getFont(FontFactory.HELVETICA, 11, Font.NORMAL,new Color(0,0,0));

  String applicant = "John Doe";
  String string1 = ", hereby state that I am not legally married at this time. ";

  Paragraph para1 = new Paragraph("Statement by Applicant Who is Not Married\n",myFont4);
  Paragraph para2 = new Paragraph("",myFont1);
  Paragraph para6 = new Paragraph("Date                                         (Attach Death Certificate)",myFont1);
  Paragraph para7 = new Paragraph("",myFont1);

  para1.setAlignment(1);

        try {
            Document document = new Document();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PdfWriter.getInstance(document, baos);
            document.open();

            document.add(para1);
            document.add(new Paragraph("\n"));


            document.close();
            response.setContentType("application/pdf");
            response.setContentLength(baos.size());
            response.setBufferSize(baos.size());
            ServletOutputStream out = response.getOutputStream();
            baos.writeTo(out);
            out.flush();
        }
        catch(DocumentException de) {
          de.printStackTrace();
          System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
          ioe.printStackTrace();
          System.err.println(ioe.getMessage());
        }

    }
}




Mohammed Ishaq Ali,
----Original Message Follows----
From: "Mihnea Galeteanu" <[EMAIL PROTECTED]>
To: "Ishaq Ali Mohammed" <[EMAIL PROTECTED]>
Subject: RE: [iText-questions] The Servlet is printing garbage on IE - work around is used
Date: Thu, 29 May 2003 16:16:38 -0400
that's the pdf stream
are u setting the content type on the response?
-----Original Message-----
From: Ishaq Ali Mohammed [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 29, 2003 4:02 PM
To: [EMAIL PROTECTED]
Subject: [iText-questions] The Servlet is printing garbage on IE - work around is used
I am trying to generate PDF dynamically and I am using the work around suggested for IE i.e. write everything to ByteArrayOutputStream and set the content length etc. as explained in couple of examples.
When I get to the page where I am supposed to see this PDF I get some garbage something linke this.
======
%PDF-1.4 %� áâã 3 0 obj <> stream xœµVMoã6½ûWÌ¥mp\ɍS=u·-ê›fa{Y ¥‘Í-Eª$e7ýõ’²¾ü¡lê*Ç–Èyóæ½'þ5z»}wóèVé(~¸›Ì¿‡Ûiì¾}ûK ñ¬²QîOoF7ËB•¿1°´ÌbŽÒ¾Y}nîßV;Dn}·ñ


HCL Beanstalk PCs. You could win one Interested? ------------------------------------------------------- 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

Reply via email to