fop - http://xml.apache.org/fop/index.html

In my opinion better than iText - gives a bit more control.  I had problems
with layout in iText - it adds funny paragraph spacing (especially with big
fonts).  For fop - generate an XML file with data, write some XSL to
translate data into fop xml, and then process. Can create one xml file, one
xsl file, and translate it to what ever you want!

Says it doesnt support rtf yet... "This is currently not integrated with FOP
but it will soon."  Might be worth trying their mailing lists to see what's
happening with it.

With iText, you generate the whole thing programatically.

With iText or fop it's easy to do from an action:


    public ActionForward execute(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
        throws IOException {


        ByteArrayOutputStream outPDF = null;

        try {
            //... generate data here
            outPDF = ...

            // set response headers
            response.setHeader("Cache-Control", "max-age=60");
            response.setContentType("application/pdf");


            StringBuffer cd = new StringBuffer();
            cd.append("inline");
            cd.append("; filename=");
            cd.append("whatever");
            cd.append(".pdf");
            response.setHeader("Content-disposition", cd.toString());
            response.setContentLength(outPDF.size());

            // send pdf data
            ServletOutputStream sos;
            sos = response.getOutputStream();
            outPDF.writeTo(sos);
            sos.flush();

        // return null so it just outputs data (no forward)
        return null;
    }


Hope that helps,

Daniel.


> -----Original Message-----
> From: Barnett, Brian W. [mailto:[EMAIL PROTECTED]
> Sent: 19 July 2004 23:22
> To: '[EMAIL PROTECTED]'
> Subject: [OT] RTF & PDF export options
>
>
> Any suggestions for converting html to RTF and PDF inside an action class
> and then sending the RTF or PDF back to the client?
>
>
>
> Open source tools, code snippets, tips & tricks, etc. ??
>
>
>
> Thanks a bunch.
>
>
>
> Brian Barnett
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to