docs/examples/fo/pdfoutline.fo for an example. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194025 13f79535-47bb-0310-9956-ffa450edef68tags/fop-0_17_0
<property name="src.properties.xsl" value="${src.codegen}/properties.xsl"/> | <property name="src.properties.xsl" value="${src.codegen}/properties.xsl"/> | ||||
<property name="foproperties.xml" value="${build.codegen}/foproperties.xml"/> | <property name="foproperties.xml" value="${build.codegen}/foproperties.xml"/> | ||||
<property name="svgproperties.xml" value="${build.codegen}/svgproperties.xml"/> | <property name="svgproperties.xml" value="${build.codegen}/svgproperties.xml"/> | ||||
<property name="extproperties.xml" value="${build.codegen}/extproperties.xml"/> | |||||
<property name="properties.xsl" value="${build.codegen}/properties.xsl"/> | <property name="properties.xsl" value="${build.codegen}/properties.xsl"/> | ||||
<property name="propmap.xsl" value="${build.codegen}/propmap.xsl"/> | <property name="propmap.xsl" value="${build.codegen}/propmap.xsl"/> | ||||
<property name="enumgen.xsl" value="${build.codegen}/enumgen.xsl"/> | <property name="enumgen.xsl" value="${build.codegen}/enumgen.xsl"/> | ||||
<!-- generate the java files from xml resources --> | <!-- generate the java files from xml resources --> | ||||
<echo message="Generating the java files from xml resources"/> | <echo message="Generating the java files from xml resources"/> | ||||
<xslt infile="${foproperties.xml}" xsltfile="${properties.xsl}" | <xslt infile="${foproperties.xml}" xsltfile="${properties.xsl}" | ||||
dependent="${propinc.xsl}" | dependent="${propinc.xsl}" | ||||
outfile="${build.src}/${replacestring}/fo/properties/fo_${ignore_this}" smart="yes"/> | outfile="${build.src}/${replacestring}/fo/properties/fo_${ignore_this}" smart="yes"/> | ||||
<xslt infile="${svgproperties.xml}" xsltfile="${properties.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/svg_${ignore_this}" smart="yes"/> | |||||
<xslt infile="${foproperties.xml}" xsltfile="${propmap.xsl}" | <xslt infile="${foproperties.xml}" xsltfile="${propmap.xsl}" | ||||
dependent="${propinc.xsl}" | dependent="${propinc.xsl}" | ||||
outfile="${build.src}/${replacestring}/fo/properties/FOPropertyMapping.java" smart="yes"/> | outfile="${build.src}/${replacestring}/fo/properties/FOPropertyMapping.java" smart="yes"/> | ||||
<xslt infile="${svgproperties.xml}" xsltfile="${propmap.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/SVGPropertyMapping.java" smart="yes"/> | |||||
<xslt infile="${foproperties.xml}" xsltfile="${enumgen.xsl}" | <xslt infile="${foproperties.xml}" xsltfile="${enumgen.xsl}" | ||||
dependent="${propinc.xsl}" | dependent="${propinc.xsl}" | ||||
outfile="${build.src}/${replacestring}/fo/properties/foenums_${ignore_this}" smart="yes"/> | outfile="${build.src}/${replacestring}/fo/properties/foenums_${ignore_this}" smart="yes"/> | ||||
<xslt infile="${svgproperties.xml}" xsltfile="${properties.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/svg_${ignore_this}" smart="yes"/> | |||||
<xslt infile="${svgproperties.xml}" xsltfile="${propmap.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/SVGPropertyMapping.java" smart="yes"/> | |||||
<xslt infile="${svgproperties.xml}" xsltfile="${enumgen.xsl}" | <xslt infile="${svgproperties.xml}" xsltfile="${enumgen.xsl}" | ||||
dependent="${propinc.xsl}" | dependent="${propinc.xsl}" | ||||
outfile="${build.src}/${replacestring}/fo/properties/svgenums_${ignore_this}" smart="yes"/> | outfile="${build.src}/${replacestring}/fo/properties/svgenums_${ignore_this}" smart="yes"/> | ||||
<xslt infile="${extproperties.xml}" xsltfile="${properties.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/ext_${ignore_this}" smart="yes"/> | |||||
<xslt infile="${extproperties.xml}" xsltfile="${propmap.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/ExtensionPropertyMapping.java" smart="yes"/> | |||||
<xslt infile="${extproperties.xml}" xsltfile="${enumgen.xsl}" | |||||
dependent="${propinc.xsl}" | |||||
outfile="${build.src}/${replacestring}/fo/properties/extenums_${ignore_this}" smart="yes"/> | |||||
<xslt infile="${charlist.xml}" xsltfile="${charlist.xsl}" | <xslt infile="${charlist.xml}" xsltfile="${charlist.xsl}" | ||||
outfile="${build.src}/${replacestring}/render/pdf/CodePointMapping.java" smart="yes"/> | outfile="${build.src}/${replacestring}/render/pdf/CodePointMapping.java" smart="yes"/> | ||||
<xslt infile="${Courier.xml}" xsltfile="${fontfile.xsl}" mergefile="${charlist.xml}" | <xslt infile="${Courier.xml}" xsltfile="${fontfile.xsl}" mergefile="${charlist.xml}" |
<fop fofile="${foDir}/simple.fo" pdffile="${testDir}/simple.pdf"/> | <fop fofile="${foDir}/simple.fo" pdffile="${testDir}/simple.pdf"/> | ||||
<fop fofile="${foDir}/hyphen.fo" pdffile="${testDir}/hyphen.pdf"/> | <fop fofile="${foDir}/hyphen.fo" pdffile="${testDir}/hyphen.pdf"/> | ||||
<fop fofile="${foDir}/character.fo" pdffile="${testDir}/character.pdf"/> | <fop fofile="${foDir}/character.fo" pdffile="${testDir}/character.pdf"/> | ||||
<fop fofile="${foDir}/pdfoutline.fo" pdffile="${testDir}/pdfoutline.pdf"/> | |||||
</target> | </target> | ||||
<?xml version="1.0" ?> | |||||
<property-list family="Extension"> | |||||
<generic-property-list> | |||||
<property> | |||||
<name>external-destination</name> | |||||
<inherited>false</inherited> | |||||
<datatype>String</datatype> | |||||
<default></default> | |||||
</property> | |||||
<property> | |||||
<name>internal-destination</name> | |||||
<inherited>false</inherited> | |||||
<datatype>String</datatype> | |||||
<default></default> | |||||
</property> | |||||
</generic-property-list> | |||||
</property-list> |
Version.getVersion()); | Version.getVersion()); | ||||
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMapping"); | |||||
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.extensions.ExtensionPropertyListMapping"); | |||||
driver.buildFOTree(parser, fileInputSource(foFile)); | driver.buildFOTree(parser, fileInputSource(foFile)); | ||||
driver.format(); | driver.format(); | ||||
driver.setOutputStream(new FileOutputStream(pdfFile)); | driver.setOutputStream(new FileOutputStream(pdfFile)); |
version); | version); | ||||
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMapping"); | |||||
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.extensions.ExtensionPropertyListMapping"); | |||||
OutputStream stream = new BufferedOutputStream(new FileOutputStream(pdfFile)); | OutputStream stream = new BufferedOutputStream(new FileOutputStream(pdfFile)); | ||||
driver.setOutputStream(stream); | driver.setOutputStream(stream); | ||||
driver.buildFOTree(parser, new InputSource(reader)); | driver.buildFOTree(parser, new InputSource(reader)); |
* @param id the id whose reference to use | * @param id the id whose reference to use | ||||
* @return reference to GoTo object | * @return reference to GoTo object | ||||
*/ | */ | ||||
public String getInternalLinkGotToReference(String id) | |||||
public String getInternalLinkGoToReference(String id) | |||||
{ | { | ||||
IDNode node = (IDNode)idReferences.get(id); | IDNode node = (IDNode)idReferences.get(id); | ||||
return node.getInternalLinkGoToReference(); | return node.getInternalLinkGoToReference(); |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.extensions; | |||||
import org.apache.fop.fo.*; | |||||
public class ExtensionElementMapping implements ElementMapping { | |||||
public static final String URI = "http://xml.apache.org/fop/extensions"; | |||||
public void addToBuilder(TreeBuilder builder) { | |||||
builder.addMapping(URI, "outline", Outline.maker()); | |||||
builder.addMapping(URI, "label", Label.maker()); | |||||
} | |||||
} |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.extensions; | |||||
import org.apache.fop.fo.*; | |||||
import org.apache.fop.layout.*; | |||||
import org.apache.fop.apps.FOPException; | |||||
/** | |||||
* base class for extension objects | |||||
*/ | |||||
public abstract class ExtensionObj extends FObj | |||||
{ | |||||
/** | |||||
* | |||||
* @param parent the parent formatting object | |||||
* @param propertyList the explicit properties of this object | |||||
*/ | |||||
public ExtensionObj(FObj parent, PropertyList propertyList) { | |||||
super(parent, propertyList); | |||||
} | |||||
/** | |||||
* Called for extensions within a page sequence or flow. These extensions | |||||
* are allowed to generate visible areas within the layout. | |||||
* | |||||
* | |||||
* @param area | |||||
*/ | |||||
public Status layout(Area area) throws FOPException { | |||||
ExtensionArea extArea = new ExtensionArea(this); | |||||
area.addChild(extArea); | |||||
return new Status(Status.OK); | |||||
} | |||||
/** | |||||
* Called for root extensions. Root extensions aren't allowed to generate | |||||
* any visible areas. They are used for extra items that don't show up in | |||||
* the page layout itself. For example: pdf outlines | |||||
* | |||||
* @param areaTree | |||||
*/ | |||||
public void format(AreaTree areaTree) throws FOPException { | |||||
ExtensionArea extArea = new ExtensionArea(this); | |||||
areaTree.addExtension(this); | |||||
} | |||||
} |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.extensions; | |||||
import org.apache.fop.fo.properties.ExtensionPropertyMapping; | |||||
import org.apache.fop.fo.PropertyListMapping; | |||||
import org.apache.fop.fo.TreeBuilder; | |||||
import java.util.Enumeration; | |||||
import java.util.Hashtable; | |||||
public class ExtensionPropertyListMapping implements PropertyListMapping { | |||||
public void addToBuilder(TreeBuilder builder) { | |||||
builder.addPropertyList(ExtensionElementMapping.URI, | |||||
ExtensionPropertyMapping.getGenericMappings()); | |||||
/* Add any element mappings */ | |||||
for (Enumeration e = ExtensionPropertyMapping.getElementMappings(); | |||||
e.hasMoreElements();) { | |||||
String elem = (String)e.nextElement(); | |||||
builder.addElementPropertyList(ExtensionElementMapping.URI, elem, | |||||
ExtensionPropertyMapping.getElementMapping(elem)); | |||||
} | |||||
} | |||||
} |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.extensions; | |||||
import org.apache.fop.fo.*; | |||||
public class Label extends ExtensionObj | |||||
{ | |||||
private String _label = ""; | |||||
public static class Maker extends FObj.Maker { | |||||
public FObj make(FObj parent, PropertyList propertyList) | |||||
{ | |||||
return new Label(parent, propertyList); | |||||
} | |||||
} | |||||
public static FObj.Maker maker() { | |||||
return new Label.Maker(); | |||||
} | |||||
public Label(FObj parent, PropertyList propertyList) { | |||||
super(parent, propertyList); | |||||
} | |||||
protected void addCharacters(char data[], int start, int end) { | |||||
_label += new String(data, start, end-start); | |||||
} | |||||
public String toString() | |||||
{ | |||||
return _label; | |||||
} | |||||
} |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.extensions; | |||||
import org.apache.fop.fo.*; | |||||
import org.apache.fop.pdf.PDFGoTo; | |||||
import org.apache.fop.pdf.PDFAction; | |||||
import org.apache.fop.datatypes.IDReferences; | |||||
import org.apache.fop.messaging.MessageHandler; | |||||
import java.util.*; | |||||
public class Outline extends ExtensionObj | |||||
{ | |||||
private Label _label; | |||||
private Vector _outlines = new Vector(); | |||||
private String _internalDestination; | |||||
private String _externalDestination; | |||||
/** The parent outline object if it exists */ | |||||
private Outline _parentOutline; | |||||
/** an opaque renderer context object, e.g. PDFOutline for PDFRenderer */ | |||||
private Object _rendererObject; | |||||
public static class Maker extends FObj.Maker { | |||||
public FObj make(FObj parent, PropertyList propertyList) | |||||
{ | |||||
return new Outline(parent, propertyList); | |||||
} | |||||
} | |||||
public static FObj.Maker maker() { | |||||
return new Outline.Maker(); | |||||
} | |||||
public Outline(FObj parent, PropertyList propertyList) { | |||||
super(parent, propertyList); | |||||
_internalDestination = this.properties.get("internal-destination").getString(); | |||||
_externalDestination = this.properties.get("external-destination").getString(); | |||||
if (_externalDestination != null && !_externalDestination.equals("")) { | |||||
MessageHandler.errorln("WARNING: fox:outline external-destination not supported currently."); | |||||
} | |||||
if (_internalDestination == null || _internalDestination.equals("")) { | |||||
MessageHandler.errorln("WARNING: fox:outline requires an internal-destination."); | |||||
} | |||||
for (FONode node = getParent(); node != null; node = node.getParent()) { | |||||
if (node instanceof Outline) { | |||||
_parentOutline = (Outline)node; | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
protected void addChild(FONode obj) | |||||
{ | |||||
if (obj instanceof Label) { | |||||
_label = (Label)obj; | |||||
} | |||||
else if (obj instanceof Outline) { | |||||
_outlines.add(obj); | |||||
} | |||||
super.addChild(obj); | |||||
} | |||||
public void setRendererObject(Object o) | |||||
{ | |||||
_rendererObject = o; | |||||
} | |||||
public Object getRendererObject() | |||||
{ | |||||
return _rendererObject; | |||||
} | |||||
public Outline getParentOutline() | |||||
{ | |||||
return _parentOutline; | |||||
} | |||||
public Label getLabel() | |||||
{ | |||||
return _label == null?new Label(this,this.properties):_label; | |||||
} | |||||
public Vector getOutlines() | |||||
{ | |||||
return _outlines; | |||||
} | |||||
public String getInternalDestination() | |||||
{ | |||||
return _internalDestination; | |||||
} | |||||
} | |||||
import org.apache.fop.fo.properties.*; | import org.apache.fop.fo.properties.*; | ||||
import org.apache.fop.layout.AreaTree; | import org.apache.fop.layout.AreaTree; | ||||
import org.apache.fop.apps.FOPException; | import org.apache.fop.apps.FOPException; | ||||
import org.apache.fop.extensions.ExtensionObj; | |||||
// Java | // Java | ||||
import java.util.Vector; | import java.util.Vector; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
/** | |||||
* The fo:root formatting object. Contains page masters, root extensions, | |||||
* page-sequences. | |||||
*/ | |||||
public class Root extends FObj { | public class Root extends FObj { | ||||
public static class Maker extends FObj.Maker { | |||||
public FObj make(FObj parent, PropertyList propertyList) throws FOPException { | |||||
return new Root(parent, propertyList); | |||||
} | |||||
} | |||||
public static FObj.Maker maker() | |||||
public static class Maker extends FObj.Maker { | |||||
public FObj make(FObj parent, PropertyList propertyList) | |||||
throws FOPException | |||||
{ | { | ||||
return new Root.Maker(); | |||||
} | |||||
LayoutMasterSet layoutMasterSet; | |||||
Vector pageSequences; | |||||
protected Root(FObj parent, PropertyList propertyList) throws FOPException | |||||
{ | |||||
super(parent, propertyList); | |||||
this.name = "fo:root"; | |||||
pageSequences = new Vector(); | |||||
if (parent != null) | |||||
{ | |||||
throw new FOPException("root must be root element"); | |||||
} | |||||
} | |||||
public void addPageSequence(PageSequence pageSequence) | |||||
{ | |||||
this.pageSequences.addElement(pageSequence); | |||||
} | |||||
public LayoutMasterSet getLayoutMasterSet() | |||||
{ | |||||
return this.layoutMasterSet; | |||||
return new Root(parent, propertyList); | |||||
} | } | ||||
} | |||||
public static FObj.Maker maker() | |||||
{ | |||||
return new Root.Maker(); | |||||
} | |||||
public void format(AreaTree areaTree) throws FOPException | |||||
{ | |||||
// MessageHandler.errorln(" Root[" + marker + "] "); | |||||
if(layoutMasterSet == null) | |||||
{ | |||||
throw new FOPException("No layout master set."); | |||||
} | |||||
LayoutMasterSet layoutMasterSet; | |||||
Vector pageSequences; | |||||
Enumeration e = pageSequences.elements(); | |||||
while (e.hasMoreElements()) | |||||
{ | |||||
((PageSequence) e.nextElement()).format(areaTree); | |||||
} | |||||
protected Root(FObj parent, PropertyList propertyList) throws FOPException | |||||
{ | |||||
super(parent, propertyList); | |||||
this.name = "fo:root"; | |||||
} | |||||
pageSequences = new Vector(); | |||||
if (parent != null) | |||||
{ | |||||
throw new FOPException("root must be root element"); | |||||
} | |||||
} | |||||
/** @deprecated handled by addChild now | |||||
*/ | |||||
public void addPageSequence(PageSequence pageSequence) | |||||
{ | |||||
this.pageSequences.addElement(pageSequence); | |||||
} | |||||
public LayoutMasterSet getLayoutMasterSet() | |||||
{ | |||||
return this.layoutMasterSet; | |||||
} | |||||
public void setLayoutMasterSet(LayoutMasterSet layoutMasterSet) { | public void setLayoutMasterSet(LayoutMasterSet layoutMasterSet) { | ||||
this.layoutMasterSet = layoutMasterSet; | this.layoutMasterSet = layoutMasterSet; | ||||
} | } | ||||
public void format(AreaTree areaTree) throws FOPException | |||||
{ | |||||
// MessageHandler.errorln(" Root[" + marker + "] "); | |||||
if(layoutMasterSet == null) { | |||||
throw new FOPException("No layout master set."); | |||||
} | |||||
Enumeration e = children.elements(); | |||||
while (e.hasMoreElements()) { | |||||
Object o = e.nextElement(); | |||||
if (o instanceof PageSequence) { | |||||
((PageSequence) o).format(areaTree); | |||||
} | |||||
else if (o instanceof ExtensionObj) { | |||||
((ExtensionObj)o).format(areaTree); | |||||
} | |||||
} | |||||
} | |||||
} | } |
import org.apache.fop.svg.*; | import org.apache.fop.svg.*; | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
import org.apache.fop.datatypes.IDReferences; | import org.apache.fop.datatypes.IDReferences; | ||||
import org.apache.fop.extensions.ExtensionObj; | |||||
// Java | // Java | ||||
import java.io.IOException; | import java.io.IOException; | ||||
/* list of all the pages */ | /* list of all the pages */ | ||||
Vector pageList = new Vector(); | Vector pageList = new Vector(); | ||||
/** List of root extension objects */ | |||||
Vector rootExtensions = new Vector(); | |||||
IDReferences idReferences = new IDReferences(); | IDReferences idReferences = new IDReferences(); | ||||
public void setFontInfo(FontInfo fontInfo) { | public void setFontInfo(FontInfo fontInfo) { | ||||
{ | { | ||||
return idReferences; | return idReferences; | ||||
} | } | ||||
public void addExtension(ExtensionObj obj) | |||||
{ | |||||
rootExtensions.addElement(obj); | |||||
} | |||||
public Vector getExtensions() | |||||
{ | |||||
return rootExtensions; | |||||
} | |||||
} | } |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.layout; | |||||
import org.apache.fop.fo.*; | |||||
import org.apache.fop.extensions.*; | |||||
import org.apache.fop.render.*; | |||||
public class ExtensionArea extends Area | |||||
{ | |||||
private ExtensionObj _extensionObj; | |||||
public ExtensionArea (ExtensionObj obj) { | |||||
super(null); | |||||
_extensionObj = obj; | |||||
} | |||||
public FObj getExtensionObj() | |||||
{ | |||||
return _extensionObj; | |||||
} | |||||
public void render(Renderer renderer) | |||||
{ | |||||
// renderer.renderExtensionArea(this); | |||||
} | |||||
} |
} | } | ||||
} | } | ||||
else { // linkType is internal | else { // linkType is internal | ||||
String goToReference; | |||||
PDFInternalLink internalLink; | |||||
if ( idReferences.doesIDExist(destination) ) { | |||||
if ( idReferences.doesGoToReferenceExist(destination) ) { | |||||
goToReference = idReferences.getInternalLinkGotToReference(destination); | |||||
} | |||||
else { //assign Internal Link GoTo object | |||||
goToReference = idReferences.createInternalLinkGoTo(destination,++this.objectcount); | |||||
this.objects.addElement(idReferences.getPDFGoTo(destination)); | |||||
} | |||||
} | |||||
else { //id was not found, so create it | |||||
idReferences.createNewId(destination); | |||||
idReferences.addToIdValidationList(destination); | |||||
goToReference = idReferences.createInternalLinkGoTo(destination,++this.objectcount); | |||||
this.objects.addElement(idReferences.getPDFGoTo(destination)); | |||||
} | |||||
internalLink = new PDFInternalLink(goToReference); | |||||
String goToReference = getGoToReference(destination); | |||||
PDFInternalLink internalLink = new PDFInternalLink(goToReference); | |||||
link.setAction(internalLink); | link.setAction(internalLink); | ||||
} | } | ||||
return link; | return link; | ||||
} | } | ||||
private String getGoToReference(String destination) | |||||
{ | |||||
String goToReference; | |||||
if ( idReferences.doesIDExist(destination) ) { | |||||
if ( idReferences.doesGoToReferenceExist(destination) ) { | |||||
goToReference = idReferences.getInternalLinkGoToReference(destination); | |||||
} | |||||
else { //assign Internal Link GoTo object | |||||
goToReference = idReferences.createInternalLinkGoTo(destination,++this.objectcount); | |||||
this.objects.addElement(idReferences.getPDFGoTo(destination)); | |||||
} | |||||
} | |||||
else { //id was not found, so create it | |||||
idReferences.createNewId(destination); | |||||
idReferences.addToIdValidationList(destination); | |||||
goToReference = idReferences.createInternalLinkGoTo(destination,++this.objectcount); | |||||
this.objects.addElement(idReferences.getPDFGoTo(destination)); | |||||
} | |||||
return goToReference; | |||||
} | |||||
/** | /** | ||||
* make a stream object | * make a stream object | ||||
return obj; | return obj; | ||||
} | } | ||||
/** | |||||
* Make the root Outlines object | |||||
*/ | |||||
public PDFOutline makeOutlineRoot() | |||||
{ | |||||
PDFOutline obj = new PDFOutline(++this.objectcount, null, null); | |||||
this.objects.addElement(obj); | |||||
root.setRootOutline(obj); | |||||
return obj; | |||||
} | |||||
/** Make an outline object and add it to the given outline | |||||
* @param parent parent PDFOutline object | |||||
* @param label the title for the new outline object | |||||
* @param action the PDFAction to reference | |||||
*/ | |||||
public PDFOutline makeOutline(PDFOutline parent, | |||||
String label, | |||||
String destination) | |||||
{ | |||||
String goToRef = getGoToReference(destination); | |||||
PDFOutline obj = new PDFOutline(++this.objectcount, label, goToRef); | |||||
// System.out.println("created new outline object"); | |||||
if (parent != null) { | |||||
parent.addOutline(obj); | |||||
} | |||||
this.objects.addElement(obj); | |||||
return obj; | |||||
} | |||||
/** | /** | ||||
* get the /Resources object for the document | * get the /Resources object for the document | ||||
* | * |
* class representing a /GoTo object. | * class representing a /GoTo object. | ||||
* | * | ||||
*/ | */ | ||||
public class PDFGoTo extends PDFObject { | |||||
public class PDFGoTo extends PDFAction { | |||||
/** the pageReference */ | /** the pageReference */ | ||||
protected String pageReference; | protected String pageReference; | ||||
this.xPosition = (xPosition/1000f); | this.xPosition = (xPosition/1000f); | ||||
} | } | ||||
public String getAction() | |||||
{ | |||||
return referencePDF(); | |||||
} | |||||
/** | /** | ||||
* represent the object in PDF | * represent the object in PDF |
/*-- $Id$ -- | |||||
============================================================================ | |||||
The Apache Software License, Version 1.1 | |||||
============================================================================ | |||||
Copyright (C) 1999 The Apache Software Foundation. All rights reserved. | |||||
Redistribution and use in source and binary forms, with or without modifica- | |||||
tion, are permitted provided that the following conditions are met: | |||||
1. Redistributions of source code must retain the above copyright notice, | |||||
this list of conditions and the following disclaimer. | |||||
2. Redistributions in binary form must reproduce the above copyright notice, | |||||
this list of conditions and the following disclaimer in the documentation | |||||
and/or other materials provided with the distribution. | |||||
3. The end-user documentation included with the redistribution, if any, must | |||||
include the following acknowledgment: "This product includes software | |||||
developed by the Apache Software Foundation (http://www.apache.org/)." | |||||
Alternately, this acknowledgment may appear in the software itself, if | |||||
and wherever such third-party acknowledgments normally appear. | |||||
4. The names "FOP" and "Apache Software Foundation" must not be used to | |||||
endorse or promote products derived from this software without prior | |||||
written permission. For written permission, please contact | |||||
apache@apache.org. | |||||
5. Products derived from this software may not be called "Apache", nor may | |||||
"Apache" appear in their name, without prior written permission of the | |||||
Apache Software Foundation. | |||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, | |||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |||||
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- | |||||
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | |||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
This software consists of voluntary contributions made by many individuals | |||||
on behalf of the Apache Software Foundation and was originally created by | |||||
James Tauber <jtauber@jtauber.com>. For more information on the Apache | |||||
Software Foundation, please see <http://www.apache.org/>. | |||||
*/ | |||||
package org.apache.fop.pdf; | |||||
import java.util.Vector; | |||||
/** | |||||
* This represents a single Outline object in a PDF, including the root Outlines | |||||
* object. Outlines provide the bookmark bar, usually rendered to the right of | |||||
* a PDF document in user agents such as Acrobat Reader | |||||
* | |||||
* @author Kelly A. Campbell | |||||
* | |||||
*/ | |||||
public class PDFOutline extends PDFObject | |||||
{ | |||||
/** list of sub-entries (outline objects) */ | |||||
private Vector _subentries; | |||||
/** parent outline object. Root Outlines parent is null */ | |||||
private PDFOutline _parent; | |||||
private PDFOutline _prev; | |||||
private PDFOutline _next; | |||||
private PDFOutline _first; | |||||
private PDFOutline _last; | |||||
private int _count; | |||||
/** title to display for the bookmark entry */ | |||||
private String _title; | |||||
String _actionRef; | |||||
/** | |||||
* @param number the object id number | |||||
* @param title the title of the outline entry (can only be null for root Outlines obj) | |||||
* @param page the page which this outline refers to. | |||||
*/ | |||||
public PDFOutline(int number, String title, String action) | |||||
{ | |||||
super(number); | |||||
_subentries = new Vector(); | |||||
_count = 0; | |||||
_parent = null; | |||||
_prev = null; | |||||
_next = null; | |||||
_first = null; | |||||
_last = null; | |||||
_title = title; | |||||
_actionRef = action; | |||||
} | |||||
public void setTitle(String title) | |||||
{ | |||||
_title = title; | |||||
} | |||||
/** | |||||
* Add a sub element to this outline | |||||
*/ | |||||
public void addOutline(PDFOutline outline) | |||||
{ | |||||
if (_subentries.size() > 0) { | |||||
outline._prev = (PDFOutline)_subentries.elementAt(_subentries.size() - 1); | |||||
outline._prev._next = outline; | |||||
} | |||||
else { | |||||
_first = outline; | |||||
} | |||||
_subentries.addElement(outline); | |||||
outline._parent = this; | |||||
incrementCount(); // note: count is not just the immediate children | |||||
_last = outline; | |||||
} | |||||
private void incrementCount() | |||||
{ | |||||
// count is a total of our immediate subentries and all descendent subentries | |||||
_count++; | |||||
if (_parent != null) { | |||||
_parent.incrementCount(); | |||||
} | |||||
} | |||||
/** represent the object in PDF */ | |||||
protected byte[] toPDF() | |||||
{ | |||||
StringBuffer result = new StringBuffer(this.number+" "+this.generation+" obj\n<<\n"); | |||||
if (_parent == null) { | |||||
// root Outlines object | |||||
if (_first != null && _last != null) { | |||||
result.append(" /First "+_first.referencePDF()+"\n"); | |||||
result.append(" /Last "+_last.referencePDF()+"\n"); | |||||
// no count... we start with the outline completely closed for now | |||||
} | |||||
} | |||||
else { | |||||
// subentry Outline object | |||||
result.append(" /Title ("+escapeString(_title)+")\n"); | |||||
result.append(" /Parent "+_parent.referencePDF()+"\n"); | |||||
if (_first != null && _last != null) { | |||||
result.append(" /First "+_first.referencePDF()+"\n"); | |||||
result.append(" /Last "+_last.referencePDF()+"\n"); | |||||
} | |||||
if (_prev != null) { | |||||
result.append(" /Prev "+_prev.referencePDF()+"\n"); | |||||
} | |||||
if (_next != null) { | |||||
result.append(" /Next "+_next.referencePDF()+"\n"); | |||||
} | |||||
if (_count > 0) { | |||||
result.append(" /Count -"+_count+"\n"); | |||||
} | |||||
if (_actionRef != null) { | |||||
result.append(" /A "+_actionRef+"\n"); | |||||
} | |||||
} | |||||
result.append(">> endobj\n"); | |||||
return result.toString().getBytes(); | |||||
} | |||||
/** escape parens, and other special chars for PDF */ | |||||
private String escapeString(String s) | |||||
{ | |||||
StringBuffer result = new StringBuffer(); | |||||
if (s != null) { | |||||
int l = s.length(); | |||||
for (int i = 0; i < l; i++) { | |||||
char ch = s.charAt(i); | |||||
if (ch > 127) { | |||||
result.append("\\"); | |||||
result.append(Integer.toOctalString((int) ch)); | |||||
} else { | |||||
switch (ch) { | |||||
case '(' : | |||||
case ')' : | |||||
case '\\' : | |||||
result.append('\\'); | |||||
break; | |||||
} | |||||
result.append(ch); | |||||
} | |||||
} | |||||
} | |||||
return result.toString(); | |||||
} | |||||
} |
/** the /Pages object that is root of the Pages hierarchy */ | /** the /Pages object that is root of the Pages hierarchy */ | ||||
protected PDFPages rootPages; | protected PDFPages rootPages; | ||||
/** Root outline object */ | |||||
private PDFOutline _outline; | |||||
/** | /** | ||||
* create a Root (/Catalog) object | * create a Root (/Catalog) object | ||||
* | * | ||||
this.rootPages = pages; | this.rootPages = pages; | ||||
} | } | ||||
public void setRootOutline(PDFOutline outline) | |||||
{ | |||||
_outline = outline; | |||||
} | |||||
/** | /** | ||||
* represent the object as PDF | * represent the object as PDF | ||||
* | * | ||||
* @return the PDF string | * @return the PDF string | ||||
*/ | */ | ||||
public byte[] toPDF() { | public byte[] toPDF() { | ||||
String p = this.number + " " + this.generation | |||||
StringBuffer p = new StringBuffer(this.number + " " + this.generation | |||||
+ " obj\n<< /Type /Catalog\n/Pages " | + " obj\n<< /Type /Catalog\n/Pages " | ||||
+ this.rootPages.referencePDF() + " >>\nendobj\n"; | |||||
return p.getBytes(); | |||||
+ this.rootPages.referencePDF() + "\n"); | |||||
if (_outline != null) { | |||||
p.append(" /Outlines "+_outline.referencePDF()+"\n"); | |||||
p.append(" /PageMode /UseOutlines\n"); | |||||
} | |||||
p.append(" >>\nendobj\n"); | |||||
return p.toString().getBytes(); | |||||
} | } | ||||
} | } |
import org.apache.fop.layout.*; | import org.apache.fop.layout.*; | ||||
import org.apache.fop.image.*; | import org.apache.fop.image.*; | ||||
import org.apache.fop.configuration.Configuration; | import org.apache.fop.configuration.Configuration; | ||||
import org.apache.fop.extensions.*; | |||||
import org.apache.fop.datatypes.IDReferences; | |||||
import org.w3c.dom.*; | import org.w3c.dom.*; | ||||
import org.w3c.dom.svg.*; | import org.w3c.dom.svg.*; | ||||
boolean useKerning; | boolean useKerning; | ||||
private PDFOutline rootOutline; | |||||
/** | /** | ||||
* create the PDF renderer | * create the PDF renderer | ||||
idReferences.getInvalidIds() + "\n"); | idReferences.getInvalidIds() + "\n"); | ||||
} | } | ||||
renderRootExtensions(areaTree); | |||||
MessageHandler.logln("writing out PDF"); | MessageHandler.logln("writing out PDF"); | ||||
this.pdfDoc.output(stream); | this.pdfDoc.output(stream); | ||||
} | } | ||||
return rs; | return rs; | ||||
} | } | ||||
protected void renderRootExtensions(AreaTree areaTree) | |||||
{ | |||||
Vector v = areaTree.getExtensions(); | |||||
if (v != null) { | |||||
Enumeration e = v.elements(); | |||||
while (e.hasMoreElements()) { | |||||
ExtensionObj ext = (ExtensionObj)e.nextElement(); | |||||
if (ext instanceof Outline) { | |||||
renderOutline((Outline)ext); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
private void renderOutline(Outline outline) | |||||
{ | |||||
if (rootOutline == null) { | |||||
rootOutline = this.pdfDoc.makeOutlineRoot(); | |||||
} | |||||
PDFOutline pdfOutline = null; | |||||
Outline parent = outline.getParentOutline(); | |||||
if (parent == null) { | |||||
pdfOutline = this.pdfDoc.makeOutline(rootOutline, | |||||
outline.getLabel().toString(), | |||||
outline.getInternalDestination()); | |||||
} | |||||
else { | |||||
PDFOutline pdfParentOutline = (PDFOutline)parent.getRendererObject(); | |||||
if (pdfParentOutline == null) { | |||||
MessageHandler.errorln("Error: pdfParentOutline is null"); | |||||
} | |||||
else { | |||||
pdfOutline = this.pdfDoc.makeOutline(pdfParentOutline, | |||||
outline.getLabel().toString(), | |||||
outline.getInternalDestination()); | |||||
} | |||||
} | |||||
outline.setRendererObject(pdfOutline); | |||||
// handle sub outlines | |||||
Vector v = outline.getOutlines(); | |||||
Enumeration e = v.elements(); | |||||
while (e.hasMoreElements()) { | |||||
renderOutline((Outline)e.nextElement()); | |||||
} | |||||
} | |||||
} | } |
version); | version); | ||||
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | driver.addElementMapping("org.apache.fop.fo.StandardElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | driver.addElementMapping("org.apache.fop.svg.SVGElementMapping"); | ||||
driver.addElementMapping("org.apache.fop.extensions.ExtensionElementMapping"); | |||||
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping"); | ||||
driver.addPropertyList("org.apache.fop.extensions.ExtensionPropertyListMapping"); | |||||
driver.setOutputStream(new FileOutputStream(pdffile)); | driver.setOutputStream(new FileOutputStream(pdffile)); | ||||
driver.buildFOTree(parser, fileInputSource(fofile)); | driver.buildFOTree(parser, fileInputSource(fofile)); | ||||
driver.format(); | driver.format(); |