----Original Message Follows----
From: Nick Neuberger <[EMAIL PROTECTED]>
To: 'Ishaq Ali Mohammed' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject: RE: [iText-questions] The Servlet Code Problem -- Please Help
Date: Mon, 21 Jul 2003 09:08:54 -0500
Here are a couple of thoughts!
1) You might want to try and set the response.setContentType("") to "PDF" or
something like "application/pdf". I'm guess that there is a method like
this to tell the browser what type of content it is. It's been a while
since I've directly set content types like that. Another option is the
following:2) You can generate the file and place it behind a webserver. Then "forward" the response to the url to that new file that was generated. Plus, this allows you to permanently store the PDF on the server for later retrieval.
Just a Thought! Hope it Helps.
Nick
-----Original Message----- From: Ishaq Ali Mohammed [mailto:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 5:18 PM To: [EMAIL PROTECTED] Subject: [iText-questions] The Servlet Code Problem -- Please Help
Hi,
I am trying to generate pdf using servlet.
I am getting junk in the browser: "%PDF-1.4 %���� 2 0 obj <> stream [EMAIL PROTECTED])�� <mailto:[EMAIL PROTECTED])��> ... "
When I write the output to a file by using the same code, It is working.
Here is the code servlet version code: Can you please help me with this code.
package com.iamnpf.penapp;
import java.awt.Color; import java.io.IOException; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream;
import javax.servlet.*; import javax.servlet.http.*;
import com.lowagie.text.*; import com.lowagie.text.pdf.PdfWriter;
public class PANotMarriedStatement extends HttpServlet {
public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String applicant = "John Doe";
String string1 = ", text here text here text here.";Paragraph para1 = new Paragraph("Statement by Applicant Who is Not
Married\n");
Paragraph para6 = new Paragraph("Date (Attach Death Certificate)");
Paragraph para7 = new Paragraph("");
Paragraph para9 = new Paragraph("text.");
Paragraph para10 = new Paragraph("Applicant's signature_");
Paragraph para11 = new Paragraph("Notary's Certification");
Paragraph para12 = new Paragraph("State of");
Paragraph para13 = new Paragraph("I certify that");
Chunk chunk8 = new Chunk(string1);
para7.add(chunk8);
para1.setAlignment(1);
para6.setIndentationLeft(200);
para7.setIndentationLeft(50);para6.setLeading(10);
try {
Document document = new Document();
response.setContentType("application/pdf");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
response.setHeader("Pragma", "public"); ByteArrayOutputStream baos = new ByteArrayOutputStream();
//PdfWriter.getInstance(document, new
FileOutputStream("c:\\temp\\PANotMarriedStatement.pdf"));
document.open(); document.add(para1);
document.add(new Paragraph("\n"));
document.add(para6);
document.add(new Paragraph("\n"));
document.add(para7);
document.add(new Paragraph("\n"));
document.add(para9);
document.add(new Paragraph("\n"));
document.add(para10);
document.add(new Paragraph("\n"));
document.add(para11);
document.add(new Paragraph("\n"));
document.add(para12);
document.add(new Paragraph("\n"));
document.add(para13); document.close();
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());
}} }
_____
It's new, it's here! It's full of fun! MSN Messenger V6.0 <http://g.msn.com/8HMUENIN/2731??PS=> ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
- - - - - - This e-mail message is intended only for the use of the individual or entity identified in the alias address of this message and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of this e-mail message is strictly prohibited. If you have received this e-mail message in error, please notify the sender immediately by reply e-mail and delete this message from your system. Thank you.
Mohammed Ishaq Ali,
_________________________________________________________________
It's all happening @ F1. Feel the thrill! http://server1.msn.co.in/sp03/formula2003/index.asp Race along right here!
------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
