Showing results for 
Search instead for 
Did you mean: 

Print PDF in SAP from Java Servlet

Former Member
0 Kudos


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.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Raghu,

In normal Servlet Programming, the following code will create a pdf and send to the browser.


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:,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();


// Tell browser to try to display inline, but if not,

// to save under the given filename.


"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.setAuthor("Ian F. Darwin");

// Write the PDF file page




I hope this logic will help you........


Lakshmi Prasad.

Former Member
0 Kudos

Preferably API from SUN ,like Java Print Service API to be used.I may not be allowed to use any third party jars.