[opencms-dev] JSP for dynamic PDF generation - export problem

Riss, Stefan Stefan.Riss at t-systems.com
Mon Aug 9 12:56:01 CEST 2004


Hi 

I am using the prototype-JSP below to check the possibilities for dynamic PDF generation. 

When I call the JSP directly from within opencms (by clicking on its filename) everything works fine and the PDF opens up in the browser window. 

When I do a static export of the same resource a file with the correct name is generated. But the PDF is broken. Comparing both files (the complete and incomplete version) shows that the incomplete file stops at the first occurence of a "0" byte. 

So why does the file get truncated when doing the static export? Any ideas? 

BTW: Im using the production release 5.01. 

Cheers, 
Stefan Riss 

Code:
<%@ page session="false" import="org.xml.sax.InputSource,org.apache.fop.apps.Driver,java.io.*" %> 
<% 
/* 
import javax.servlet.*; 
import javax.servlet.http.*; 

import org.xml.sax.InputSource; 

import org.apache.fop.apps.Driver; 
*/ 
try { 

        ByteArrayOutputStream bOut = new ByteArrayOutputStream(); 
        response.setContentType("application/pdf"); 
        Driver driver = new Driver(new InputSource("C:/fonts.fo"),bOut); 
        driver.setRenderer(Driver.RENDER_PDF); 
        driver.run(); 

            byte[] content = bOut.toByteArray(); 
            response.setContentLength(content.length); 
            response.getOutputStream().write(content); 
            response.getOutputStream().flush(); 

    } catch (Exception ex) { 
        throw new ServletException(ex); 
    } 

%>

______________________________________________________________
Stefan Riß
Hansastr. 24
80686 München

Mail : stefan.riss at telekom.de
Phone: +49 89 54754469 

"This is why you want to get out of IT and get a nice job, say, as a crash-test dummy"



More information about the opencms-dev mailing list