From 726f89d6ade324f36287b250a64906fbf2d7506c Mon Sep 17 00:00:00 2001
From: Christian Geisert FOP distributions are either pre-compiled binary or source.
If you are using a binary distribution, it is already built and there is no need to build it again. See the Download Instructions for information about whether a binary or source distribution is best for your needs.
- Building FOP requires a minimum Java Development Kit (JDK) of 1.3.
+ Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.3
+ (A Java Runtime Environment ist not sufficient)
There is no generally no need to setup a classpath.
All libraries needed to compile FOP are included in the source distribution and are referenced by the build script.
You will only need to adjust the classpath if you build FOP in some other way. See the build scripts (build.bat for Windows, and build.sh for Unix) for details. Ant, which is used by the build script, requires that the environment variable JAVA_HOME point to your local JDK root directory.
This is true even if you use JDK 1.2 or above, which normally don't need this setting. Build FOP by executing the "build" script, which is located in the FOP root directory.
The Windows batch file is build.bat, and the Unix shell script is build.sh.
@@ -59,8 +60,8 @@ To obtain a complete list of useful build targets: To clean the build directory first: If you have problems building FOP, please try the following: In the directory xml-fop/conf you will find two configuration files. One of them,
- config.xml, is only intended for FOP developers, who want to add new default values
- to some FOP feature. Don't change this file. For user configuration there is a file called
- userconfig.xml. It contains templates for all settings a user can change. Most of them are
- commented out. Uncomment the entry you want to set and change the value according to
- your wishes. Please regard any comments which specify the value range. And, well, the
- configuration files are xml files, so keep them at least well-formed. ;-)
- The file userconfig.xml is not read automatically, but the user must specify its use on
- the command line. See Running FOP
- or Embedding FOP for details.
- The FOP configuration file is an XML file containing a variety of settings that are useful for controlling FOP's behavior, and for helping it find resources that you wish it to use. The easiest way to get started using a FOP configuration file is to copy the sample found at The general structure of the configuration file is a series of <entry> tags, each containing a <key> and a <value>. (Fonts use a different format). Here is an example: After creating your configuration file, you must tell FOP how to find it: See Setting the Configuration Programmatically for instructions on how to do so in an embedded environment. FOP comes already with some hyphenation pattern. If you need a hyphenation pattern
- which isn't included in the distribution, do the following:
- The sections below provide detailed information for configuration options that are not self-explanatory. The parenthetical information after each key name indicates (Data Type, Default). Use this entry to indicate a directory containing custom hyphenation files (if any).
+See FOP: Hyphenation for more information on creating and modifying hyphenation within FOP. In some cases, some text in SVG documents is converted to graphical shapes instead of retaining its character as text. To force all text to be rendered as text, set strokeSVGText = false. For a discussion of this issue, see FOP: Graphics, Placing SVG Text into PDF. Font configuration information is included in the FOP configuration file, but is documented at FOP: Fonts. Note especially the section entitled Register Fonts with FOP. Basic documents are stored in XML files, and use DTDs provided by Apache Forrest. These principles are not written in stone, but reflect the current philosophy, and are documented here primarily to help achieve consistency. These principles should be changed if better or more practical ones are found, but they should probably be discussed and changed by common consent. The documentation and the product are in a constant state of change, and there is some difficulty in deciding what product state the website content should reflect. The current thinking is that the website should reflect the current state of the repository code branch from which releases are made. Features or other documentation that applies to unreleased code should be marked in such a way within the content that the user can determine whether and how it applies to the version they are using. For example, "Feature xyz is first available in Release n.nn.n". Other approaches were considered, but all seemed to have significantly higher costs both to the users and the developers. From the user's standpoint, the choice is either that they potentially have to look multiple places to get the information they need (which was rejected), or they have to filter out an occasional feature that is in code available subsequent to their release (which was accepted). Please note that patches for enhancements to the maintenance branch will generally not be considered. Bug fixes are welcome there, but new developers are strongly encouraged to apply their efforts to the trunk development line. Because there is a fair amount of common information between the maintenance and trunk development lines, we attempt to document them together, highlighting differences only where needed. The design for FOP is specified under the Design section. This is where the information on how FOP is developed and designed
+ The design for FOP is specified under the Design section. This is where the information on how FOP is developed and designed
internally will be kept.
Binary distributions include "-bin" in their names, and can be downloaded from the FOP Distribution directory.
-
- {fop-dir}/conf/userconfig.xml
to a location of your choice, and then to edit it according to your needs.
+It contains templates for the various configuration options, most of which are commented out. Remove the comments and change the settings for entries that you wish to use.
+Be sure to follow any instructions, including comments which specify the value range.
+Also, since the configuration file is XML, be sure to keep it well-formed.{fop-dir}/conf/config.xml
or use it as the basis for your configuration file. It has an entirely different purpose.
+
+
-
+
-
-
+
+
+
+ Option (key)
+ Data Type (for the value)
+ Default Value
+
+
+ baseDir
+ URL
+ For command-line, the directory containing the input FO or XML file. For embedded, the current working directory.
+
+
+ fontBaseDir
+ URL
+ value of baseDir
+
+
+ hyphenation-dir
+ URL
+ None. This is for custom hyphenation patterns.
+
+
+ strokeSVGText
+ Boolean
+ True
+
+
+
Here is an example use of Driver which outputs PDF:
+Driver driver = new Driver(new InputSource(args[0]), + new FileOutputStream(args[1])); +driver.setRenderer(Driver.RENDER_PDF); +driver.run();]]>In the example above, args[0] contains the path to an XSL-FO file, while args[1] contains a path for the target PDF file.
-You also need to set up logging. Global logging for all FOP
- processes is managed by MessageHandler. Per-instance logging
- is handled by Driver. You want to set both using an implementation
- of org.apache.avalon.framework.logger.Logger. See
-
+ You also need to set up logging. Global logging for all FOP
+ processes is managed by MessageHandler. Per-instance logging
+ is handled by Driver. You want to set both using an implementation
+ of org.apache.avalon.framework.logger.Logger. See
+
+ Call setLogger(Logger)
always immediately after
+ instantiating the Driver object. See here:
+
To setup the user config file you can do the following -
+/*..*/ + +Driver driver = new Driver(); +Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); +MessageHandler.setScreenLogger(logger); +driver.setLogger(logger);]]> +
+ Once the Driver is set up, one of the render()
methods
+ is called. Depending on whether DOM or an InputSource is being used, the
+ invocation of the method is either render(Document)
or
+ render(Parser, InputSource)
respectively.
+
+ Another possibility may be used to build the FO Tree: You can
+ call getContentHandler()
and fire the SAX events yourself.
+
+ You don't have to call run()
or render()
on the
+ Driver object if you use getContentHandler()
.
+
Here is an example use of Driver:
-Once the Driver is set up, the render method
- is called. Depending on whether DOM or SAX is being used, the
- invocation of the method is either render(Document)
or
- render(Parser, InputSource)
respectively.
-
- Another possibility may be used to build the FO Tree. You can
- call getContentHandler()
and fire the SAX events yourself.
-
-
Once the FO Tree is built, the format() and render() methods may be - called in that order. -
-Here is an example use of Driver:
- -You can also specify an xml and xsl file for the input. -
-Here is an example use of Driver with the XSLTInputHandler:
- -Have a look at the classes CommandLineStarter or FopServlet for complete - examples. Also, have a look at the examples at the bottom of this page. -
++ If you want to process XSL-FO generated from XML using XSLT we recommend + using standard JAXP to do the XSLT part and piping the generated SAX + events directly through to FOP. Here's how this would look like: +
+ +run()
or render()
.+ This may look complicated at first, but it's really just the combination of an + XSL transformation and a FOP run. It's also easy to comment out the FOP part + for debugging purposes, for example when you're tracking down a bug in your + stylesheet. You can easily write the XSL-FO output from the XSL transformation + to a file to check if that part generates the expected output. +
++ For fully working examples of the above and hints to some interesting + possibilities, see the examples section below. +
+FOP uses Jakarta Avalon's
-
Per default FOP uses the ConsoleLogger which logs to System.out. If you want to do logging using a - logging framework (such as LogKit, Log4J or JDK 1.4 Logging) you can set a - different Logger implementation on the Driver object. Here's an example how you would use LogKit:
+
+ FOP uses the
+
+ Per default FOP uses the ConsoleLogger which logs to System.out. If you want to do logging using a + logging framework (such as LogKit, Log4J or JDK 1.4 Logging) you can set a + different Logger implementation on the Driver object. Here's an example how you would use LogKit: +
-The LogKitLogger class implements the Logger interface so all logging calls are being redirected to LogKit.
- More information on Jakarta LogKit can be found
Similar implementations exist for Log4J (org.apache.avalon.framework.logger.Log4JLogger) and - JDK 1.4 logging (org.apache.avalon.framework.logger.Jdk14Logger).
-If you want FOP to be totally silent you can also set an org.apache.avalon.framework.logger.NullLogger instance.
-If you want to use yet another logging facility you simply have to create a class that implements org.apache.avalon.framework.logging.Logger - and set it on the Driver object. See the existing implementations in Avalon Framework for examples.
-The input XSL-FO document is always handled internally as SAX (see the Parsing Design Document for the rationale). -However, the input itself can be provided in a variety of ways to FOP, which normalizes the input (if necessary) into SAX events:
-FOTreeBuilder
is the SAX Handler which is obtained through getContentHandler
on Driver
.render(Document)
method on Driver
.Driver
can take an InputSource
as input.
-This can use a Stream
, String
etc.XSLTInputHandler
is used as an InputSource
in the render(XMLReader
, InputSource
) method on Driver
.There are a variety of upstream data manipulations possible.
-For example, you may have a DOM and an XSL stylesheet; or you may want to
-set variables in the stylesheet.
-Interface documentation and some cookbook solutions to these situations are provided in
-See the Examples for some variations on input. -
--If FOP is going to be used multiple times within your application -it may be useful to reuse certain objects to save time. -
--The renderers and the driver can both be reused. A renderer is reusable -once the previous render has been completed. The driver is reuseable -after the rendering is complete and the reset method is called. -You will need to setup the driver again with a new OutputStream, -IntputStream and renderer. -
-
-To get the number of pages that were rendered by FOP you can call
-Driver.getResults()
. This returns a FormattingResults object
-where you can lookup the number of pages produced. It also gives you the
-page-sequences that were produced along with their id attribute and their
-number of pages. This is particularly useful if you render multiple
-documents (each enclosed by a page-sequence) and have to know the number of
-pages of each document.
-
- Here is a minimal code snippet to demonstrate the basics: -
- --There are numerous problems with the code snippet above. -Its purpose is only to demonstrate the basic concepts. -See xml-fop/examples/servlet for a working example of FOP used in a servlet. -After building the servlet, drop the fop.war into the webapps directory of Tomcat. -Then access a URL as follows: -
-http://localhost:8080/fop/fop?fo=/home/path/to/fofile.fo
-http://localhost:8080/fop/fop?xml=/home/path/to/xmlfile.xml&xsl=/home/path/to/xslfile.xsl
-The source code for the servlet can be found under xml-fop/examples/servlet/src/FopServlet.java.
-
- If both the source XML and XSL are read from files, use the TraxInputHandler:
+ The LogKitLogger class implements the Logger interface so all logging calls are being redirected to LogKit.
+ More information on Jakarta LogKit can be found
- This code snippet has the same problems as the one from the section above. + Similar implementations exist for Log4J (org.apache.avalon.framework.logger.Log4JLogger) and + JDK 1.4 logging (org.apache.avalon.framework.logger.Jdk14Logger).
- If your source XML is generated on the fly (for example from a database, a web service, or another servlet), create a transformer object explicitly, and use a SAX event stream to feed the transformation result into FOP: + If you want FOP to be totally silent you can also set an org.apache.avalon.framework.logger.NullLogger instance.
-- You don't have to call run() or render() on the driver object. + If you want to use yet another logging facility you simply have to create a class that + implements org.apache.avalon.framework.logging.Logger and set it on the Driver object. + See the existing implementations in Avalon Framework for examples.
+
- The xmlsource
is a placeholder for your actual XML source.
-If you have to read the XML from a string, supply a new StreamSource(new StringReader(xmlstring))
.
-Constructing and reparsing an XML string is generally less desirable than using a SAXSource if you generate your XML.
-You can alternatively supply a DOMSource as well.
-You may also use dynamically generated XSL if you like.
+ The input XSL-FO document is always handled internally as SAX (see the
+ Parsing Design Document for the rationale).
+ However, the input itself can be provided in a variety of ways to FOP,
+ which normalizes the input (if necessary) into SAX events:
FOTreeBuilder
is the SAX Handler which is obtained through getContentHandler
on Driver
.render(Document)
method on Driver
.Driver
can take an InputSource
as input.
+This can use a Stream
, String
etc.XSLTInputHandler
is used as an InputSource
in the render(XMLReader
, InputSource
) method on Driver
.
- Because you have an explicit transformer object, you can also use it to explicitly set parameters for the transformation run.
+ There are a variety of upstream data manipulations possible.
+ For example, you may have a DOM and an XSL stylesheet; or you may want to
+ set variables in the stylesheet. Interface documentation and some cookbook
+ solutions to these situations are provided in
+
+ See the Examples for some variations on input.
To access an external configuration:
- + +
No further reference to the options
variable is necessary.
+ The "options = " is actually not even necessary.
See Multithreading FOP for issues related to changing configuration in a multithreaded environment. @@ -290,6 +247,82 @@ You may also use dynamically generated XSL if you like. See Multithreading FOP for issues related to changing configuration in a multithreaded environment.
+If FOP is going to be used multiple times within your application +it may be useful to reuse certain objects to save time. +
+
+The renderers and the driver can both be reused. A renderer is reusable
+once the previous render has been completed. The driver is reuseable
+after the rendering is complete and the reset()
method is called.
+You will need to setup the driver again with a new OutputStream,
+IntputStream and renderer.
+
+ If your XSL-FO files contain SVG then Batik will be used. When Batik is
+ initialised it uses certain classes in java.awt
that
+ intialises the java AWT classes. This means that a daemon thread
+ is created by the JVM and on Unix it will need to connect to a
+ DISPLAY.
+
+ The thread means that the Java application may not automatically quit
+ when finished, you will need to call System.exit()
. These
+ issues should be fixed in the upcoming JDK 1.4.
+
+ If you run into trouble running FOP on a head-less server, please see the + notes on Batik. +
+
+To get the number of pages that were rendered by FOP you can call
+Driver.getResults()
. This returns a FormattingResults object
+where you can lookup the number of pages produced. It also gives you the
+page-sequences that were produced along with their id attribute and their
+number of pages. This is particularly useful if you render multiple
+documents (each enclosed by a page-sequence) and have to know the number of
+pages of each document.
+
+ There are several options to consider: +
+driver.setOutputStream(new java.io.BufferedOutputStream(out));
+ Templates
object and reuse it each time you do
+ the XSL transformation.
+ @@ -299,44 +332,26 @@ variables for configuration data and loading images. Here are some tips to mitigate these problems:
init()
method of the servlet.
+ init()
method of the servlet.
+ - When using a servlet engine, there are potential CLASSPATH issues, and potential conflicts with existing XML/XSLT libraries. -Servlet containers also often use their own classloaders for loading webapps, which can cause bugs and security problems. -
-- Check Tomcat's documentation for detailed instructions about installing FOP and Cocoon. -There are known bugs that must be addressed, particularly for Tomcat 4.0.3. -
-- Put a copy of a working parser in some directory where WebSphere can access it. -For example, if /usr/webapps/yourapp/servlets is the CLASSPATH for your servlets, copy the Xerces jar into it (any other directory would also be fine). -Do not add the jar to the servlet CLASSPATH, but add it to the CLASSPATH of the application server which contains your web application. -In the WebSphere administration console, click on the "environment" button in the "general" tab. -In the "variable name" box, enter "CLASSPATH". -In the "value" box, enter the correct path to the parser jar file (/usr/webapps/yourapp/servlets/Xerces.jar in our example here). -Press "OK", then apply the change and restart the application server. -
-There is also a known issue with fonts being jumbled between threads when using the AWT renderer (which is used by the -awt and -print output options). +In general, you cannot safely run multiple threads through the AWT renderer.
-The directory "xml-fop/examples/embedding" contains several working examples. +The directory "{fop-fir}/examples/embedding" contains several working examples. In contrast of the examples above the examples here primarily use JAXP for XML access. This may be easier to understand for people familiar with JAXP.
diff --git a/src/documentation/content/xdocs/examples.xml b/src/documentation/content/xdocs/examples.xml index e0e6aed0b..321e563e6 100644 --- a/src/documentation/content/xdocs/examples.xml +++ b/src/documentation/content/xdocs/examples.xml @@ -7,6 +7,11 @@+ These examples have been rendered using FOP: +
fonts.fo.pdf |
Examples for the use of XSL-FO can be found in the FOP distribution in +
Other basic examples on the use of XSL-FO can be found in the FOP distribution in the subdirectory xml-fop/examples/fo. You can start transformation of all fo files into pdf files by starting xml-fop/examples/fo/runtests (only source distribution). The resulting test files can be found in xml-fop/examples/fo/tests @@ -57,18 +59,66 @@
Also, in the directory examples/fo/pagination you will find a suite of examples showing the use + of XSL-FO pagination. +
Developers will find the first steps to a test suite for all implemented formatting objects and properties in xml-fop/test/xml/.
-+Embedding images in FO: +
+description | +fo file | +pdf result | +
---|---|---|
align in larger viewport | +align.fo | +align.fo.pdf | +
align in smaller viewport | +align2.fo | +align2.fo.pdf | +
scaling image | +size.fo | +size.fo.pdf | +
Look also into the directory examples/fo/svg. There you find some very extensive SVG examples. +
++Instream Foreign Object images in FO, there are more on the +SVG Page: +
+description | +fo file | +pdf result | +
---|---|---|
embedding svg in viewport | +embed.fo | +embed.fo.pdf | +
- See also release notes. + Update your FO documents and style sheets.
- This is typically a problem with your classpath.
+This is typically a problem with your classpath.
If you are running FOP from the command line:
- If you run FOP embedded in your servlet, web application or other - Java application, check the classpath of the application. + If you run FOP embedded in your servlet, web application or + other Java application, check the classpath of the + application. Check the also the information pertaining servlet engines + for further hints.
If you use XSLT, problems in your style sheet and in your source XML - also often produce a NullPointerException. Run the transformation + also can produce a NullPointerException. Run the transformation separately to check for this, usually you'll get a detailed error message from the XSLT processor.
@@ -307,22 +309,7 @@- The src attribute of the fo:external-graphics element takes an URI, - not a file name. -
-- Relative URLs are resolved against the baseDir property of FOP. For - the command line FOP application, the baseDir is the directory of the - input file, either the FO file or the XML source. If FOP is used - embedded in a servlet, baseDir can be - set explicitely. If it's not set, it is usually the current - working directory of the process which runs FOP. -
- +The src attribute of the fo:external-graphics element requires a URI, not a file name. See External Resources for more information about specifying URIs.
Did you get: «Failed to read font metrics file C:\foo\arial.xml - : File "C:\foo\arial.xml" not found²? The value for the + : File "C:\foo\arial.xml" not found»? The value for the metrics-file attribute in the user config file is actually an URL, not a file name. Use "file:///C:/foo/arial.xml" instead.
@@ -339,11 +326,51 @@ directory you expect. Currently FOP does not use the baseDir for resolving relative URLs pointing to font metric files. ++ Try also setting the fontBaseDir configuration. (FIXME: add + link to congfiguration page) +
+ Leaders still work, in fact they work better than ever + before. You'll just have to add text-align="justify" and/or + text-align-last="justify" to the block with the leader. Be + sure you haven't accidentally overridden the + leader-length.maximum="100%" default value. +
++ Earlier versions of FOP used to expand a leader to fill the + rest of the line unconditionally, anything following it, + like page numbers in a TOC, was actually shifted beyong the + right margin. +
++ The new implementation uses leader-length.optimum to + determine where to break the line, and expands the leader + only further if the line should be filled, as indicated by + the text-aling and text-align-last properties. +
++ Actually due to the fuzzyness of the specification both the + old and the new method are conformant (although adding text + after the expanded leader in the old variant never was). +
++ If you want to have a longer ruler or space in a + non-justified line, you have to increase the + leader-length.optimum property. +
+- This happens for fo:page-number-citation elements if the citation - occurs before FOP formatted the requested page, usually in TOC or - index pages. + This happens for fo:page-number-citation elements if the + citation occurs before FOP formatted the requested page, + usually in TOC or index pages. It is caused by the problem + that FOP has to guess how much space the yet unknown page + number will occupy, and usually the guesses are somewhat + off.
- It is caused by the problem that FOP has to guess how much space the - yet unknown page number will occupy, and usually the guesses are - somewhat off. You can try to use a non-proportional font like Courier - to remedy this. However, this is likely to look ugly, and wont fix the - problem completely. + The most recent FOP releases should have this problem + fixed. Check whether you can upgrade.
- Set the language attribute somewhere. Check whether you use a language - for which hyphenation is supported. Supported languages can be deduced - from the files in the hyph directory of the FOP source distribution. + Set the language attribute somewhere and explicitly enable hyphenation. + Check whether you use a language for which hyphenation is supported. + Supported languages can be deduced from the files in the {fop-dir}/src/hyph + directory of the FOP source distribution. If you want to use a language + FOP currently doesn't hyphenate, please see the + Configuration page. +
++ Set the language (on fo:page-sequence, fo:block or fo:character): +
+ ++ Enable hyphenation on a block:
+- There are a few fonts supplied with Acrobat Reader. If you use other - fonts, the font must be available on the machine where the PDF is - viewed or it must have been embedded in the PDF file. See - embedding fonts. + This usually means the selected font doesn't have a glyph + for the character. +
++ The standard text fonts supplied with Acrobat Reader have + mostly glyphs for characters from the ISO Latin 1 character + set. For a variety of reasons, even those are not completely + guaranteed to work, for example you can't use the fi + ligature from the standard serif font. Check the overview for the default + PDF fonts.
- Furthermore, if you select a certain font family, the font must - contain glyphs for the desired character. There is an overview available for the - default PDF fonts. For most symbols, it is better to select the symbol - font explicitely, for example in order to get the symbol for the + If you use your own fonts, the font must have a glyph for + the desired character. Furthermore the font must be + available on the machine where the PDF is viewed or it must + have been embedded in the PDF file. See embedding fonts. +
++ For most symbols, it is better to select the symbol font + explicitely, for example in order to get the symbol for the mathematical empty set, write:
@@ -758,31 +807,9 @@ Can I control this?This is a problem of Internet Explorer requesting the content several - times. Some suggestions: + times. Please see the notes on Internet Explorer + for more information.
-.pdf
, like
- http://myserver/servlet/stuff.pdf
. Yes, the servlet can
- be configured to handle this. If the URL has to contain parameters,
- try to have both the base URL as well as the last parameter end in
- .pdf
, if necessary append a dummy parameter, like
- http://myserver/servlet/stuff.pdf?par1=a&par2=b&d=.pdf
. The
- effect may depend on IEx version.
- - See XML Entity Characters. + See Using HTML Character Names.
FOP uses XSL-FO as input.
It is the responsibility of the user to make sure that the XSL-FO submitted to FOP is correct.
-The tutorial items presented here are not comprehensive, but are of the FAQ variety.
+The tutorial items presented here are not comprehensive, but are of the FAQ variety. Another
+good FAQ is
Get the number of the last page as follows:
- +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.
@@ -421,6 +422,28 @@ This document can be used either to validate against the FO standard, or against See the notes near the beginning of the document for instructions on how to use it.+ Pages in landscape format can easily be produced by exchanging the page-height and page-width values of a simple-page-master element. +
+ +Resources needed by an XSL-FO file that are external to it (graphics, for example), are defined in the XSL-FO standard as being of type "uri-specification". This is defined in the standard at
URIs may be either absolute or relative to a base URI. (See FOP: Configuration for information on setting the base URI for a FOP session). Here is an example referencing an external-graphic that is relative to the base URI:
+ +Here is an example referencing an external-graphic that is an absolute URI on a local filesystem:
+ +The information on this page applies primarily to the PDF renderer. The PostScript renderer - also supports custom fonts but doesn't support font embedding, yet. This page does - not apply to the AWT, PCL, MIF and other renderers.
-The AWT renderer relies upon AWT to provide the available fonts. And it's the printer - driver of your operating system that decides if a font is embedded when using the AWT - renderer.
-FOP (building PDF files) normally supports only the base 14 font package defined in the Adobe PDF specification. - That includes the following fonts: Helvetica, Times, Courier, Symbol and ZapfDingbats. -
-Font support in FOP can be extended by the addition of font metric files (written in XML) created from Adobe - Type 1 fonts and TrueType fonts. No other font types (Type 3, etc.) are supported at this time. - More information about font types can be found at - the - Adobe font types. There is also lots more font information - on this Adobe Font Technote. -
-As mentioned above you need an XML file containing font metrics to be able to use an additional font. FOP - contains a tool that can generate such a font metrics file from a PFM file, which normally comes with the font file. -
-Run the class org.apache.fop.fonts.apps.PFMReader to generate the XML file. -
-Windows:
- -Unix:
- -The following table summarizes the font capabilites of the various FOP renderers:
+Renderer | +Base-14 | +AWT/OS | +Custom | +Custom Embedding | +
---|---|---|---|---|
yes | +no | +yes | +yes | +|
PostScript | +yes | +no | +yes | +no | +
PCL | +yes (modified) | +no | +no | +no | +
TXT | +yes (used for layout but not for output) | +no | +yes (used for layout but not for output) | +no | +
AWT | +if available from OS | +yes | +no | +n/a (display only) | +
if available from OS | +yes | +no | +controlled by OS printer driver | +|
RTF | +n/a (font metrics not needed) | +n/a | +n/a | +n/a | +
MIF | +n/a (font metrics not needed) | +n/a | +n/a | +n/a | +
SVG | +if available from OS | +yes | +no | +no | +
XML | +yes | +no | +yes | +n/a | +
- Edit conf/userconfig.xml and add entries for the font - if the fonts section, - ie: -
- -The Adobe PDF Specification specifies a set of 14 fonts that must be available to every PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), Symbol and ZapfDingbats.
Adding TrueType fonts is almost identical to the process of - adding Type 1 fonts. The main difference is in the first - step.
- -As mentioned above you need an XML file containing font - metrics to be able to use an additional font. FOP contains - a tool that can generate such a font metrics file from - your TrueType font file. -
-- Create metrics for the fontfile (we assume the file has - the name cmr10.ttf and exists in c:\myfonts\): -
-It is possible that your question has already been answered but has not yet found its way into the FAQ. -Links to the FOP User mailing list archives are on the Resources page. +Links to the FOP User mailing list archives are on the Mailing List page.
See FOP User Mailing List for details.
Because of licensing issues, the JIMI image library is not included in the FOP distribution. First,
FOP has been compiled with JAI support, but JAI is not included in the FOP distribution. -To use it, simply install JAI. +To use it, install JAI, then copy the jai_core.jar and the jai_codec.jar files to {fop-install-dir}/lib. JAI is much faster than JIMI, but is not available for all platforms. See What platforms are supported? on the JAI FAQ page for more details.
FOP native support for BMP images is limited to the RGB color-space.
+FOP provides support for two output targets:
+ Other output targets can't be supported at the moment because + FOP lacks a PostScript interpreter. +
Not all variants of JPEG are supported, especially those containing unusual color lookup tables and color profiles. If you have trouble with a JPEG image in FOP, try opening it with an image processing program (such as Photoshop or Gimp) and then saving it. Specifying 24-bit color output may also help. +
FOP native support of JPEG does not include all variants, especially those containing unusual color lookup tables and color profiles. +If you have trouble with a JPEG image in FOP, try opening it with an image processing program (such as Photoshop or Gimp) and then saving it. +Specifying 24-bit color output may also help. +For the PDF and PostScript renderers most JPEG images can be passed through without decompression. +User reports indicate that grayscale, RGB, and CMYK color-spaces are all rendered properly.
If using JAI for PNG support, only RGB and RGBA color-spaces are supported for FOP rendering.
+-It is possible to make sure that all text is drawn into PDF using the -PDF text commands (instead of the graphical shapes), by adding the following to the user config: -
-In a servlet environment, you can set it directly:
-For information on using a configuration file in a servlet, see the FAQ on that topic.
-Note that this configuration setting works only for the PDF renderer.
--The drawback to forcing text to be rendered as text is that it will be confined to text that is -possible for PDF fonts (including embedded fonts) and implemented with -this workaround. The fonts available are the standard pdf fonts and any -fonts that you have embedded using FOP. The font sizes will be rounded -to an integer value. In future this will be improved. +For PDF output, there is a configuration option to force SVG text to be rendered as text. +The drawback to this approach is that it is effective only for available fonts (including embedded fonts). +Font sizes are rounded to the next integer point size. +This will be improved in the future.
Note that because SVG text can be rendered as either text or a vector graphic, you may need to consider settings in your viewer for both. The Acrobat viewer has both "smooth line art" and "smooth text" settings that may need to be set for SVG images to be displayed nicely on your screen (see Edit / Preferences / Display). @@ -276,6 +231,16 @@ into a raster graphic are not drawn properly in PDF. The image is opaque.
FOP-native TIFF support is limited to PDF and PostScript output only. Also, according to user reports, FOP's native support for TIFF is limited to images with the following characteristics (all must be true for successful rendering):
+JAI: Supports RGB and RGBA only for FOP rendering.
+Some bitmapped image file formats store a dots-per-inch (dpi) or other resolution value. Since PDF and most output formats do not have a concept of resolution, but only of absolute image units (i.e. pixels) FOP ignores the resolution values as well. Instead, FOP uses the dimensions of the image as specified in the fo:external-graphic element to render the image:
@@ -287,5 +252,20 @@ into a raster graphic are not drawn properly in PDF. The image is opaque.If you need a higher apparent output resolution for bitmapped images, first make sure that at least one dimension of the image is defined in your XSL-FO input. Apart from that, resolution problems are in the image file itself, and must be corrected there: use or create a higher-resolution image file.
+ FOP caches images between runs. The URL is used as a key to identify images which means that when + a particular URL appears again, the image is taken from the cache. If you have a servlet that + generates a different image each time it is called with the same URL you need to use a constantly + changing dummy parameter on the URL to avoid caching. +
+
+ Currently, the images are not automatically released when an OutOfMemoryError is imminent. The
+ image cache can grow to a considerable size over time when a lot of different URLs are in use.
+ Starting with version 0.20.5 you can call org.apache.fop.image.FopImageFactory.resetCache()
+ to manually empty the cache. Image caching will be improved as part of our redesign effort.
+
Welcome Glen Mazza!
++ See the full text of the announcement. +
+@@ -21,10 +32,10 @@
We are looking for a new logo. FOP logo - contest is started!
-We are looking for a new logo. FOP logo + contest is started!
+
diff --git a/src/documentation/content/xdocs/output.xml b/src/documentation/content/xdocs/output.xml
index 3ba4a509a..16296837b 100644
--- a/src/documentation/content/xdocs/output.xml
+++ b/src/documentation/content/xdocs/output.xml
@@ -277,19 +277,15 @@ Adobe Framemaker. This is currently not fully implemented.
-Text as you could imagine does not work very well. It is an output format
-that you should expect bad results. The main purpose of this is to get
-a quick and dirty view of the document and the text inside it.
-
-The TXTRenderer is a FOP renderer that produces plain ASCII text output
+The text renderer produces plain ASCII text output
that attempts to match the output of the PDFRenderer as closely as
possible. This was originally developed to accommodate an archive system
-that could only accept plain text files. Of course when limited to plain
-fixed pitch text the output does not always look very good.
+that could only accept plain text files, and is primarily useful for getting
+a quick-and-dirty view of the document text. The renderer is very limited,
+so do not be surprised if it gives unsatisfactory results.
-The TXTRenderer works with a fixed size page buffer. The size of this
+The Text renderer works with a fixed size page buffer. The size of this
buffer is controlled with the textCPI and textLPI public variables.
The textCPI is the effective horizontal characters per inch to use.
The textLPI is the vertical lines per inch to use. From these values
@@ -298,6 +294,13 @@ The formatting objects to be rendered are then mapped to this grid.
Graphic elements (lines, borders, etc) are assigned a lower priority
than text, so text will overwrite any graphic element representations.
Because FOP lays the text onto a grid during layout, there are frequently extra or missing spaces between characters and lines, which is generally unsatisfactory.
+Users have reported that the optimal settings to avoid such spacing problems are:
+
FOP supports encryption of PDF output, thanks to Patrick - C. Lankswert. This feature is commonly used to prevent unauthorized - viewing, printing, editing and copying text from the document - annotations. It is also possible to ask the user for a password in order - to view the contents. Note that there already exist third party - applications which can decrypt an encrypted PDF without effort and allow - the aforementioned operations, therefore the degree of protection is - limited. + C. Lankswert. This feature is commonly used to prevent + unauthorized viewing, printing, editing, copying text from the + document and doing annotations. It is also possible to ask the + user for a password in order to view the contents. Note that + there already exist third party applications which can decrypt + an encrypted PDF without effort and allow the aforementioned + operations, therefore the degree of protection is limited.
For further information about features and restrictions regarding PDF @@ -29,19 +31,21 @@
Encryption is enabled by supplying any of the encryption related options.
- An owner password with the -o
option. This password is
- actually used as encryption key. Usually it is also used by most tools
- to disregard any restriction imposed on the PDF document.
+ An owner password is set with the -o
option. This
+ password is actually used as encryption key. Many tools for
+ PDF processing ask for this password to disregard any
+ restriction imposed on the PDF document.
If no owner password has been supplied but FOP was asked to apply some - restrictions, a random password is used. + restrictions, a random password is used. In this case it is obviously + impossiible to disregard restrictions in PDF processing tools.
A user password, supplied with the -u
option, will
@@ -56,16 +60,83 @@
text, editing in Adobe Acrobat and making annotations, respectively.
+ When FOP is embedded in another Java application you need to set an + options map on the renderer. These are the supported options: +
+Option | +Description | +Values | +Default | +
---|---|---|---|
ownerPassword | +The owner password | +String | ++ |
userPassword | +The user password | +String | ++ |
allowPrint | +Allows/disallows printing of the PDF | +"TRUE" or "FALSE" | +"TRUE" | +
allowCopyContent | +Allows/disallows copy/paste of content | +"TRUE" or "FALSE" | +"TRUE" | +
allowEditContent | +Allows/disallows editing of content | +"TRUE" or "FALSE" | +"TRUE" | +
allowEditAnnotations | +Allows/disallows editing of annotations | +"TRUE" or "FALSE" | +"TRUE" | +
+ An example to enable PDF encryption in Java code: +
+- In order to use PDF encryption, FOP has to be compiled with cryptography - support. Currently, only JCE - is supported. JCE is part of JDK 1.4. For earlier JDKs, it can be - installed separately. The build process automatically senses JCE - presence and installs PDF support if possible, otherwise, a stub is - compiled in. + is supported. JCE is part of JDK 1.4. For earlier JDKs, it can + be installed separately. The build process automatically + detects JCE presence and installs PDF encryption support if + possible, otherwise a stub is compiled in.
Cryptography support must also be present at run time. In particular, a @@ -75,7 +146,7 @@
- then you don't have the needed support. + then you don't have the needed infrastructure.
There are several commercial and a few Open Source packages which @@ -112,6 +183,10 @@ providers. For JDK 1.4 this is detailed on Sun's web site. +
+ If you have any experience with Mozilla JSS or any other + cryptography provider, please post it to the fop-user list. +