Return-Path: X-Original-To: apmail-xmlgraphics-commits-archive@www.apache.org Delivered-To: apmail-xmlgraphics-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C1B73D27F for ; Wed, 24 Oct 2012 04:10:10 +0000 (UTC) Received: (qmail 79742 invoked by uid 500); 24 Oct 2012 04:10:10 -0000 Mailing-List: contact commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@xmlgraphics.apache.org Delivered-To: mailing list commits@xmlgraphics.apache.org Received: (qmail 79726 invoked by uid 99); 24 Oct 2012 04:10:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2012 04:10:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2012 04:10:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 459252388A29 for ; Wed, 24 Oct 2012 04:09:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r835962 [3/14] - in /websites/staging/xmlgraphics/trunk/content: ./ batik/ commons/ fop/ fop/0.95/ fop/1.0/ fop/1.1/ fop/dev/ fop/dev/design/ fop/trunk/ Date: Wed, 24 Oct 2012 04:09:13 -0000 To: commits@xmlgraphics.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121024040922.459252388A29@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/0.95/servlets.html Wed Oct 24 04:09:09 2012 @@ -330,11 +330,11 @@ $(document).ready(function () {
-

Apache(tm) FOP: Servlets

+

Apache™ FOP: Servlets

How to use Apache� FOP in a Servlet$Revision: 1298724 $

-

Overview

+

Overview

This page discusses topic all around using Apache™ FOP in a servlet environment.

-

Example Servlets in the FOP distribution

+

Example Servlets in the FOP distribution

In the directory {fop-dir}/src/java/org/apache/fop/servlet, you'll find a working example of a FOP-enabled servlet.

The servlet is automatically built when you build Apache FOP using the supplied Ant script. After building the servlet, drop fop.war into the webapps directory of Apache Tomcat (or any other web container). Then, you can use URLs like the following to generate PDF files:

    @@ -347,9 +347,9 @@ $(document).ready(function () {

The source code for the servlet can be found under {fop-dir}/src/java/org/apache/fop/servlet/FopServlet.java. This example servlet should not be used on a public web server connected to the Internet as it does not contain any measures to prevent Denial-of-Service-Attacks. It is provided as an example and as a starting point for your own servlet.

-

Create your own Servlet

+

Create your own Servlet

This section assumes you are familiar with embedding FOP .

-

A minimal Servlet #

+

A minimal Servlet #

Here is a minimal code snippet to demonstrate the basics: private FopFactory fopFactory = FopFactory.newInstance(); private TransformerFactory tFactory = TransformerFactory.newInstance();

@@ -366,7 +366,7 @@ private TransformerFactory tFactory = Tr throw new ServletException(ex); } }There are numerous problems with the code snippet above. Its purpose is only to demonstrate the basic concepts. See below for details.

-

Adding XSL tranformation (XSLT) #

+

Adding XSL tranformation (XSLT) #

A common requirement is to transform an XML source to XSL-FO using an XSL transformation. It is recommended to use JAXP for this task. The following snippet shows the basic code: private FopFactory fopFactory = FopFactory.newInstance(); private TransformerFactory tFactory = TransformerFactory.newInstance();

@@ -406,9 +406,9 @@ private TransformerFactory tFactory = Tr

The Source instance used above is simply an example. 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.

Because you have an explicit Transformer object, you can also use it to explicitely set parameters for the transformation run.

-

Custom configuration #

+

Custom configuration #

You can easily set up your own FOUserAgent as demonstrated on the Embedding page .

-

Improving performance #

+

Improving performance #

There are several options to consider:

  • @@ -419,7 +419,7 @@ private TransformerFactory tFactory = Tr

Of course, the performance hints from the Embedding page apply here, too.

-

Accessing resources in your web application #

+

Accessing resources in your web application #

Often, you will want to use resources (stylesheets, images etc.) which are bundled with your web application. FOP provides a URIResolver implementation that lets you access files via the Servlet's ServletContext. The class is called org.apache.fop.servlet.ServletContextURIResolver .

Here's how to set it up in your servlet. Instantiate a new instance in the servlet's init() method:

/** URIResolver for use by this servlet */
@@ -459,7 +459,7 @@ Source xsltSrc = this.uriResolver.resolv
     "servlet-context:/xslt/mystylesheet.xsl", null);
 Transformer transformer = this.transFactory.newTransformer(xsltSrc);
 transformer.setURIResolver(this.uriResolver);

-

Notes on Microsoft Internet Explorer

+

Notes on Microsoft Internet Explorer

Some versions of Internet Explorer will not automatically show the PDF or call the servlet multiple times. These are well-known limitations of Internet Explorer and are not a problem of the servlet. However, Internet Explorer can still be used to download the PDF so that it can be viewed later. Here are some suggestions in this context:

  • @@ -474,13 +474,13 @@ transformer.setURIResolver(this.uriResol

    Cache in the server. It may help to include a parameter in the URL which has a timestamp as the value min order to decide whether a request is repeated. IEx is reported to retrieve a document up to three times, but never more often.

-

Servlet Engines

+

Servlet Engines

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.

-

Tomcat #

+

Tomcat #

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.

-

WebSphere 3.5 #

+

WebSphere 3.5 #

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.

-

Handling complex use cases

+

Handling complex use cases

Sometimes the requirements for a servlet get quite sophisticated: SQL data sources, multiple XSL transformations, merging of several datasources etc. In such a case consider using Apache Cocoon instead of a custom servlet to accomplish your goal.

Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/accessibility.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/accessibility.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/accessibility.html Wed Oct 24 04:09:09 2012 @@ -330,11 +330,11 @@ $(document).ready(function () {
-

Apache(tm) FOP: Accessibility

-

Overview

+

Apache™ FOP: Accessibility

+

Overview

This page describes the accessibility features of Apache™ FOP. Section 508 defines accessibility in the context of electronic documents for the USA but other countries have similar requirements.

Accessibility features are available only for the PDF output format and there are some implementation limitations. Also, certain actions must be undertaken by the content creator to ensure that FOP can create a truly accessible document.

-

Enabling accessibility

+

Enabling accessibility

There are 3 ways to enable accessibility:

  1. @@ -352,7 +352,7 @@ $(document).ready(function () {

When accessibility is enabled, additional information relating to the logical structure of the document is added to the PDF. That information allows the PDF viewer (or a text-to-speech application) to retrieve the natural reading order of the document. The processing of the logical structure is memory-hungry. You may need to adjust the Java heap size in order to process larger files.

-

Changes to your XSL-FO input files

+

Changes to your XSL-FO input files

Apache FOP cannot automatically generate accessible PDFs. Some of the work can only be performed by the content provider. Following are some changes that may be necessary to your XSL-FO content in order to generate really accessible documents:

  • @@ -368,7 +368,7 @@ The processing of the logical structure

    Specify the natural language of the document using the language and country properties (or via the xml:lang shorthand property).

-

Customized Tagging

+

Customized Tagging

The PDF Reference defines a set of standard Structure Types to tag content. For example, ‘P’ is used for identifying paragraphs, ‘H1’ to ‘H6’ for headers, ‘L’ for lists, ‘Div’ for block-level groups of elements, etc. This standard set is aimed at improving interoperability between applications producing or consuming PDF.

FOP provides a default mapping of Formatting Objects to elements from that standard set. For example, fo:page-sequence is mapped to ‘Part’, fo:block is mapped to ‘P’, fo:list-block to ‘L’, etc.

You may want to customize that mapping to improve the accuracy of the tagging or deal with particular FO constructs. For example, you may want to make use of the ‘H1’ to ‘H6’ tags to make the hierarchical structure of the document appear in the PDF. This is achieved by using the role XSL-FO property: @@ -377,9 +377,9 @@ The processing of the logical structure This is the first paragraph of the first section... ... If a non-standard structure type is specified, FOP will issue a warning and fall back to the default tag associated to the Formatting Object.

-

Testing

+

Testing

Accessible PDFs can be tested, for example, using Adobe Acrobat Professional. Its Accessibility Check feature creates a report indicating any deficiencies with a PDF document. Alternatively, you can just let a screen reader read the document aloud.

-

Limitations

+

Limitations

Accessibility support in Apache FOP is relatively new, so there are certain limitations. Please help us identify and close any gaps.

  • @@ -395,7 +395,7 @@ If a non-standard structure type is spec

    The side regions (region-before, region-after etc.) are currently not specially identified. Screen readers may read their content at page changes.

- +

Many resources providing guidance about creating accessible documents can be found on the web. Here are a few links, along with additional resources around the topic:

  • Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/anttask.html Wed Oct 24 04:09:09 2012 @@ -330,10 +330,10 @@ $(document).ready(function () {
    -

    Apache(tm) FOP: Ant task

    +

    Apache™ FOP: Ant task

    $Revision: 1298724 $

    Apache™ FOP provides an Ant task for automating the document build process.

    -

    Description

    +

    Description

    The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output (see Output formats for available formats).

    To call FOP tasks within Ant, first add a FOP task definition to your Ant build file. One method of defining the task is as follows:

    Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/compiling.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/compiling.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/compiling.html Wed Oct 24 04:09:09 2012 @@ -330,21 +330,21 @@ $(document).ready(function () {
    -

    Apache(tm) FOP: Building from Source Code

    +

    Apache™ FOP: Building from Source Code

    $Revision: 1298724 $

    -

    Do You Need To Build?

    +

    Do You Need To Build?

    Apache™ 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.

    If you got the source code from a repository snapshot or via Subversion you will need to build FOP in any case.

    -

    Set Up Your Environment

    -

    JDK #

    +

    Set Up Your Environment

    +

    JDK #

    Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.4 (A Java Runtime Environment is not sufficient).

    -

    CLASSPATH #

    +

    CLASSPATH #

    There is 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 script build.xml for details.

    -

    JAVA_HOME #

    +

    JAVA_HOME #

    The build script uses Apache Ant , a popular Java-based build tool, which usually requires that the environment variable JAVA_HOME point to your local JDK root directory. This is true even if you use JDK 1.4 or above, which normally does not need this setting.

    -

    Apache Ant #

    +

    Apache Ant #

    Apache Ant (Version 1.7 or later) must be installed in order to build FOP. Following best practices we don't include Ant with FOP anymore. You can find the instructions to install Ant in the Ant manual on the web.

    -

    Run the Build Script

    +

    Run the Build Script

    Change to the FOP root directory and build FOP by executing the build script (build.xml) using the "ant" command. The "ant" command is only available on your system if you've properly installed Apache Ant and added Ant's location to the PATH environment variable. The file build.xml in the FOP root directory is the blueprint that Ant uses for the build. It contains information for numerous build targets, many of which are building blocks to more useful target, and others which are primarily used by the FOP developers. You may benefit from looking through this file to learn more about the various build targets. To obtain a complete list of useful build targets: @@ -369,7 +369,7 @@ OR ant all To clean the build directory first: ant clean allIf you want to shorten the build time you can just call the "package" target which doesn't perform any automated tests during the build.

    -

    Troubleshooting

    +

    Troubleshooting

    If you have problems building FOP, please try the following:

    • Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/configuration.html Wed Oct 24 04:09:09 2012 @@ -330,12 +330,12 @@ $(document).ready(function () {
      -

      Apache(tm) FOP: Configuration

      +

      Apache™ FOP: Configuration

      $Revision: 1298724 $

      -

      Configuration File Basics

      +

      Configuration File Basics

      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 {fop-dir}/conf/fop.xconf 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.

      -

      Making Configuration Available to FOP #

      +

      Making Configuration Available to FOP #

      After creating your configuration file, you must tell FOP how to find it:

      • @@ -346,7 +346,7 @@ $(document).ready(function () {

      See Setting the Configuration Programmatically for instructions on how to do so in an embedded environment.

      -

      Summary of the General Configuration Options

      +

      Summary of the General Configuration Options

      @@ -456,12 +456,12 @@ $(document).ready(function () {

      -

      Image Loading Customization

      +

      Image Loading Customization

      Apache FOP uses the image loading framework from Apache XML Graphics Commons to load images using various plug-ins. Every image loader plug-in has a hard-coded usage penalty that influences which solution is chosen if there are multiple possibilities to load an image. Sometimes, though, these penalties need to be tweaked and this can be done in the FOP configuration. An example:

      The second penalty element sets an "infinite" penalty for the TIFF loader using the internal TIFF codec. This practically disables that plug-in as it will never be chosen as a possible solution.

      Negative penalties are possible to promote a plug-in but a negative penalty sum will be treated as zero penalty in most cases. For more details on the image loading framework, please consult the documentation there.

      -

      Renderer configuration

      +

      Renderer configuration

      Each Renderer has its own configuration section which is identified by the MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer.

      The configuration for the PDF Renderer could look like this:

      @@ -487,7 +487,7 @@ $(document).ready(function () {

      The details on the font configuration can be found on the separate Fonts page. Note especially the section entitled Register Fonts with FOP .

      -

      Special Settings for the PDF Renderer #

      +

      Special Settings for the PDF Renderer #

      The configuration element for the PDF renderer contains two elements. One is for the font configuration (please follow the link above) and one is for the "filter list". The filter list controls how the individual objects in a PDF file are encoded. By default, all objects get "flate" encoded (i.e. simply compressed with the same algorithm that is also used in ZIP files). Most users don't need to change that setting. For debugging purposes, it may be desired not to compress the internal objects at all so the generated PDF commands can be read. In that case, you can simply use the following filter list. The second filter list (type="image") ensures that all images still get compressed but also ASCII-85 encoded so the produced PDF file is still easily readable in a text editor.

      <renderer mime="application/pdf">
         <filterList>
      @@ -539,7 +539,7 @@ $(document).ready(function () {
       
      -

      Special Settings for the PostScript Renderer #

      +

      Special Settings for the PostScript Renderer #

      Besides the normal font configuration (the same "fonts" element as for the PDF renderer) the PostScript renderer has an additional setting to force landscape pages to be rotated to fit on a page inserted into the printer in portrait mode. Set the value to "true" to activate this feature. The default is "false". Example:

      <renderer mime="application/postscript">
         <auto-rotate-landscape>true</auto-rotate-landscape>
      @@ -558,7 +558,7 @@ $(document).ready(function () {
       
      -

      Special Settings for the PCL Renderer #

      +

      Special Settings for the PCL Renderer #

      Non-standard fonts for the PCL renderer are made available through the Java2D subsystem which means that you don't have to do any custom font configuration in this case but you have to use the font names offered by Java.

      Additionally, there are certain settings that control how the renderer handles various elements. @@ -567,7 +567,7 @@ $(document).ready(function () { The default value for the "rendering" setting is "speed" which causes borders to be painted as plain rectangles. In this mode, no special borders (dotted, dashed etc.) are available. If you want support for all border modes, set the value to "quality" as indicated above. This will cause the borders to be painted as bitmaps.

      The default value for the "text-rendering" setting is "auto" which paints the base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D. If the mix of painting methods results in unwelcome output, you can set this to "bitmap" which causes all text to be rendered as bitmaps.

      -

      Special Settings for the AFP Renderer #

      +

      Special Settings for the AFP Renderer #

      Additionally, there are certain settings that control how the renderer handles various elements. @@ -578,7 +578,7 @@ The default value for the "rendering" se The default value for the images "mode" setting is "b+w" (black and white). When the images "mode" setting is "b+w" a "bits-per-pixel" setting can be provided to aid the grayscale conversion process. With this setting all images referenced in your source document are converted to an IOCA FS45 grayscale bitmap image form. When the setting is "color" all images are converted to an IOCA FS45 color bitmap image form. When "native" setting is "true", all images encountered (TIFF, GIF, JPEG and Encapsulated Postscript etc.) will be embedded directly in the datastream in their native form using a MO:DCA Object Container.

      The default value for the "renderer-resolution" is 240 dpi.

      By default if there is no configuration definition for "resource-group-file", external resources will be placed in a file called resources.afp.

      -

      When it does not work

      +

      When it does not work

      FOP searches the configuration file for the information it expects, at the position it expects. When that information is not present, FOP will not complain, it will just continue. When there is other information in the file, FOP will not complain, it will just ignore it. That means that when your configuration information is in the file but in a different XML element, or in a different XML path, than FOP expects, it will be silently ignored.

      Check the following possibilities:

        Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/embedding.html Wed Oct 24 04:09:09 2012 @@ -330,13 +330,13 @@ $(document).ready(function () {
        -

        Apache(tm) FOP: Embedding

        +

        Apache™ FOP: Embedding

        How to Embed Apache� FOP in a Java application$Revision: 1298724 $

        -

        Overview

        +

        Overview

        Review Running FOP for important information that applies to embedded applications as well as command-line use, such as options and performance.

        To embed Apache™ FOP in your application, first create a new org.apache.fop.apps.FopFactory instance. This object can be used to launch multiple rendering runs. For each run, create a new org.apache.fop.apps.Fop instance through one of the factory methods of FopFactory. In the method call you specify which output format (i.e. Renderer) to use and, if the selected renderer requires an OutputStream, which OutputStream to use for the results of the rendering. You can customize FOP's behaviour in a rendering run by supplying your own FOUserAgent instance. The FOUserAgent can, for example, be used to set your own Renderer instance (details below). Finally, you retrieve a SAX DefaultHandler instance from the Fop object and use that as the SAXResult of your transformation. We recently changed FOP's outer API to what we consider the final API. This might require some changes in your application. The main reasons for these changes were performance improvements due to better reuse of reusable objects and reduced use of static variables for added flexibility in complex environments.

        -

        Basic Usage Pattern

        +

        Basic Usage Pattern

        Apache FOP relies heavily on JAXP. It uses SAX events exclusively to receive the XSL-FO input document. It is therefore a good idea that you know a few things about JAXP (which is a good skill anyway). Let's look at the basic usage pattern for FOP...

        Here is the basic pattern to render an XSL-FO file to PDF:

        import org.apache.fop.apps.FopFactory; @@ -389,7 +389,7 @@ Let's discuss these 5 steps in detail:

        If you're not totally familiar with JAXP Transformers, please have a look at the Embedding examples below. The section contains examples for all sorts of use cases. If you look at all of them in turn you should be able to see the patterns in use and the flexibility this approach offers without adding too much complexity.

        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. An example for that can be found in the Embedding examples (See "ExampleXML2FO").

        -

        Logging #

        +

        Logging #

        Logging is now a little different than it was in FOP 0.20.5. We've switched from Avalon Logging to Jakarta Commons Logging . While with Avalon Logging the loggers were directly given to FOP, FOP now retrieves its logger(s) through a statically available LogFactory. This is similar to the general pattern that you use when you work with Apache Log4J directly, for example. We call this "static logging" (Commons Logging, Log4J) as opposed to "instance logging" (Avalon Logging). This has a consequence: You can't give FOP a logger for each processing run anymore. The log output of multiple, simultaneously running FOP instances is sent to the same logger.

        By default, Jakarta Commons Logging uses JDK logging (available in JDKs 1.4 or higher) as its backend. You can configure Commons Logging to use an alternative backend, for example Log4J. Please consult the documentation for Jakarta Commons Logging on how to configure alternative backends.

        As a result of the above we differentiate between two kinds of "logging":

        @@ -402,16 +402,16 @@ Let's discuss these 5 steps in detail:

      The use of "feedback" instead of "logging" is intentional. Most people were using log output as a means to get feedback from events within FOP. Therefore, FOP now includes an event package which can be used to receive feedback from the layout engine and other components within FOP per rendering run . This feedback is not just some text but event objects with parameters so these events can be interpreted by code. Of course, there is a facility to turn these events into normal human-readable messages. For details, please read on on the Events page . This leaves normal logging to be mostly a thing used by the FOP developers although anyone can surely activate certain logging categories but the feedback from the loggers won't be separated by processing runs. If this is required, the Events subsystem is the right approach.

      -

      Processing XSL-FO #

      +

      Processing XSL-FO #

      Once the Fop instance is set up, call getDefaultHandler() to obtain a SAX DefaultHandler instance to which you can send the SAX events making up the XSL-FO document you'd like to render. FOP processing starts as soon as the DefaultHandler's startDocument() method is called. Processing stops again when the DefaultHandler's endDocument() method is called. Please refer to the basic usage pattern shown above to render a simple XSL-FO document.

      -

      Processing XSL-FO generated from XML+XSLT #

      +

      Processing XSL-FO generated from XML+XSLT #

      If you want to process XSL-FO generated from XML using XSLT we recommend again using standard JAXP to do the XSLT part and piping the generated SAX events directly through to FOP. The only thing you'd change to do that on the basic usage pattern above is to set up the Transformer differently:

      //without XSLT: //Transformer transformer = factory.newTransformer(); // identity transformer

      //with XSLT: Source xslt = new StreamSource(new File("mystylesheet.xsl")); Transformer transformer = factory.newTransformer(xslt);

      -

      Input Sources

      +

      Input Sources

      The input XSL-FO document is always received by FOP as a SAX stream (see the Parsing Design Document for the rationale).

      However, you may not always have your input document available as a SAX stream. But with JAXP it's easy to convert different input sources to a SAX stream so you can pipe it into FOP. That sounds more difficult than it is. You simply have to set up the right Source instance as input for the JAXP transformation. A few examples:

        @@ -438,9 +438,9 @@ Let's discuss these 5 steps in detail:

      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 Xalan Basic Usage Patterns .

      -

      Configuring Apache FOP Programmatically

      +

      Configuring Apache FOP Programmatically

      Apache FOP provides two levels on which you can customize FOP's behaviour: the FopFactory and the user agent.

      -

      Customizing the FopFactory #

      +

      Customizing the FopFactory #

      The FopFactory holds configuration data and references to objects which are reusable over multiple rendering runs. It's important to instantiate it only once (except in special environments) and reuse it every time to create new FOUserAgent and Fop instances.

      You can set all sorts of things on the FopFactory:

        @@ -473,7 +473,7 @@ fopFactory.addElementMapping(myElementMa fopFactory.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolverBoth the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FopFactory is primarily used to resolve URIs on factory-level (hyphenation patterns, for example) and it is always used if no other URIResolver (for example on the FOUserAgent) resolved the URI first.

      -

      Customizing the User Agent #

      +

      Customizing the User Agent #

      The user agent is the entity that allows you to interact with a single rendering run, i.e. the processing of a single document. If you wish to customize the user agent's behaviour, the first step is to create your own instance of FOUserAgent using the appropriate factory method on FopFactory and pass that to the factory method that will create a new Fop instance:

      FopFactory fopFactory = FopFactory.newInstance(); // Reuse the FopFactory if possible! // do the following for each new rendering run @@ -528,7 +528,7 @@ userAgent.setURIResolver(myResolver); // You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially in multi-threaded environment, this is a bad idea.

      -

      Using a Configuration File

      +

      Using a Configuration File

      Instead of setting the parameters manually in code as shown above you can also set many values from an XML configuration file:

      import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;

      @@ -539,16 +539,16 @@ fopFactory.setUserConfig(cfg);

      / ..or.. /

      fopFactory.setUserConfig(new File("C:/Temp/mycfg.xml")); The layout of the configuration file is described on the Configuration page .

      -

      Hints

      -

      Object reuse #

      +

      Hints

      +

      Object reuse #

      Fop instances shouldn't (and can't) be reused. Please recreate Fop and FOUserAgent instances for each rendering run using the FopFactory. This is a cheap operation as all reusable information is held in the FopFactory. That's why it's so important to reuse the FopFactory instance.

      -

      AWT issues #

      +

      AWT issues #

      If your XSL-FO files contain SVG then Apache Batik will be used. When Batik is initialised it uses certain classes in java.awt that intialise 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 JDK 1.4.

      If you run into trouble running FOP on a head-less server, please see the notes on Batik .

      -

      Getting information on the rendering process #

      +

      Getting information on the rendering process #

      To get the number of pages that were rendered by FOP you can call Fop.getResults() . This returns a FormattingResults object where you can look up the number of pages produced. It also gives you the page-sequences that were produced along with their id attribute and their numbers 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.

      -

      Improving performance

      +

      Improving performance

      There are several options to consider:

      • @@ -570,35 +570,35 @@ The layout of the configuration file is

        You may also wish to consider trying to reduce memory usage .

      -

      Multithreading FOP

      +

      Multithreading FOP

      Apache FOP may currently not be completely thread safe. The code has not been fully tested for multi-threading issues, yet. If you encounter any suspicious behaviour, please notify us.

      There is also a known issue with fonts being jumbled between threads when using the Java2D/AWT renderer (which is used by the -awt and -print output options). In general, you cannot safely run multiple threads through the AWT renderer.

      -

      Examples

      +

      Examples

      The directory "{fop-dir}/examples/embedding" contains several working examples.

      -

      ExampleFO2PDF.java #

      +

      ExampleFO2PDF.java #

      This example demonstrates the basic usage pattern to transform an XSL-FO file to PDF using FOP.

      -

      ExampleXML2FO.java #

      +

      ExampleXML2FO.java #

      This example has nothing to do with FOP. It is there to show you how an XML file can be converted to XSL-FO using XSLT. The JAXP API is used to do the transformation. Make sure you've got a JAXP-compliant XSLT processor in your classpath (ex. Xalan ).

      -

      ExampleXML2PDF.java #

      +

      ExampleXML2PDF.java #

      This example demonstrates how you can convert an arbitrary XML file to PDF using XSLT and XSL-FO/FOP. It is a combination of the first two examples above. The example uses JAXP to transform the XML file to XSL-FO and FOP to transform the XSL-FO to PDF.

      The output (XSL-FO) from the XSL transformation is piped through to FOP using SAX events. This is the most efficient way to do this because the intermediate result doesn't have to be saved somewhere. Often, novice users save the intermediate result in a file, a byte array or a DOM tree. We strongly discourage you to do this if it isn't absolutely necessary. The performance is significantly higher with SAX.

      -

      ExampleObj2XML.java #

      +

      ExampleObj2XML.java #

      This example is a preparatory example for the next one. It's an example that shows how an arbitrary Java object can be converted to XML. It's an often needed task to do this. Often people create a DOM tree from a Java object and use that. This is pretty straightforward. The example here, however, shows how to do this using SAX, which will probably be faster and not even more complicated once you know how this works.

      For this example we've created two classes: ProjectTeam and ProjectMember (found in xml-fop/examples/embedding/java/embedding/model). They represent the same data structure found in xml-fop/examples/embedding/xml/xml/projectteam.xml. We want to serialize to XML a project team with several members which exist as Java objects. Therefore we created the two classes: ProjectTeamInputSource and ProjectTeamXMLReader (in the same place as ProjectTeam above).

      The XMLReader implementation (regard it as a special kind of XML parser) is responsible for creating SAX events from the Java object. The InputSource class is only used to hold the ProjectTeam object to be used.

      Have a look at the source of ExampleObj2XML.java to find out how this is used. For more detailed information see other resources on JAXP (ex. An older JAXP tutorial ).

      -

      ExampleObj2PDF.java #

      +

      ExampleObj2PDF.java #

      This example combines the previous and the third to demonstrate how you can transform a Java object to a PDF directly in one smooth run by generating SAX events from the Java object that get fed to an XSL transformation. The result of the transformation is then converted to PDF using FOP as before.

      -

      ExampleDOM2PDF.java #

      +

      ExampleDOM2PDF.java #

      This example has FOP use a DOMSource instead of a StreamSource in order to use a DOM tree as input for an XSL transformation.

      -

      ExampleSVG2PDF.java (PDF Transcoder example) #

      +

      ExampleSVG2PDF.java (PDF Transcoder example) #

      This example shows the usage of the PDF Transcoder, a sub-application within FOP. It is used to generate a PDF document from an SVG file.

      -

      Final notes #

      +

      Final notes #

      These examples should give you an idea of what's possible. It should be easy to adjust these examples to your needs. Also, if you have other examples that you think should be added here, please let us know via either the fop-users or fop-dev mailing lists. Finally, for more help please send your questions to the fop-users mailing list.

      Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/events.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/events.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/events.html Wed Oct 24 04:09:09 2012 @@ -330,13 +330,13 @@ $(document).ready(function () {
      -

      Apache(tm) FOP: Events/Processing Feedback

      +

      Apache™ FOP: Events/Processing Feedback

      $Revision: 1298724 $

      -

      Introduction

      +

      Introduction

      In versions until 0.20.5, Apache™ FOP used Avalon-style Logging where it was possible to supply a logger per processing run. During the redesign the logging infrastructure was switched over to Commons Logging which is (like Log4J or java.util.logging) a "static" logging framework (the logger is accessed through static variables). This made it very difficult in a multi-threaded system to retrieve information for a single processing run.

      With FOP's event subsystem, we'd like to close this gap again and even go further. The first point is to realize that we have two kinds of "logging". Firstly, we have the logging infrastructure for the (FOP) developer who needs to be able to enable finer log messages for certain parts of FOP to track down a certain problem. Secondly, we have the user who would like to be informed about missing images, overflowing lines or substituted fonts. These messages (or events) are targeted at less technical people and may ideally be localized (translated). Furthermore, tool and solution builders would like to integrate FOP into their own solutions. For example, an FO editor should be able to point the user to the right place where a particular problem occurred while developing a document template. Finally, some integrators would like to abort processing if a resource (an image or a font) has not been found, while others would simply continue. The event system allows to react on the se events.

      On this page, we won't discuss logging as such. We will show how the event subsystem can be used for various tasks. We'll first look at the event subsystem from the consumer side. Finally, the production of events inside FOP will be discussed (this is mostly interesting for FOP developers only).

      -

      The consumer side

      +

      The consumer side

      The event subsystem is located in the org.apache.fop.events package and its base is the Event class. An instance is created for each event and is sent to a set of EventListener instances by the EventBroadcaster . An Event contains:

      • @@ -354,7 +354,7 @@ $(document).ready(function () {

      The EventFormatter class can be used to translate the events into human-readable, localized messages.

      A full example of what is shown here can be found in the examples/embedding/java/embedding/events directory in the FOP distribution. The example can also be accessed via the web .

      -

      Writing an EventListener #

      +

      Writing an EventListener #

      The following code sample shows a very simple EventListener. It basically just sends all events to System.out (stdout) or System.err (stderr) depending on the event severity. import org.apache.fop.events.Event; import org.apache.fop.events.EventFormatter; @@ -385,12 +385,12 @@ public class SysOutEventListener impleme You can see that for every event the method processEvent of the EventListener will be called. Inside this method you can do whatever processing you would like including throwing a RuntimeException , if you want to abort the current processing run.

      The code above also shows how you can turn an event into a human-readable, localized message that can be presented to a user. The EventFormatter class does this for you. It provides additional methods if you'd like to explicitly specify the locale.

      It is possible to gather all events for a whole processing run so they can be evaluated afterwards. However, care should be taken about memory consumption since the events provide references to objects inside FOP which may themselves have references to other objects. So holding on to these objects may mean that whole object trees cannot be released!

      -

      Adding an EventListener #

      +

      Adding an EventListener #

      To register the event listener with FOP, get the EventBroadcaster which is associated with the user agent ( FOUserAgent ) and add it there: FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener()); Please note that this is done separately for each processing run, i.e. for each new user agent.

      -

      An additional listener example #

      +

      An additional listener example #

      Here's an additional example of an event listener:

      By default, FOP continues processing even if an image wasn't found. If you have more strict requirements and want FOP to stop if an image is not available, you can do something like the following in the simplest case: public class MyEventListener implements EventListener {

      @@ -426,10 +426,10 @@ public class MyEventListener implements

      } This throws a RuntimeException with the FileNotFoundException as the cause. Further processing effectively stops in FOP. You can catch the exception in your code and react as you see necessary.

      -

      The producer side (for FOP developers)

      +

      The producer side (for FOP developers)

      This section is primarily for FOP and FOP plug-in developers. It describes how to use the event subsystem for producing events. The event package has been designed in order to be theoretically useful for use cases outside FOP. If you think this is interesting independently from FOP, please talk to us .

      -

      Producing and sending an event #

      +

      Producing and sending an event #

      The basics are very simple. Just instantiate an Event object and fill it with the necessary parameters. Then pass it to the EventBroadcaster which distributes the events to the interested listeneners. Here's a code example: Event ev = new Event(this, "complain", EventSeverity.WARN, Event.paramsBuilder() @@ -439,7 +439,7 @@ Event ev = new Event(this, "complain", E EventBroadcaster broadcaster = [get it from somewhere]; broadcaster.broadcastEvent(ev);

      The Event.paramsBuilder() is a fluent interface to help with the build-up of the parameters. You could just as well instantiate a Map ( Map<String, Object> ) and fill it with values.

      -

      The EventProducer interface #

      +

      The EventProducer interface #

      To simplify event production, the event subsystem provides the EventProducer interface. You can create interfaces which extend EventProducer . These interfaces will contain one method per event to be generated. By contract, each event method must have as its first parameter a parameter named "source" (Type Object) which indicates the object that generated the event. After that come an arbitrary number of parameters of any type as needed by the event.

      The event producer interface does not need to have any implementation. The implementation is produced at runtime by a dynamic proxy created by DefaultEventBroadcaster . The dynamic proxy creates Event instances for each method call against the event producer interface. Each parameter (except "source") is added to the event's parameter map.

      To simplify the code needed to get an instance of the event producer interface it is suggested to create a public inner provider class inside the interface.

      @@ -468,13 +468,13 @@ To produce the same event as in the firs EventBroadcaster broadcaster = [get it from somewhere]; TestEventProducer producer = TestEventProducer.Provider.get(broadcaster); producer.complain(this, "I'm tired", 23);

      -

      The event model #

      +

      The event model #

      Inside an invocation handler for a dynamic proxy, there's no information about the names of each parameter. The JVM doesn't provide it. The only thing you know is the interface and method name. In order to properly fill the Event 's parameter map we need to know the parameter names. These are retrieved from an event object model. This is found in the org.apache.fop.events.model package. The data for the object model is retrieved from an XML representation of the event model that is loaded as a resource. The XML representation is generated using an Ant task at build time ( ant resourcegen ). The Ant task (found in src/codegen/java/org/apache/fop/tools/EventProducerCollectorTask.java ) scans FOP's sources for descendants of the EventProducer interface and uses QDox to parse these interfaces.

      The event model XML files are generated during build by the Ant task mentioned above when running the "resourcegen" task. So just run "ant resourcegen" if you receive a MissingResourceException at runtime indicating that "event-model.xml" is missing.

      Primarily, the QDox-based collector task records the parameters' names and types. Furthermore, it extracts additional attributes embedded as Javadoc comments from the methods. At the moment, the only such attribute is "@event.severity" which indicates the default event severity (which can be changed by event listeners). The example event producer above shows the Javadocs for an event method.

      There's one more information that is extracted from the event producer information for the event model: an optional primary exception. The first exception in the "throws" declaration of an event method is noted. It is used to throw an exception from the invocation handler if the event has an event severity of "FATAL" when all listeners have been called (listeners can update the event severity). Please note that an implementation of org.apache.fop.events.EventExceptionManager$ExceptionFactory has to be registered for the EventExceptionManager to be able to construct the exception from an event.

      For a given application, there can be multiple event models active at the same time. In FOP, each renderer is considered to be a plug-in and provides its own specific event model. The individual event models are provided through an EventModelFactory . This interface is implemented for each event model and registered through the service provider mechanism (see the plug-ins section for details).

      -

      Event severity #

      +

      Event severity #

      Four different levels of severity for events has been defined:

      1. @@ -491,7 +491,7 @@ producer.complain(this, "I'm tired", 23)

      Event listeners can choose to ignore certain events based on their event severity. Please note that you may recieve an event "twice" in a specific case: if there is a fatal error an event is generated and sent to the listeners. After that an exception is thrown with the same information and processing stops. If the fatal event is shown to the user and the following exception is equally presented to the user it may appear that the event is duplicated. Of course, the same information is just published through two different channels.

      -

      Plug-ins to the event subsystem #

      +

      Plug-ins to the event subsystem #

      The event subsystem is extensible. There are a number of extension points:

      • @@ -502,7 +502,7 @@ producer.complain(this, "I'm tired", 23)

      The names in bold above are used as filenames for the service provider files that are placed in the META-INF/services directory. That way, they are automatically detected. This is a mechanism defined by the JAR file specification .

      -

      Localization (L10n) #

      +

      Localization (L10n) #

      One goal of the event subsystem was to have localized (translated) event messages. The EventFormatter class can be used to convert an event to a human-readable message. Each EventProducer can provide its own XML-based translation file. If there is none, a central translation file is used, called "EventFormatter.xml" (found in the same directory as the EventFormatter class).

      The XML format used by the EventFormatter is the same as Apache Cocoon's catalog format. Here's an example: <?xml version="1.0" encoding="UTF-8"?> Modified: websites/staging/xmlgraphics/trunk/content/fop/1.0/fonts.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/1.0/fonts.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/1.0/fonts.html Wed Oct 24 04:09:09 2012 @@ -330,9 +330,9 @@ $(document).ready(function () {

      -

      Apache(tm) FOP: Fonts

      +

      Apache™ FOP: Fonts

      $Revision: 1298724 $

      -

      Summary

      +

      Summary

      The following table summarizes the font capabilities of the various Apache� FOP renderers:

      @@ -410,7 +410,7 @@ $(document).ready(function () {
      -

      Base-14 Fonts

      +

      Base-14 Fonts

      The Adobe PostScript and PDF Specification specify a set of 14 fonts that must be available to every PostScript interpreter and PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), Symbol and ZapfDingbats.

      The following font family names are hard-coded into FOP for the Base-14 font set:

      @@ -444,14 +444,14 @@ $(document).ready(function () {

      Please note that recent versions of Adobe Acrobat Reader replace "Helvetica" with "Arial" and "Times" with "Times New Roman" internally. GhostScript replaces "Helvetica" with "Nimbus Sans L" and "Times" with "Nimbus Roman No9 L". Other document viewers may do similar font substitutions. If you need to make sure that there are no such substitutions, you need to specify an explicit font and embed it in the target document.

      -

      Missing Fonts

      +

      Missing Fonts

      When FOP does not have a specific font at its disposal (because it's not installed in the operating system or set up in FOP's configuration), the font is replaced with "any". "any" is internally mapped to the Base-14 font "Times" (see above).

      -

      Missing Glyphs

      +

      Missing Glyphs

      Every font contains a particular set of glyphs . If no glyph can be found for a given character, FOP will issue a warning and use the glpyh for "#" (if available) instead. Before it does that, it consults a (currently hard-coded) registry of glyph substitution groups (see Glyphs.java in Apache XML Graphics Commons). This registry can supply alternative glyphs in some cases (like using space when a no-break space is requested). But there's no guarantee that the result will be as expected (for example, in the case of hyphens and similar glyphs). A better way is to use a font that has all the necessary glyphs. This glyph substitution is only a last resort.

      -

      Java2D/AWT/Operating System Fonts

      +

      Java2D/AWT/Operating System Fonts

      The Java2D family of renderers (Java2D, AWT, Print, TIFF, PNG), use the Java AWT subsystem for font metric information. Through operating system registration, the AWT subsystem knows what fonts are available on the system, and the font metrics for each one.

      When working with one of these output formats and you're missing a font, just install it in your operating system and they should be available for these renderers. Please note that this is not true for other output formats such as PDF or PostScript.

      -

      Custom Fonts

      +

      Custom Fonts

      Support for custom fonts is highly output format dependent (see above table). This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and Java2D-based renderers. Other renderers (like AFP) support other font formats. Details in this case can be found on the page about output formats .

      In earlier FOP versions, it was always necessary to create an XML font metrics file if you wanted to add a custom font. This unconvenient step has been removed and in addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts installed in your operating system or can scan user-specified directories for fonts. Font registration via XML font metrics file is still supported and may still be necessary for some very special cases as fallback variant while we stabilize font auto-detection.

      Basic information about fonts can be found at:

      @@ -463,7 +463,7 @@ $(document).ready(function () {

      Adobe Font Technote

    -

    Basic font configuration

    +

    Basic font configuration

    If you want FOP to use custom fonts, you need to tell it where to find them. This is done in the configuration file and once per renderer (because each output format is a little different). In the basic form, you can either tell FOP to find your operating system fonts or you can specify directories that it will search for support fonts. These fonts will then automatically be registered.

    @@ -481,9 +481,9 @@ $(document).ready(function () {

    Review the documentation for FOP Configuration for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information. It is currently not possible to easily configure fonts from Java code.

    -

    Advanced font configuration

    +

    Advanced font configuration

    The instructions found above should be sufficient for most users. Below are some additional instructions in case the basic font configuration doesn't lead to the desired results.

    -

    Type 1 Font Metrics #

    +

    Type 1 Font Metrics #

    FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. To use it, run the class org.apache.fop.fonts.apps.PFMReader:

    Windows: java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar @@ -496,7 +496,7 @@ PFMReader [options]:

  • -fn By default, FOP uses the fontname from the .pfm file when embedding the font. Use the "-fn" option to override this name with one you have chosen. This may be useful in some cases to ensure that applications using the output document (Acrobat Reader for example) use the embedded font instead of a local font with the same name. The classpath in the above example has been simplified for readability. You will have to adjust the classpath to the names of the actual JAR files in the lib directory. xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later.The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. The constructed values however appear to have no visible influence.
-

TrueType Font Metrics #

+

TrueType Font Metrics #

FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. Use it in a similar manner to PFMReader. For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf: java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar org.apache.fop.fonts.apps.TTFReader [options] @@ -557,7 +557,7 @@ Alternatively, the individual sub-fonts

-

Register Fonts with FOP #

+

Register Fonts with FOP #

You must tell FOP how to find and use the font metrics files by registering them in the FOP Configuration . Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:

@@ -631,7 +631,7 @@ Alternatively, the individual sub-fonts

If relative URLs are specified, they are evaluated relative to the value of the "font-base" setting. If there is no "font-base" setting, the fonts are evaluated relative to the base directory.

-

Auto-Detect and auto-embed feature #

+

Auto-Detect and auto-embed feature #

When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.

FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf: Manifest-Version: 1.0

@@ -641,7 +641,7 @@ Manifest-Version: 1.0

This feature allows you to create JAR files containing fonts. The JAR files can be added to fop by providem them in the classpath, e.g. copying them into the lib/ directory.

-

Embedding #

+

Embedding #

By default, all fonts are embedded if an output format supports font embedding. In some cases, however, it is preferred that some fonts are only referenced. When working with referenced fonts it is important to be in control of the target environment where the produced document is consumed, i.e. the necessary fonts have to be installed there.

There are two different ways how you can specify that a font should be referenced:

    @@ -680,7 +680,7 @@ At the moment, you can only match fonts

    When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the original font, containing only the glyphs used, is embedded in the output document. That's the default, but if you specify encoding-mode="single-byte" (see above), the complete font is embedded.

    -

    Substitution #

    +

    Substitution #

    When a section is defined in the configuration, FOP will re-map any font-family references found in your FO input to a given substitution font.

    • @@ -705,7 +705,7 @@ At the moment, you can only match fonts

      -

      Font Selection Strategies

      +

      Font Selection Strategies

      There are two font selection strategies: character-by-character or auto. The default is auto.

      Auto selected the first font from the list which is able to display the most characters in a given word. This means (assume font A has characters for abclmn, font B for lnmxyz, fontlist is A,B):

        @@ -723,7 +723,7 @@ At the moment, you can only match fonts

      Character-by-Character is NOT yet supported!

      -

      Font List Command-Line Tool

      +

      Font List Command-Line Tool

      FOP contains a small command-line tool that lets you generate a list of all configured fonts. Its class name is: org.apache.fop.tools.fontlist.FontListMain . Run it with the "-?" parameter to get help for the various options.

--------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: commits-help@xmlgraphics.apache.org