xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Soika <ralph.so...@imixs.com>
Subject PDF File content ist not visible
Date Thu, 14 Apr 2011 18:33:42 GMT
Hi,
I have a strange problem with FOP PDF creation.
In general everything looks fine. But I try to provide REST Service to 
create pdf files.
The result seems to work but the File which is provided by my 
ResponseBuild consits only of blank pages?
Also when I try to write the result into a file the file seems to have 
the right size and is regogniced as a pdf file but the pages are blank.
Has anybody a idea what I did wrong?

My JAX-RS Code looks like this..
....
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
             try {

                     ReportService.fopTranformation(sXML, sXSL,
                 outputStream.flush();
                 Response.ResponseBuilder builder = 
Response.ok(outputStream.toString(encoding),
                         sContentType);

                 } finally {
                 outputStream.close();

                 return builder.build();
             ......
......


     public static void fopTranformation(String xmlSource, String 
xslSource,
             String aEncoding, ByteArrayOutputStream output) throws 
Exception {
         // configure fopFactory as desired
         FopFactory fopFactory = FopFactory.newInstance();

         FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
         // configure foUserAgent as desired

         try {
             // Construct fop with desired output format

             Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, 
foUserAgent,
                     output);

             // Setup XSLT
             TransformerFactory factory = TransformerFactory.newInstance();
             ByteArrayInputStream baisXSL = new ByteArrayInputStream(
                     xslSource.getBytes());
             InputStreamReader isreaderXSL = new InputStreamReader(baisXSL,
                     aEncoding);
             Source xslSrc = new StreamSource(isreaderXSL);

             Transformer transformer = factory.newTransformer(xslSrc);

             // Setup input for XSLT transformation
             ByteArrayInputStream baisXML = new ByteArrayInputStream(
                     xmlSource.getBytes());
             InputStreamReader isreaderXML;

             isreaderXML = new InputStreamReader(baisXML, aEncoding);

             Source xmlSrc = new StreamSource(isreaderXML);

             // Resulting SAX events (the generated FO) must be piped 
through to
             // FOP
             Result res = new SAXResult(fop.getDefaultHandler());

             // Start XSLT transformation and FOP processing
             transformer.transform(xmlSrc, res);
         } finally {
             output.flush();
             output.close();
         }
     }
-- 


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message