Hi,
I have to generate a special barcode on every rendered page for a mass
printing facility, essentially so that the printed pages end up in the
correct envelope for postage.
To this end I've written a custom BarcodeObj class (subclass of
org.apache.fop.fo.XMLObj) to represent the barcode in the area trea and a
BarcodeElementMapping to register a new barcode tag, which I can use
within my fo files. A BarcodeXmlHandler class which implements the
org.apache.fop.render.XMLHandler interface is responsible for rendering
the barcode itself.
So far everything works nicely, however I've the problem, that I have to
know at the rendering stage, whether a page is the last within a
PageSequence so that I can render a dedicated "end bit" in the barcode.
How do I know, that a page is the last one within a sequence? I tried the
ref-id approach as described in the doc for my fo file, but how do I read
the value of the ref-id in my XMLHandler class?
The relevant fo part:
...
<fo:instream-foreign-object>
<boewe:barcode fo:ref-id="last-page"/>
</fo:instream-foreign-object>
... (at the end of the flow)
<fo:block id="last-page"/>
The relevant code in BarcodeXmlHandler:
public class BarcodeXMLHandler implements XMLHandler,
RendererContextConstants {
public void handleXML(RendererContext context, Document doc, String ns)
throws Exception {
PageViewport page = (PageViewport) context.getProperty(PAGE_VIEWPORT);
int pageNumber = page.getPageNumber();
/* TODO: How to get total number of pages within the page sequence? */
...
}
}
Thanks for any help,
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]