You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Gregan, Miroslav" <mi...@siemens.com> on 2007/11/14 11:07:57 UTC
Total page numbering example only for FOP 0.20.5
Hi,
I found a document that is not up to date:
http://xmlgraphics.apache.org/fop/fo.html#fo-total-pages
A new example like the following should be added for FOP 0.94 (or
replace the current FOP 0.20.5)
class rendtest {
public static void main(File fo, File pdf) {
OutputStream out = null;
try {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,
out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(fo);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
// Read total page number and set the FO's page-count parameter
transformer.setParameter("page-count",
Integer.toString(fop.getResults().getPageCount()));
transformer.transform(src, res);
}
catch( Exception e) {
e.printStackTrace();
}
finally {
if (out != null) {
out.close();
}
}
}
}
Cheers,
Miro
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Total page numbering example only for FOP 0.20.5
Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Done. Thanks for the hint.
Jeremias Maerki
On 14.11.2007 11:07:57 Gregan, Miroslav wrote:
>
> Hi,
>
> I found a document that is not up to date:
>
> http://xmlgraphics.apache.org/fop/fo.html#fo-total-pages
>
> A new example like the following should be added for FOP 0.94 (or
> replace the current FOP 0.20.5)
>
> class rendtest {
>
> public static void main(File fo, File pdf) {
> OutputStream out = null;
> try {
> FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
> out = new FileOutputStream(pdf);
> out = new BufferedOutputStream(out);
> Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent,
> out);
> TransformerFactory factory = TransformerFactory.newInstance();
> Transformer transformer = factory.newTransformer();
> Source src = new StreamSource(fo);
> Result res = new SAXResult(fop.getDefaultHandler());
> transformer.transform(src, res);
>
> // Read total page number and set the FO's page-count parameter
> transformer.setParameter("page-count",
> Integer.toString(fop.getResults().getPageCount()));
>
> transformer.transform(src, res);
> }
> catch( Exception e) {
> e.printStackTrace();
> }
> finally {
> if (out != null) {
> out.close();
> }
> }
> }
> }
>
> Cheers,
>
> Miro
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org