Olá pessoal,estou gerando um PDF através de XSL-FO utilizando o apache FOP, e neste arquivo .fo eu tenho umas tags que são para construir uma tabela.
Mas quando o PDF é gerado no browser, a tabela não é exibida.
meu arquivo fo é o seguinte:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:html="http://www.w3.org/1999/xhtml" writing-mode="lr-tb"
hyphenate="false" text-align="start" role="html">
<fo:layout-master-set>
<fo:simple-page-master page-width="auto" page-height="auto" master-name="all-pages">
<fo:region-body column-gap="12pt" column-count="1" margin-left="1in" margin-bottom="1in" margin-right="1in"
margin-top="1in"/>
<fo:region-before display-align="before" extent="1in" region-name="page-header"/>
<fo:region-after display-align="after" extent="1in" region-name="page-footer"/>
<fo:region-start extent="1in"/>
<fo:region-end extent="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="all-pages">
<fo:title>Teste</fo:title>
<fo:static-content flow-name="page-header">
<fo:block font-size="small" text-align="center" space-before="0.5in" space-before.conditionality="retain">
Teste
</fo:block>
</fo:static-content>
<fo:static-content flow-name="page-footer">
<fo:block font-size="small" text-align="center" space-after="0.5in" space-after.conditionality="retain">-
<fo:page-number/>
-
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block role="body">
<fo:table-and-caption>
<fo:table>
<fo:table-column column-width="25mm"/>
<fo:table-column column-width="25mm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block font-weight="bold">Car</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block font-weight="bold">Price</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>Volvo</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>$50000</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>SAAB</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>$48000</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-and-caption>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
meu método que gera o PDF:
public void convertFO2PDF(File fo, HttpServletResponse response) throws IOException, FOPException {
ServletOutputStream outputStream = null;
try {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
outputStream = response.getOutputStream();
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outputStream);
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer
// Setup input stream
Source src = new StreamSource(fo);
// 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(src, res);
response.setHeader( "Content-Type", MimeConstants.MIME_PDF );
response.setHeader( "Content-Disposition", "inline; filename=architect.pdf" );
response.setHeader( "Cache-Control", "no-cache" );
response.setDateHeader( "Expires", 0 );
response.setHeader( "Pragma", "No-cache" );
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace(System.err);
} finally {
outputStream.close();
}
}
Detalhe, o PDF é gerado no browser sem erro algum, o title e o numero da pagina são exibidos corretamente, somente a tabela não é exibida.
Alguém tem alguma sugestão?
Agradeço desde já!