You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Carmelo Montanez <ca...@nist.gov> on 2001/09/26 17:41:05 UTC

Anything wrong with this code (please look at attachements)

Hello all

Thanks Sempri for all your comments.  For anyone interested, I am attaching a very
slimed down copy of my Servlet.  I am hardwiring the file name (FO file) inside the
servlet (for convenience of running). I am also attaching a "dummy" HTML file
to call the servlet (no parameters are retrieved from the HTML by the servlet).
I am also attaching the FO file

I am running this using Tomcat.   If anyone please try an attempt to run the
servlet.  I am still getting "stuff" (as you will see) on the browser.  Please look
at the "import" statements (most of them are comments) to see
which classes you need, I can can provide them if need be.

I am using FOP's latest version.

Greetings,
Carmelo

Re: Anything wrong with this code (please look at attachements)

Posted by Alex McLintock <al...@yahoo.com>.
 --- Carmelo Montanez <ca...@nist.gov> wrote: > Thanks it worked for me too now both in Netscape
and
> IE.  However what if I wanted to embed to PDF results from
> FOP inside some HTML code for formatting
> purposes?, is that possible at all.  What I mean is
> is possible to send the PDF and the HTML back to
> the client in some fashion?

Forget FOP for a minute and ask yourself whether such a thing is possible at all?

Where have you seen an html document with PDF embedded in it? It *might* be possible
to use the acrobat plugin in this way but try to find an example and I bet you
can't. Whenever I have seen the acrobat plugin it either opens up a new window or
takes over the entire window. 

You can of course send back an html page which *links* to other pdf documents, 
but that is about it. 

Then you might want to look at frames - it might be possible to have html in one
frame and a pdf document in another...

none of this has anything to do with FOP though.

Alex



=====
Alex McLintock        alex@OWAL.co.uk    Open Source Consultancy in London
OpenWeb Analysts Ltd, http://www.OWAL.co.uk/ 
SF and Computing Book News and Reviews: http://news.diversebooks.com/
Get Your XML T-Shirt <t-shirt/> at http://www.inversity.co.uk/

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Anything wrong with this code (please look at attachements)

Posted by Carmelo Montanez <ca...@nist.gov>.
Thanks it worked for me too now both in Netscape and
IE.  However what if I wanted to embed to PDF results from
FOP inside some HTML code for formatting
purposes?, is that possible at all.  What I mean is
is possible to send the PDF and the HTML back to
the client in some fashion?

Greetings,
Carmelo
----- Original Message ----- 
From: "Matt Savino" <ma...@synergizethis.com>
To: <fo...@xml.apache.org>
Sent: Wednesday, September 26, 2001 7:20 PM
Subject: Re: Anything wrong with this code (please look at attachements)


