You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by CoryO <co...@verizon.net> on 2016/08/28 17:25:45 UTC

How to Use Extensions for Text Output?

I'm having difficulties understanding how to implement Apache FOP extensions.
Right now I'm just trying to get FOP to replace my custom element with the
character "0". All of the samples appear to be for inserting images.

I even tried re-implementing the "fo:page-number" element (below). It seems
to do all of the same validation and runs the various methods, but it does
not cause the page number to output.

Are the custom extensions not meant for text insertion or filtering?

By the way, I'm only looking into this as a possibility to allow me to
format page numbering with and without a leading zero on the same page. The
"format" attribute is only accepted on "fo:page-sequence" and not
"fo:page-number".

public class TestElementMapping extends ElementMapping {
    public static final String URI = "http://www.test.com/fop";
    public static final String STANDARD_PREFIX = "tst";
    public TestElementMapping() {
        namespaceURI = URI;
    }
    @Override
    protected void initialize() {
        if (foObjs == null) {
            foObjs = new HashMap<String, Maker>();
            foObjs.put("page-number", new PageNumberMaker());
        }
    }
    static class PageNumberMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new org.apache.fop.fo.flow.PageNumber(parent) {
                @Override
                public String getNamespaceURI() {
                    return URI;
                }
                @Override
                public String getNormalNamespacePrefix() {
                    return STANDARD_PREFIX;
                }
            };
        }
    }
}



--
View this message in context: http://apache-fop.1065347.n5.nabble.com/How-to-Use-Extensions-for-Text-Output-tp44391.html
Sent from the FOP - Dev mailing list archive at Nabble.com.