on 02-25-2009 1:42 PM
Hi,
I have an existing Java JSP application.
What are the possibilities of printing a PDF File existing in SAP through Java Application from tomcat server.
Hi Raghu,
In normal Servlet Programming, the following code will create a pdf and send to the browser.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.darwinsys.spdf.PDF;
import com.darwinsys.spdf.Page;
import com.darwinsys.spdf.Text;
import com.darwinsys.spdf.MoveTo;
/** Simple PDF-based Coupon Printer Servlet
@author Lakshmi Prasad.
@version $Id: PDFCouponServlet.java,v 1.2 2000/06/09 02:54:12 ian Exp $
*/
public class PDFCouponServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
response.setContentType("application/pdf");
// Tell browser to try to display inline, but if not,
// to save under the given filename.
response.setHeader("Content-disposition",
"inline; filename=\"MyCoupon.pdf\"");
PDF p = new PDF(out);
Page p1 = new Page(p);
p1.add(new MoveTo(p, 100, 600));
p1.add(new Text(p,
"This coupon good for one free coffee in the student lounge."));
String name = request.getParameter("name");
if (name == null)
name = "unknown user";
p1.add(new Text(p,
"Printed for the exclusive use of " + name));
p1.add(new Text(p,
"by Ian Darwin's PDFCoupon Servlet and DarwinSys SPDF software"));
p1.add(new Text(p, "at " + new Date().toString()));
p.add(p1);
p.setAuthor("Ian F. Darwin");
// Write the PDF file page
p.writePDF();
}
}
I hope this logic will help you........
Regards,
Lakshmi Prasad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.