[ https://issues.apache.org/jira/browse/FOP-2444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Toni Ruiz updated FOP-2444: --------------------------- Description: I am using Apache FOP 0.95 to generate a PDF file from a XSL file and when I open the generated PDF on Google Chrome it shows the content properly but when I try to open it with Acrobat Reader X (10.1.1.33) or with IE, I get this message: "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem" If the pdf generated has more than one page, I can see all pages properly except the first page. My code to generate a PDF document: try { StreamSource source = new StreamSource(IOUtils.toInputStream(xmlPortaSignatura, "iso-8859-1")); StreamSource transformSource = new StreamSource(IOUtils.toInputStream(xslfo.toString(), "iso-8859-1")); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Transformer xslfoTransformer; TransformerFactory transfact = TransformerFactory.newInstance(); xslfoTransformer = getTransformer(transformSource); // Construct fop with desired output format Fop fop; try { fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outStream); // Resulting SAX events (the generated FO) // must be piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); // Start XSLT transformation and FOP processing try { xslfoTransformer.transform(source, res); byte[] pdfBytes = outStream.toByteArray(); response.setContentLength(pdfBytes.length); response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment;filename=actaPDF_" +acta.getNumActaExam()+"_" +acta.getNumVersionExam()+".pdf"); response.getOutputStream().write(pdfBytes); response.getOutputStream().flush(); } catch (TransformerException e) { request.setAttribute("errorActa", e.getMessage()); log.error("TransformerException: "+e.getMessage()); throw e; } } catch (FOPException e) { request.setAttribute("errorActa", e.getMessage()); log.error("FOPException: "+e.getMessage()); throw e; } } catch (TransformerConfigurationException e) { request.setAttribute("errorActa", e.getMessage()); log.error("TransformerConfigurationException: "+e.getMessage()); throw e; } catch (TransformerFactoryConfigurationError e) { request.setAttribute("errorActa", e.getMessage()); log.error("TransformerFactoryConfigurationError: "+e.getMessage()); throw e; } was: I am using Apache FOP 0.95 to generate a PDF file from a XSL file and when I open the generated PDF on Google Chrome it shows the content properly but when I try to open it with Acrobat Reader X (10.1.1.33) or with IE, I get this message: "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem" If the pdf generated has more than one page, I can see all pages properly except the first page. I've attached my code to generate a PDF document: > PDF corrupt using Apache FOP > ---------------------------- > > Key: FOP-2444 > URL: https://issues.apache.org/jira/browse/FOP-2444 > Project: Fop > Issue Type: Bug > Reporter: Toni Ruiz > > I am using Apache FOP 0.95 to generate a PDF file from a XSL file and when I > open the generated PDF on Google Chrome it shows the content properly but > when I try to open it with Acrobat Reader X (10.1.1.33) or with IE, I get > this message: > "An error exists on this page. Acrobat may not display the page correctly. > Please contact the person who created the PDF document to correct the problem" > If the pdf generated has more than one page, I can see all pages properly > except the first page. > My code to generate a PDF document: > try > { > StreamSource source = new > StreamSource(IOUtils.toInputStream(xmlPortaSignatura, "iso-8859-1")); > StreamSource transformSource = new > StreamSource(IOUtils.toInputStream(xslfo.toString(), "iso-8859-1")); > FopFactory fopFactory = FopFactory.newInstance(); > FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); > ByteArrayOutputStream outStream = new > ByteArrayOutputStream(); > Transformer xslfoTransformer; > TransformerFactory transfact = > TransformerFactory.newInstance(); > xslfoTransformer = getTransformer(transformSource); > // Construct fop with desired output format > Fop fop; > try > { > fop = fopFactory.newFop(MimeConstants.MIME_PDF, > foUserAgent, outStream); > // Resulting SAX events (the generated FO) > // must be piped through to FOP > Result res = new SAXResult(fop.getDefaultHandler()); > // Start XSLT transformation and FOP processing > try > { > xslfoTransformer.transform(source, res); > byte[] pdfBytes = outStream.toByteArray(); > response.setContentLength(pdfBytes.length); > response.setContentType("application/pdf"); > response.addHeader("Content-Disposition", > "attachment;filename=actaPDF_" > +acta.getNumActaExam()+"_" > +acta.getNumVersionExam()+".pdf"); > response.getOutputStream().write(pdfBytes); > response.getOutputStream().flush(); > } > catch (TransformerException e) { > request.setAttribute("errorActa", e.getMessage()); > log.error("TransformerException: > "+e.getMessage()); > throw e; > } > } > catch (FOPException e) { > request.setAttribute("errorActa", e.getMessage()); > log.error("FOPException: "+e.getMessage()); > throw e; > } > } > catch (TransformerConfigurationException e) > { > request.setAttribute("errorActa", e.getMessage()); > log.error("TransformerConfigurationException: > "+e.getMessage()); > throw e; > } > catch (TransformerFactoryConfigurationError e) > { > request.setAttribute("errorActa", e.getMessage()); > log.error("TransformerFactoryConfigurationError: > "+e.getMessage()); > throw e; > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)