> For one thing it looks like you are mixing PDF and HTML content in your
> response:
> 
>       ServletOutputStream out = response.getOutputStream();
>       try {
>         out.println("<HTML>\n");
>         out.println("<HEAD>\n");
>         out.println("<BODY>\n");
>         out.println("<CENTER><H1>FOP and PDF
> Creation.</H1></CENTER>\n");
>         renderFO(response);
>         out.println("</BODY>\n");
>         out.println("</HTML>\n");
>      }
> and 
>        
>    byte[] content = outPDF.toByteArray();
>           response.setContentLength(content.length);
>           response.getOutputStream().write(content);
>           response.getOutputStream().println("<BR><BR>");
>           response.getOutputStream().println("There should be a PDF
> image above");
>           response.flushBuffer();
>           response.getOutputStream().flush();
> 
> For some reason, Netscape doesn't mind this. But IE seems to create an
> Http error that's related to the discrepancy in the content length of
> the response. (At least with Weblogic). I removed all your 
> out.println("..") calls and the code works.
> 
> Also I have noticed a weird bug where IE sometimes doesn't recognize
> PDF, even though you set the response type to "application/pdf". I was
> using the FopServlet example from .20.1. It worked fine if used
> Netscape. The weird thing is if I clicked back, then forward in IE, it
> recognized the PDF and loaded the plugin. I think I solved the problem
> by mapping the servlet URI to FopServletTest.pdf and sending the FO
> filename as a POST form instead of a GET. 
> 
> Hope this helps,
> Matt
> 
> > Carmelo Montanez wrote:
> > 
> > Hello all
> > 
> > Thanks Sempri for all your comments.  For anyone interested, I am
> > attaching a very
> > slimed down copy of my Servlet.  I am hardwiring the file name (FO
> > file) inside the
> > servlet (for convenience of running). I am also attaching a "dummy"
> > HTML file
> > to call the servlet (no parameters are retrieved from the HTML by the
> > servlet).
> > I am also attaching the FO file
> > 
> > I am running this using Tomcat.   If anyone please try an attempt to
> > run the
> > servlet.  I am still getting "stuff" (as you will see) on
> > the browser.  Please look
> > at the "import" statements (most of them are comments) to see
> > which classes you need, I can can provide them if need be.
> > 
> > I am using FOP's latest version.
> > 
> > Greetings,
> > Carmelo
> > 
> >                    Name: testPDF.java
> >    testPDF.java    Type: unspecified type (application/octet-stream)
> >                Encoding: quoted-printable
> > 
> >                 Name: test.html
> >    test.html    Type: Hypertext Markup Language (text/html)
> >             Encoding: 7bit
> > 
> >                                  Name: cbpbp-background-color4.fo
> >    cbpbp-background-color4.fo    Type: unspecified type
> >                                        (application/octet-stream)
> >                              Encoding: quoted-printable
> > 
> >     ---------------------------------------------------------------
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> > For additional commands, email: fop-dev-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Anything wrong with this code (please look at attachements)

Posted by Matt Savino <ma...@synergizethis.com>.
For one thing it looks like you are mixing PDF and HTML content in your
response:

      ServletOutputStream out = response.getOutputStream();
      try {
        out.println("<HTML>\n");
        out.println("<HEAD>\n");
        out.println("<BODY>\n");
        out.println("<CENTER><H1>FOP and PDF
Creation.</H1></CENTER>\n");
        renderFO(response);
        out.println("</BODY>\n");
        out.println("</HTML>\n");
     }
and 
       
	   byte[] content = outPDF.toByteArray();
          response.setContentLength(content.length);
          response.getOutputStream().write(content);
          response.getOutputStream().println("<BR><BR>");
          response.getOutputStream().println("There should be a PDF
image above");
          response.flushBuffer();
          response.getOutputStream().flush();

For some reason, Netscape doesn't mind this. But IE seems to create an
Http error that's related to the discrepancy in the content length of
the response. (At least with Weblogic). I removed all your 
out.println("..") calls and the code works.

Also I have noticed a weird bug where IE sometimes doesn't recognize
PDF, even though you set the response type to "application/pdf". I was
using the FopServlet example from .20.1. It worked fine if used
Netscape. The weird thing is if I clicked back, then forward in IE, it
recognized the PDF and loaded the plugin. I think I solved the problem
by mapping the servlet URI to FopServletTest.pdf and sending the FO
filename as a POST form instead of a GET. 

Hope this helps,
Matt

> Carmelo Montanez wrote:
> 
> Hello all
> 
> Thanks Sempri for all your comments.  For anyone interested, I am
> attaching a very
> slimed down copy of my Servlet.  I am hardwiring the file name (FO
> file) inside the
> servlet (for convenience of running). I am also attaching a "dummy"
> HTML file
> to call the servlet (no parameters are retrieved from the HTML by the
> servlet).
> I am also attaching the FO file
> 
> I am running this using Tomcat.   If anyone please try an attempt to
> run the
> servlet.  I am still getting "stuff" (as you will see) on
> the browser.  Please look
> at the "import" statements (most of them are comments) to see
> which classes you need, I can can provide them if need be.
> 
> I am using FOP's latest version.
> 
> Greetings,
> Carmelo
> 
>                    Name: testPDF.java
>    testPDF.java    Type: unspecified type (application/octet-stream)
>                Encoding: quoted-printable
> 
>                 Name: test.html
>    test.html    Type: Hypertext Markup Language (text/html)
>             Encoding: 7bit
> 
>                                  Name: cbpbp-background-color4.fo
>    cbpbp-background-color4.fo    Type: unspecified type
>                                        (application/octet-stream)
>                              Encoding: quoted-printable
> 
>     ---------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org