Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XSL-FO] Re: FOP Servlet

Expand Messages
  • PRAVEEN SAM
    ... ALSO - make sure that the pdf has a .pdf in the url so that the name of the pdf file finds the extension pdf - classic IE issue .. just in case you are
    Message 1 of 6 , Jun 30, 2003
      > you have to map an url ending with .pdf to your
      > FOPServlet
      > (<servlet-mapping> in web.xml) if you are doing it
      > "the classic servlet
      > way", or use a Servlet Filter.


      ALSO - make sure that the pdf has a ".pdf" in the url
      so that the name of the pdf file finds the extension
      "pdf" - classic IE issue .. just in case you are
      missing this ...

      Cheers


      >
      > > -Jim Gannon
      > >
      > > --- In XSL-FO@yahoogroups.com, "Ronald Muller"
      > <rk.muller@1...> wrote:
      > > > The url MUST end with .pdf (IE has the erroneous
      > habit of assuming
      > > MIME
      > > > types based on file extensions), your source
      > looks okay.
      > > >
      > > > Ronald
      > > >
      > > > ----- Original Message -----
      > > > From: "gannonjim" <gannonjim@y...>
      > > > To: <XSL-FO@yahoogroups.com>
      > > > Sent: Monday, June 30, 2003 3:26 PM
      > > > Subject: [XSL-FO] FOP Servlet
      > > >
      > > >
      > > > > Hi,
      > > > >
      > > > > I'm trying to use FOP in a Servlet. When I
      > invoke the servlet,
      > > > > Internet Explorer 6.0 only displays raw PDF
      > characters (that were
      > > > > generated by the servlet) and for some reason
      > the Acrobat Reader
      > > Plug-
      > > > > In is never activated. I'm using FOP 0.20.4
      > distribution with
      > > > > J2SE
      > > > > 1.4.2 SDK and J2EE 1.3.1 SDK to create the
      > servlet. My servlet
      > > class
      > > > > is listed below:
      > > > >
      > > > > // Import libraries
      > > > > import org.apache.fop.apps.Driver;
      > > > > import java.io.*;
      > > > > import org.xml.sax.*;
      > > > > import javax.servlet.*;
      > > > > import javax.servlet.http.*;
      > > > >
      > > > > public class FOPServlet extends HttpServlet {
      > > > > public FOPServlet() {;}
      > > > >
      > > > > public void doGet(HttpServletRequest request,
      > > > > HttpServletResponse response) throws
      > ServletException {
      > > > > try {
      > > > > // Setup FOP
      > > > > Driver driver = new Driver();
      > > > > driver.setRenderer(Driver.RENDER_PDF);
      > > > >
      > > > > // Setup a buffer to obtain the content length
      > > > > ByteArrayOutputStream outStream = new
      > > > > ByteArrayOutputStream();
      > > > > driver.setOutputStream(outStream);
      > > > >
      > > > > // Setup input
      > > > > driver.setInputSource(new InputSource
      > > > > ("C:\\FOP\\TutorialOne\\simple.fo"));
      > > > >
      > > > > // Start the rendering process
      > > > > driver.run();
      > > > >
      > > > > // Prepare response
      > > > > response.setContentType("application/pdf");
      > > > > response.setContentLength(outStream.size());
      > > > >
      > > > > // Send content to Browser
      > > > > response.getOutputStream().write
      > > > > (outStream.toByteArray());
      > > > > response.getOutputStream().flush();
      > > > >
      > > > > } catch (Exception ex) {
      > > > > throw new ServletException(ex);
      > > > > }
      > > > > }
      > > > > }
      > > > >
      > > > > I know the file simple.fo is good since I can
      > create a PDF
      > > document
      > > > > using the standalone FOP application. The
      > format object file,
      > > > > simple.fo is listed below:
      > > > >
      > > > > <?xml version="1.0" encoding="utf-8"?>
      > > > > <fo:root
      > xmlns:fo="http://www.w3.org/1999/XSL/Format">
      > > > > <fo:layout-master-set>
      > > > > <fo:simple-page-master master-name="main"
      > > > > margin-top="25pt" margin-bottom="25pt"
      > > > > page-width="8.5in" page-height="11in"
      > > > > margin-left="75pt" margin-right="75pt">
      > > > > <fo:region-body margin-bottom="50pt"
      > margin-top="50pt"/>
      > > > > </fo:simple-page-master>
      > > > > </fo:layout-master-set>
      > > > > <fo:page-sequence master-reference="main">
      > > > > <fo:flow flow-name="xsl-region-body">
      > > > > <fo:block font-size="24pt"
      > line-height="28pt">
      > > > > A Heading
      > > > > </fo:block>
      > > > > <fo:block font-size="14pt"
      > line-height="17pt">
      > > > > This is a paragraph of text. Notice
      > that as
      > > > > <fo:inline font-style="italic">this
      > meaningless
      > > > > prose</fo:inline> drones on and on,
      > the FOP
      > > > > software automatically calculates line
      > breaks for us.
      > > > > Isn't that fascinating?
      > > > > </fo:block>
      > > > > </fo:flow>
      > > > > </fo:page-sequence>
      > > > > </fo:root>
      > > > >
      > > > > Thanks for your help with my question.
      > > > >
      > > > > -Jim Gannon
      > > > >
      > > > >
      > > > >
      > > > >
      > > > > To unsubscribe from this group, send an email
      > to:
      > > > > XSL-FO-unsubscribe@egroups.com
      > > > >
      > > > >
      > > > >
      > > > > Your use of Yahoo! Groups is subject to
      > > http://docs.yahoo.com/info/terms/
      > > > >
      > > > >
      > >
      > >
      > >
      > > To unsubscribe from this group, send an email to:
      > > XSL-FO-unsubscribe@egroups.com
      > >
      > >
      > >
      > > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      > >
      > >
      >
      >


      =====


      __________________________________
      Do you Yahoo!?
      SBC Yahoo! DSL - Now only $29.95 per month!
      http://sbc.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.