aboutsummaryrefslogtreecommitdiffstats
path: root/src/documentation
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2007-11-18 10:48:53 +0000
committerJeremias Maerki <jeremias@apache.org>2007-11-18 10:48:53 +0000
commit42efdd9b247d07833edbbd4796178677762d8910 (patch)
tree1acd4dcf52165ae0596214f615dbd7f882052a9d /src/documentation
parent4dc0814427637af59dc68ba887cfea40f0e8450d (diff)
downloadxmlgraphics-fop-42efdd9b247d07833edbbd4796178677762d8910.tar.gz
xmlgraphics-fop-42efdd9b247d07833edbbd4796178677762d8910.zip
ApacheCon US is over.
OSSSummit was cancelled/postponed. Added example for total page count using XSL 1.1 Adjusted total page count example to new FOP API. (Thanks to Miroslav Gregan for the hint) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@596072 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/documentation')
-rw-r--r--src/documentation/content/xdocs/fo.xml72
-rw-r--r--src/documentation/skinconf.xml14
2 files changed, 51 insertions, 35 deletions
diff --git a/src/documentation/content/xdocs/fo.xml b/src/documentation/content/xdocs/fo.xml
index 5ab95fe8d..dc7d45ab0 100644
--- a/src/documentation/content/xdocs/fo.xml
+++ b/src/documentation/content/xdocs/fo.xml
@@ -362,9 +362,14 @@ Omit your normal headers and footers, and use (for example) an extended header t
<section id="fo-total-pages">
<title>Total Document Pages</title>
<p>
- It is frequently desirable to know the total number of pages in a document and to use that number within the document.
-For example, you might wish to show the page number on the first page as being "page 1 of 12".
-To accomplish this, place an empty block with an id at the end of the flow:
+ It is frequently desirable to know the total number of pages in a
+ document and to use that number within the document. For example, you
+ might wish to show the page number on the first page as being
+ "page 1 of 12".
+ </p>
+ <p>
+ To accomplish this in <strong>XSL 1.0</strong>, place an empty block
+ with an id at the end of the flow:
</p>
<source><![CDATA[<fo:flow ...>
...
@@ -373,10 +378,20 @@ To accomplish this, place an empty block with an id at the end of the flow:
<p>
Get the number of the last page as follows:
</p>
- <source><![CDATA[ <fo:page-number-citation ref-id="last-page"/>]]></source>
+ <source><![CDATA[<fo:page-number-citation ref-id="last-page"/>]]></source>
<p>
This does not work in certain situations: multiple page sequences, an initial page number other than 1, or forcing a certain page count, thereby producing blank pages at the end.
</p>
+ <p>
+ In <strong>XSL 1.1</strong>, you get another option to do this: make
+ sure an "id" is set on the page-sequence and reference it using
+ fo:page-number-citation-last. First, the page-sequence:
+ </p>
+ <source><![CDATA[<fo:page-sequence id="seq1" ...]]></source>
+ <p>
+ After that, reference the last page the page-sequence generates:
+ </p>
+ <source><![CDATA[<fo:page-number-citation-last ref-id="seq1"/>]]></source>
<warning>
There is no reliable way to get the real total page count with FO mechanisms. You can only get <em>page numbers</em>.
</warning>
@@ -394,27 +409,42 @@ import javax.xml.transform.stream.*;
class rendtest {
+ private static FopFactory fopFactory = FopFactory.newInstance();
+ private static TransformerFactory tFactory = TransformerFactory.newInstance();
+
public static void main(String args[]) {
+ OutputStream out;
try {
- Driver driver=new Driver();
- driver.setOutputStream(new FileOutputStream(args[2]));
- driver.setRenderer(Driver.RENDER_PDF);
- Transformer transformer=TransformerFactory.newInstance()
- .newTransformer(new StreamSource(new File(args[1])));
- transformer.setParameter("page-count","#");
+ //Load the stylesheet
+ Templates templates = tFactory.newTemplates(
+ new StreamSource(new File(args[1])));
+
+ //First run (to /dev/null)
+ out = new org.apache.commons.io.output.NullOutputStream();
+ FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
+ Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
+ Transformer transformer = templates.newTransformer();
+ transformer.setParameter("page-count", "#");
transformer.transform(new StreamSource(new File(args[0])),
- new SAXResult(driver.getContentHandler()));
- String pageCount=Integer.toString(driver.getResults().getPageCount());
- driver=new Driver();
- driver.setOutputStream(new FileOutputStream(args[2]));
- driver.setRenderer(Driver.RENDER_PDF);
- transformer=TransformerFactory.newInstance()
- .newTransformer(new StreamSource(new File(args[1])));
- transformer.setParameter("page-count",pageCount);
+ new SAXResult(fop.getDefaultHandler()));
+
+ //Get total page count
+ String pageCount = Integer.toString(driver.getResults().getPageCount());
+
+ //Second run (the real thing)
+ out = new java.io.FileOutputStream(args[2]);
+ out = new java.io.BufferedOutputStream(out);
+ try {
+ foUserAgent = fopFactory.newFOUserAgent();
+ fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
+ transformer = templates.newTransformer();
+ transformer.setParameter("page-count", pageCount);
transformer.transform(new StreamSource(new File(args[0])),
- new SAXResult(driver.getContentHandler()));
- }
- catch( Exception e) {
+ new SAXResult(fop.getDefaultHandler()));
+ } finally {
+ out.close();
+ }
+ } catch( Exception e) {
e.printStackTrace();
}
}
diff --git a/src/documentation/skinconf.xml b/src/documentation/skinconf.xml
index 1211d4de6..65a271a64 100644
--- a/src/documentation/skinconf.xml
+++ b/src/documentation/skinconf.xml
@@ -369,20 +369,6 @@ which will be used to configure the chosen Forrest skin.
<height>31</height>
</credit>
<credit box-location="alt2">
- <name>ApacheCon US 2007 (Atlanta)</name>
- <url>http://apachecon.com/2007/US/</url>
- <image>http://www.apache.org/ads/ApacheCon/2007-usa-125x125.png</image>
- <width>125</width>
- <height>125</height>
- </credit>
- <credit box-location="alt2">
- <name>OS Summit Asia 2007</name>
- <url>http://www.ossummit.com/</url>
- <image>http://www.ossummit.com/ads/ossummit_button_3.jpg</image>
- <width>125</width>
- <height>125</height>
- </credit>
- <credit box-location="alt2">
<name>ApacheCon Europe 2008</name>
<url>http://eu.apachecon.com/</url>
<image>http://apache.org/ads/ApacheCon/2008-europe-125x125.png</image>