You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by je...@neoris.com on 2001/11/08 19:29:19 UTC

Re: JSP to PDF... it's doable

Alphaworks as the DRE project, that helps you out to create PDF files,
there is a bunch of HTML to PDF out there as well, you could catch the HTML
output of a jsp and put it into a PDF... here is somo html catching code
that generates a html file on disk..

public static void main(java.lang.String[] args) {
     InputStream is = null;
     File f;
     PrintWriter out = null;
     try {
          f = new File("D:\\Temp", "domino.html");
          out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
     } catch (IOException create) {
     }

     URLConnection conn = null;
     try {
          URL url =
               new URL
("http://127.0.0.1/LABS.NSF/a8d73b2120817f1986256aa40079a254/d1f1a1302749375686256aa4007d0deb?OpenDocument");


          conn = url.openConnection();
          is = url.openStream();
          BufferedReader in = new BufferedReader(new
InputStreamReader(is));
          while (!in.ready()) {};  // Not sure if this line is needed
          String line = " ";
          while (line != null) {
               try {
                    line = in.readLine();
                    if (line != null) {
                         System.out.println(line);
                         out.println(line);
                    }
               } catch (IOException ioreading) {
                    break;
               }
          }
          out.flush();
          out.close();
     } catch (MalformedURLException urle) {
     } catch (IOException ioex) {
     }
}

Maybe this is note best way of do it, it's working though...

Another thought, you can control the MIME type of an jsp output, so in
theory you could specify the MIME type for acrobat and output a PDF
directly, just in the same way as you can send an png or a jpeg file to a
browser...

Regards,
Sabo



                                                                                                                   
                    "David Rault"                                                                                  
                    <tomcat.drault       To:     "Tomcat Users List" <to...@jakarta.apache.org>              
                    @free.fr>            cc:                                                                       
                                         Subject:     Re: JSP to PDF                                               
                    11/08/2001                                                                                     
                    12:13 PM                                                                                       
                    Please respond                                                                                 
                    to "Tomcat                                                                                     
                    Users List"                                                                                    
                                                                                                                   
                                                                                                                   




you can't make a pdf output from a jsp
the reason is quite simple

pdf is a binary format and JSPs can only generate text-based output

wanna make pdf, write a servlet
there must be an open source (maybe only LGPL) library to make pdfs
somewhere, the name is lowagie something

hope this helps

David
----- Original Message -----
From: "Huaxin" <hx...@cs.ualberta.ca>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, November 08, 2001 7:02 PM
Subject: JSP to PDF


> I am trying to use Strut, however, I am wondering if there
> is a way to convert the OUTPUT of the JSP page to a
> PDF format, so that the client side sees the PDF instead
> of the translated HTML page?
>
> thanx a lot
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>






____________________________________________________________________________
For your protection, this e-mail message has been scanned for Viruses.
Visit us at http://www.neoris.com/

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: JSP to PDF... it's doable

Posted by Huaxin <hx...@cs.ualberta.ca>.
However, sometimes you can't open a JSP using URL, -- the
sessionId is unknown to u.

Is there a way to record ServletResponse to a log file?

On Thu, 8 Nov 2001 jesus.chavez@neoris.com wrote:

>
> Alphaworks as the DRE project, that helps you out to create PDF files,
> there is a bunch of HTML to PDF out there as well, you could catch the HTML
> output of a jsp and put it into a PDF... here is somo html catching code
> that generates a html file on disk..
>
> public static void main(java.lang.String[] args) {
>      InputStream is = null;
>      File f;
>      PrintWriter out = null;
>      try {
>           f = new File("D:\\Temp", "domino.html");
>           out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
>      } catch (IOException create) {
>      }
>
>      URLConnection conn = null;
>      try {
>           URL url =
>                new URL
> ("http://127.0.0.1/LABS.NSF/a8d73b2120817f1986256aa40079a254/d1f1a1302749375686256aa4007d0deb?OpenDocument");
>
>
>           conn = url.openConnection();
>           is = url.openStream();
>           BufferedReader in = new BufferedReader(new
> InputStreamReader(is));
>           while (!in.ready()) {};  // Not sure if this line is needed
>           String line = " ";
>           while (line != null) {
>                try {
>                     line = in.readLine();
>                     if (line != null) {
>                          System.out.println(line);
>                          out.println(line);
>                     }
>                } catch (IOException ioreading) {
>                     break;
>                }
>           }
>           out.flush();
>           out.close();
>      } catch (MalformedURLException urle) {
>      } catch (IOException ioex) {
>      }
> }
>
> Maybe this is note best way of do it, it's working though...
>
> Another thought, you can control the MIME type of an jsp output, so in
> theory you could specify the MIME type for acrobat and output a PDF
> directly, just in the same way as you can send an png or a jpeg file to a
> browser...
>
> Regards,
> Sabo
>
>
>
>
>                     "David Rault"
>                     <tomcat.drault       To:     "Tomcat Users List" <to...@jakarta.apache.org>
>                     @free.fr>            cc:
>                                          Subject:     Re: JSP to PDF
>                     11/08/2001
>                     12:13 PM
>                     Please respond
>                     to "Tomcat
>                     Users List"
>
>
>
>
>
>
> you can't make a pdf output from a jsp
> the reason is quite simple
>
> pdf is a binary format and JSPs can only generate text-based output
>
> wanna make pdf, write a servlet
> there must be an open source (maybe only LGPL) library to make pdfs
> somewhere, the name is lowagie something
>
> hope this helps
>
> David
> ----- Original Message -----
> From: "Huaxin" <hx...@cs.ualberta.ca>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Thursday, November 08, 2001 7:02 PM
> Subject: JSP to PDF
>
>
> > I am trying to use Strut, however, I am wondering if there
> > is a way to convert the OUTPUT of the JSP page to a
> > PDF format, so that the client side sees the PDF instead
> > of the translated HTML page?
> >
> > thanx a lot
> >
> >
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>
>
>
>
>
> ____________________________________________________________________________
> For your protection, this e-mail message has been scanned for Viruses.
> Visit us at http://www.neoris.com/
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>