home *** CD-ROM | disk | FTP | other *** search
Java Source | 2001-07-04 | 1.1 KB | 54 lines | [TEXT/javc] |
- /* $Id: PDFlibServlet.java,v 1.4 2001/02/28 18:17:30 tm Exp $
- *
- * PDFlib client: hello servlet example in Java
- */
-
- import java.io.*;
- import javax.servlet.*;
-
- import com.pdflib.pdflib;
-
- public class PDFlibServlet extends GenericServlet
- {
- public void service(ServletRequest request, ServletResponse response)
- throws ServletException,
- OutOfMemoryError, IOException, IllegalArgumentException,
- IndexOutOfBoundsException, ClassCastException, ArithmeticException,
- RuntimeException, InternalError, UnknownError
- {
- int font;
- pdflib p;
- byte[] buf;
- ServletOutputStream out;
-
- p = new pdflib();
- p.open_file("");
-
- p.set_info("Creator", "PDFlibServlet.java");
- p.set_info("Author", "Thomas Merz");
- p.set_info("Title", "Hello world (Java servlet)");
-
- p.begin_page(595, 842);
-
- font = p.findfont("Helvetica-Bold", "host", 0);
-
- p.setfont(font, 18);
-
- p.set_text_pos(50, 700);
- p.show("Hello world!");
- p.continue_text("(says Java servlet)");
- p.end_page();
-
- p.close();
-
- buf = p.get_buffer();
-
- response.setContentType("application/pdf");
- response.setContentLength(buf.length);
-
- out = response.getOutputStream();
- out.write(buf);
- out.close();
- }
- }
-