You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Tony Oslund <To...@prepare-enrich.com> on 2008/01/18 17:54:42 UTC

RE: Using Turbine's tools for assembling PDF output (using FOP): how to?

You might also want to look at a few products, pd4ml, and htmldoc, for
performing html to pdf generation.  Pd4ml is very nice in that it allows
for easy multi-language capabilities (easy font embedding), and it is
entirely written in java.

I noticed that you are already using FO (FOP or something like it).

Personally I have found that my report development cycle is much shorter
using html to pdf rather than xsl/fo.


Anyways, I have been doing the following to send pdf content

byte[] pageContent = null;


... populate pageContent with something


ServletOutputStream outputStream = null;

try {
  HttpServletResponse response = data.getResponse();
  outputStream = response.getOutputStream();
  response.setContentType("application/pdf");
  response.setHeader("Content-disposition","filename=" + pageId +
".pdf");
  response.setIntHeader("Content-length", pageContent.length);
  outputStream.write(pageContent, 0, pageContent.length);
  outputStream.flush();
}
catch (java.io.IOException ex) {}
finally {
  if (outputStream != null) {
    try {
      outputStream.close();
    }
    catch (Exception e) {}
  }
}



-----Original Message-----
From: Alexander Zimmer [mailto:alexander.zimmer@unycom.com] 
Sent: Friday, January 18, 2008 3:44 AM
To: Turbine Users List
Subject: Using Turbine's tools for assembling PDF output (using FOP):
how to?

Hello list,

 

I am trying to extend an existing Turbine application by a "Download"
link which should result in a PDF file being served, containing the same
data as in the screen template counterpart.

 

Take a video database for instance, I can browse through the video
titles and have a look at specific videos by looking at their
"Details.vm" screen template which would output detail information.
Alternatively, I would like to offer a "Download as PDf" link which
should resemble the screen output, but was assembled via FOP, presenting
the video details as a sort of "video data sheet".

 

With regards to the PDF generation, I am presented with the same
problems as in the course of the template screen generation:

-           using the l10n mechanism

-           possibly using other pull tools

 

Therefore it would be very reasonable to use these template services in
a page which does NOT output to the HTTPServlet-request-OutputStream,
but instead is able to 

-           set a MIME-Type

-           gather the output of the template (in which I can use the
beloved set of pull tools, e.g. for internationalization), which
delivers a FO String

-           pipe the generated FO String (or Stream) through a FO->PDF
converter

-           stream the PDF byte stream into the servlet output

 

How can I achieve this in Turbine? The FO->PDF conversion poses no
problem (in fact: is already working), but how can I tell Turbine to use
the template mechanism with all pull tools but capturing the output in
order to send it into the FO->PDF converter and stream it back?

 

I suppose, this has to be a special Page class capable of doing this.
Could you point me in the right direction?

 

TIA,

Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org