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 4DAF69F39 for ; Sun, 15 Apr 2012 05:41:40 +0000 (UTC) Received: (qmail 10404 invoked by uid 500); 15 Apr 2012 05:41:40 -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 10396 invoked by uid 99); 15 Apr 2012 05:41:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Apr 2012 05:41:40 +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; Sun, 15 Apr 2012 05:41:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 61C8F2388C7E for ; Sun, 15 Apr 2012 05:40:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r813018 [24/24] - in /websites/staging/xmlgraphics/trunk/content: ./ fop/ fop/0.95/ fop/0.95/images/ fop/1.0/ fop/1.0/images/ fop/dev/ fop/dev/design/ fop/dev/fo/ fop/dev/svg/ fop/fo/ fop/trunk/ fop/trunk/images/ Date: Sun, 15 Apr 2012 05:39:54 -0000 To: commits@xmlgraphics.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120415054004.61C8F2388C7E@eris.apache.org> Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfa.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfa.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfa.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,139 @@ + + + + Apache™ FOP: PDF/A (ISO 19005) + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Apache™ FOP: PDF/A (ISO 19005)

+
+

Home » Fop » Trunk

+ +

$Revision: 1298724 $

+

Overview

+

PDF/A is a standard which turns PDF into an "electronic document file format for long-term preservation". PDF/A-1 is the first part of the standard and is documented in ISO 19005-1:2005(E) . Work on PDF/A-2 is in progress at AIIM .

+

Design documentation on PDF/A can be found on FOP's Wiki on the PDFA1ConformanceNotes page.

+

Implementation Status

+

PDF/A-1b is implemented to the degree that FOP supports the creation of the elements described in ISO 19005-1.

+

Tests have been performed against jHove and Adobe Acrobat 7.0.7 (Preflight function). FOP does not validate completely against Apago's PDF Appraiser. Reasons unknown due to lack of a full license to get a detailed error protocol.

+

PDF/A-1a is based on PDF-A-1b and adds accessibility features (such as Tagged PDF). This format is available within the limitation described on the Accessibility page .

+

Usage (command line)

+

To activate PDF/A-1b from the command-line, specify "-pdfprofile PDF/A-1b" as a parameter. If there is a violation of one of the validation rules for PDF/A, an error message is presented and the processing stops.

+

PDF/A-1a is enabled by specifying "-pdfprofile PDF/A-1a".

+

Usage (embedded)

+

When FOP is embedded in another Java application you can set a special option on the renderer options in the user agent to activate the PDF/A-1b profile. Here's an example:

+

userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); +Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent); +[..] +If one of the validation rules of PDF/A is violated, an PDFConformanceException (descendant of RuntimeException) is thrown.

+

For PDF/A-1a, just use the string "PDF/A-1a" instead of "PDF/A-1b".

+

PDF/A in Action

+

There are a number of things that must be looked after if you activate a PDF/A profile. If you receive a PDFConformanceException, have a look at the following list (not necessarily comprehensive):

+
    +
  • +

    Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) you need to obtain a license for them and embed them like any other font.

    +
  • +
  • +

    Don't use PDF encryption. PDF/A doesn't allow it.

    +
  • +
  • +

    Don't use CMYK images without an ICC color profile. PDF/A doesn't allow mixing color spaces and FOP currently only properly supports the sRGB color space. Please note that FOP embeds a standard sRGB ICC profile (sRGB IEC61966-2.1) as the primary output intent for the PDF if no other output intent has been specified in the configuration.

    +
  • +
  • +

    Don't use non-RGB colors in SVG images. Same issue as with CMYK images.

    +
  • +
  • +

    Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF is deprecated since PDF 1.4 and prohibited by PDF/A.

    +
  • +
  • +

    PDF is forced to version 1.4 if PDF/A-1 is activated.

    +
  • +
  • +

    No filter must be specified explicitely for metadata objects. Metadata must be embedded in clear text so non-PDF-aware applications can extract the XMP metadata. +There are additional requirements if you want to enabled PDF/A-1a (Tagged PDF). This is particularly the specification of the natural language and alternative descriptions for images. Please refer to the Accessibility page for details.

    +
  • +
+

PDF profile compatibility

+

The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" (or "PDF/A-1a") are compatible and can both be activated at the same time.

+

Interoperability

+

There has been some confusion about the namespace for the PDF/A indicator in the XMP metadata. At least three variants have been seen in the wild:

+ + + + + + + + + + + + + +
http://www.aiim.org/pdfa/ns/id.htmlobsolete , from an early draft of ISO-19005-1, used by Adobe Acrobat 7.x
http://www.aiim.org/pdfa/ns/id/correct , found in the technical corrigendum 1 of ISO 19005-1:2005
+

If you get an error validating a PDF/A file in Adobe Acrobat 7.x it doesn't mean that FOP did something wrong. It's Acrobat that is at fault. This is fixed in Adobe Acrobat 8.x which uses the correct namespace as described in the technical corrigendum 1.

+
+ + + + Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfencryption.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfencryption.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfencryption.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,281 @@ + + + + Apache™ FOP: PDF encryption. + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Apache™ FOP: PDF encryption.

+
+

Home » Fop » Trunk

+ +

$Revision: 1298724 $

+

Overview

+

Apache™ FOP supports encryption of PDF output, thanks to Patrick 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 encryption, look at the documentation coming with Adobe Acrobat or the technical documentation on the Adobe web site.

+

Usage (command line) # {#Usage+%28command+line%29}

+

Encryption is enabled by supplying any of the encryption related options.

+

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. In this case it is obviously impossiible to disregard restrictions in PDF processing tools.

+

A user password, supplied with the -u option, will cause the PDF display software to ask the reader for this password in order to view the contents of the document. If no user password was supplied, viewing the content is not restricted.

+

Further restrictions can be imposed by using the following command-line options: +| Option | Description | +|--------|-------------| +| -noprint | disable printing | +| -nocopy | disable copy/paste of content | +| -noedit | disable editing in Adobe Acrobat | +| -noannotations | disable editing of annotations | +| -nofillinforms | disable filling in forms | +| -noaccesscontent | disable text and graphics extraction for accessibility purposes | +| -noassembledoc | disable assembling documents | +| -noprinthq | disable high quality printing |

+

Usage (embedded) # {#Usage+%28embedded%29}

+

When FOP is embedded in another Java application you need to set an options map on the renderer. These are the supported options:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionDescriptionValuesDefault
encryption-lengthThe encryption length in bitAny multiple of 8 between 40 and 12840
ownerPasswordThe owner passwordString
userPasswordThe user passwordString
allowPrintAllows/disallows printing of the PDF"TRUE" or "FALSE""TRUE"
allowCopyContentAllows/disallows copy/paste of content"TRUE" or "FALSE""TRUE"
allowEditContentAllows/disallows editing in Adobe Acrobat"TRUE" or "FALSE""TRUE"
allowEditAnnotationsAllows/disallows editing of annotations"TRUE" or "FALSE""TRUE"
allowFillInFormsAllows/disallows filling in forms"TRUE" or "FALSE""TRUE"
allowAccessContentAllows/disallows text and graphics extraction for accessibility purposes"TRUE" or "FALSE""TRUE"
allowAssembleDocumentAllows/disallows assembling document"TRUE" or "FALSE""TRUE"
allowPrintHqAllows/disallows high quality printing"TRUE" or "FALSE""TRUE"
Encryption is enabled as soon as one of these options is set.
An example to enable PDF encryption in Java code:
+

import org.apache.fop.pdf.PDFEncryptionParams;

+

[..]

+

FOUserAgent userAgent = fopFactory.newFOUserAgent(); +useragent.getRendererOptions().put("encryption-params", new PDFEncryptionParams( + null, "password", false, false, true, true)); +Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent); +[..] +The parameters for the constructor of PDFEncryptionParams are:

+
    +
  1. +

    userPassword: String, may be null

    +
  2. +
  3. +

    ownerPassword: String, may be null

    +
  4. +
  5. +

    allowPrint: true if printing is allowed

    +
  6. +
  7. +

    allowCopyContent: true if copying content is allowed

    +
  8. +
  9. +

    allowEditContent: true if editing content is allowed

    +
  10. +
  11. +

    allowEditAnnotations: true if editing annotations is allowed

    +
  12. +
  13. +

    allowFillInForms: true if filling in forms is allowed.

    +
  14. +
  15. +

    allowAccessContent: true if extracting text and graphics is allowed

    +
  16. +
  17. +

    allowAssembleDocument: true if assembling document is allowed

    +
  18. +
  19. +

    allowPrintHq: true if printing to high quality is allowed

    +
  20. +
+

Alternatively, you can set each value separately in the Map provided by FOUserAgent.getRendererOptions() by using the following keys:

+
    +
  1. +

    user-password: String

    +
  2. +
  3. +

    owner-password: String

    +
  4. +
  5. +

    noprint: Boolean or "true"/"false"

    +
  6. +
  7. +

    nocopy: Boolean or "true"/"false"

    +
  8. +
  9. +

    noedit: Boolean or "true"/"false"

    +
  10. +
  11. +

    noannotations: Boolean or "true"/"false"

    +
  12. +
  13. +

    nofillinforms: Boolean or "true"/"false"

    +
  14. +
  15. +

    noaccesscontent: Boolean or "true"/"false"

    +
  16. +
  17. +

    noassembledoc: Boolean or "true"/"false"

    +
  18. +
  19. +

    noprinthq: Boolean or "true"/"false"

    +
  20. +
+

Environment

+

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 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 provider for the RC4 cipher is needed. Unfortunately, the sample JCE provider in Sun's JDK 1.4 does not provide RC4. If you get a message saying +"Cannot find any provider supporting RC4" +then you don't have the needed infrastructure.

+

There are several commercial and a few Open Source packages which provide RC4. A pure Java implementation is produced by The Legion of the Bouncy Castle . Mozilla JSS is an interface to a native implementation.

+

Installing a crypto provider

+

The pure Java implementation from Bouncy Castle is easy to install.

+
    +
  1. +

    Download the binary distribution for your JDK version.

    +
  2. +
  3. +

    Unpack the distribution. Add the jar file to your classpath. A convenient way to use the jar on Linux is to simply drop it into the FOP lib directory, it will be automatically picked up by fop.sh .

    +
  4. +
  5. +

    Open the java.security file and add

    security.provider.6=org.bouncycastle.jce.provider.BouncyCastleProvider ,

    preferably at the end of the block defining the other crypto providers. For JDK 1.4 this is detailed on Sun's web site .

    +
  6. +
+

If you have any experience with Mozilla JSS or any other cryptography provider, please post it to the fop-user list.

+
+ + + + Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfx.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfx.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/pdfx.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,117 @@ + + + + Apache™ FOP: PDF/X (ISO 15930) + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Apache™ FOP: PDF/X (ISO 15930)

+
+

Home » Fop » Trunk

+ +

$Revision: 1298724 $

+

Overview

+

Support for PDF/X is available beginning with version 0.93. This feature is new and may not be 100% complete, yet. Feedback is welcome. +PDF/X is a standard which faciliates prepress digital data exchange using PDF. Currently, only PDF/X-3:2003 is implemented out of the many different flavours of PDF/X profiles. PDF/X-3:2003 is documented in ISO 15930-6:2003(E) . More info on PDF/X can be found on the PDF/X info site .

+

Implementation Status

+

PDF/X-3:2003 is implemented to the degree that FOP supports the creation of the elements described in ISO 15930-6.

+

An important restriction of the current implementation is that all normal RGB colors specified in XSL-FO and SVG are left unchanged in the sRGB color space (XSL-FO and SVG both use sRGB as their default color space). There's no conversion to a CMYK color space. Although sRGB is a calibrated color space, its color space has a different size than a CMYK color space which makes the conversion a lossy conversion and can lead to unwanted results. Although the use of the calibrated sRGB has been promoted for years, print shops usually prefer to convert an sRGB PDF to CMYK prior to production. Until there's full CMYK support in FOP you will have to work closely with your print service provider to make sure you get the intended result.

+

Tests have been performed against Adobe Acrobat 7.0.7 (Preflight function). Note that there are bugs in Adobe Acrobat which cause false alarms if both PDF/A-1b and PDF/X-3:2003 are activated at the same time.

+

Usage (command line)

+

To activate PDF/X-3:2003 from the command-line, specify "-pdfprofile PDF/X-3:2003" as a parameter. If there is a violation of one of the validation rules for PDF/X, an error message is presented and the processing stops.

+

Usage (embedded)

+

When FOP is embedded in another Java application you can set a special option on the renderer options in the user agent to activate the PDF/A-1b profile. Here's an example:

+

FOUserAgent userAgent = fopFactory.newFOUserAgent(); +userAgent.getRendererOptions().put("pdf-x-mode", "PDF/X-3:2003"); +Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent); +[..] +If one of the validation rules of PDF/X is violated, an PDFConformanceException (descendant of RuntimeException) is thrown.

+

PDF/X in Action

+

There are a number of things that must be looked after if you activate a PDF/X profile. If you receive a PDFConformanceException, have a look at the following list (not necessarily comprehensive):

+
    +
  • +

    Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) you need to obtain a license for them and embed them like any other font.

    +
  • +
  • +

    Don't use PDF encryption. PDF/X doesn't allow it.

    +
  • +
  • +

    Don't use CMYK images without an ICC color profile. PDF/X doesn't allow mixing color spaces and FOP currently only properly supports the sRGB color space. However, you will need to specify an output device profile (usually a CMYK profile) in the configuration. sRGB won't work here since it's a display device profile, not an output device profile.

    +
  • +
  • +

    Don't use non-RGB colors in SVG images. Same issue as with CMYK images.

    +
  • +
  • +

    Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF is deprecated since PDF 1.4 and prohibited by PDF/X-3:2003.

    +
  • +
  • +

    PDF is forced to version 1.4 if PDF/X-3:2003 is activated.

    +
  • +
+

PDF profile compatibility

+

The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" are compatible and can both be activated at the same time.

+
+ + + + Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/running.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/running.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/running.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,252 @@ + + + + Running Apache™ FOP + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Running Apache™ FOP

+
+

Home » Fop » Trunk

+ +

$Revision: 1308679 $

+

System Requirements

+

The following software must be installed:

+
    +
  • +

    Java 1.4.x or later Runtime Environment.

    +
      +
    • Many JREs >=1.4 contain older JAXP implementations (which often contain bugs). It's usually a good idea to replace them with a current implementation.
    • +
    +
  • +
  • +

    Apache™ FOP. The FOP distribution includes all libraries that you will need to run a basic FOP installation. These can be found in the [fop-root]/lib directory. These libraries include the following:

    + +
  • +
+

The following software is optional, depending on your needs:

+
    +
  • +

    Graphics libraries. Generally, FOP contains direct support for the most important bitmap image formats (including PNG, JPEG and GIF). See FOP: Graphics Formats for details.

    +
  • +
  • +

    PDF encryption. See FOP: PDF Encryption for details.

    +
  • +
+

In addition, the following system requirements apply:

+
    +
  • If you will be using FOP to process SVG, you must do so in a graphical environment. See FOP: Graphics (Batik) for details.
  • +
+

Installation

+

Instructions

+

Basic FOP installation consists of first unzipping the .gz file that is the distribution medium, then unarchiving the resulting .tar file in a directory/folder that is convenient on your system. Please consult your operating system documentation or Zip application software documentation for instructions specific to your site.

+

Problems

+

Some Mac OSX users have experienced filename truncation problems using Stuffit to unzip and unarchive their distribution media. This is a legacy of older Mac operating systems, which had a 31-character pathname limit. Several Mac OSX users have recommended that Mac OSX users use the shell command tar -xzf instead.

+

Starting FOP as a Standalone Application

+

Using the fop script or batch file

+

The usual and recommended practice for starting FOP from the command line is to run the batch file fop.bat (Windows) or the shell script fop (Unix/Linux). These scripts require that the environment variable JAVA_HOME be set to a path pointing to the appropriate Java installation on your system. Macintosh OSX includes a Java environment as part of its distribution. We are told by Mac OSX users that the path to use in this case is /Library/Java/Home . Caveat: We suspect that, as Apple releases new Java environments and as FOP upgrades the minimum Java requirements, the two will inevitably not match on some systems. Please see Java on Mac OSX FAQ for information as it becomes available.

+

USAGE +Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl|-ps|-txt|-at [mime]|-print] + [OPTIONS] + -version print FOP version and exit + -d debug mode + -x dump configuration settings + -q quiet mode + -c cfg.xml use additional configuration file cfg.xml + -l lang the language to use for user information + -nocs disable complex script features + -r relaxed/less strict validation (where available) + -dpi xxx target resolution in dots per inch (dpi) where xxx is a number + -s for area tree XML, down to block areas only + -v run in verbose mode (currently simply print FOP version and continue)

+

-o [password] PDF file will be encrypted with option owner password + -u [password] PDF file will be encrypted with option user password + -noprint PDF file will be encrypted without printing permission + -nocopy PDF file will be encrypted without copy content permission + -noedit PDF file will be encrypted without edit content permission + -noannotations PDF file will be encrypted without edit annotation permission + -nofillinforms PDF file will be encrypted without fill in forms permission + -noaccesscontent PDF file will be encrypted without extract text and graphics permission + -noassembledoc PDF file will be encrypted without assemble the document permission + -noprinthq PDF file will be encrypted without print high quality permission + -a enables accessibility features (Tagged PDF etc., default off) + -pdfprofile prof PDF file will be generated with the specified profile + (Examples for prof: PDF/A-1b or PDF/X-3:2003)

+

-conserve enable memory-conservation policy (trades memory-consumption for disk I/O) + (Note: currently only influences whether the area tree is serialized.)

+

-cache specifies a file/directory path location + -flush flushes the current font cache file

+

[INPUT] + infile xsl:fo input file (the same as the next) + (use '-' for infile to pipe input from stdin) + -fo infile xsl:fo input file + -xml infile xml input file, must be used together with -xsl + -atin infile area tree input file + -ifin infile intermediate format input file + -imagein infile image input file (piping through stdin not supported) + -xsl stylesheet xslt stylesheet

+

-param name value to use for parameter in xslt stylesheet + (repeat '-param name value' for each parameter)

+

-catalog use catalog resolver for input XML and XSLT files + [OUTPUT] + outfile input will be rendered as PDF into outfile + (use '-' for outfile to pipe output to stdout) + -pdf outfile input will be rendered as PDF (outfile req'd) + -pdfa1b outfile input will be rendered as PDF/A-1b compliant PDF + (outfile req'd, same as "-pdf outfile -pdfprofile PDF/A-1b") + -awt input will be displayed on screen + -rtf outfile input will be rendered as RTF (outfile req'd) + -pcl outfile input will be rendered as PCL (outfile req'd) + -ps outfile input will be rendered as PostScript (outfile req'd) + -afp outfile input will be rendered as AFP (outfile req'd) + -tiff outfile input will be rendered as TIFF (outfile req'd) + -png outfile input will be rendered as PNG (outfile req'd) + -txt outfile input will be rendered as plain text (outfile req'd) + -at [mime] out representation of area tree as XML (outfile req'd) + specify optional mime output to allow the AT to be converted + to final format later + -if [mime] out representation of document in intermediate format XML (outfile req'd) + specify optional mime output to allow the IF to be converted + to final format later + -print input file will be rendered and sent to the printer + see options with "-print help" + -out mime outfile input will be rendered using the given MIME type + (outfile req'd) Example: "-out application/pdf D:\out.pdf" + (Tip: "-out list" prints the list of supported MIME types) + -svg outfile input will be rendered as an SVG slides file (outfile req'd) + Experimental feature - requires additional fop-sandbox.jar.

+

-foout outfile input will only be XSL transformed. The intermediate + XSL-FO file is saved and no rendering is performed. + (Only available if you use -xml and -xsl parameters)

+

[Examples] + fop foo.fo foo.pdf + fop -fo foo.fo -pdf foo.pdf (does the same as the previous line) + fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf + fop -xml foo.xml -xsl foo.xsl -foout foo.fo + fop -xml - -xsl foo.xsl -pdf - + fop foo.fo -mif foo.mif + fop foo.fo -rtf foo.rtf + fop foo.fo -print + fop foo.fo -awt +PDF encryption is only available if FOP was compiled with encryption support and if compatible encryption support is available at run time. Currently, only the JCE is supported. Check the Details .

+

Writing your own script

+

FOP's entry point for your own scripts is the class org.apache.fop.cli.Main . The general pattern for the command line is: java -classpath <CLASSPATH> + org.apache.fop.cli.Main <arguments> . The arguments consist of the options and infile and outfile specifications as shown above for the standard scripts. You may wish to review the standard scripts to make sure that you get your environment properly configured.

+

Running with java's -jar option

+

As an alternative to the start scripts you can run java + -jar path/to/build/fop.jar <arguments> , relying on FOP to build the classpath for running FOP dynamically, see below . If you use hyphenation, you must put fop-hyph.jar in the lib directory.

+

You can also run java -jar path/to/fop.jar + <arguments> , relying on the Class-Path entry in the manifest file. This works if you put fop.jar and all jar files from the lib directory in a single directory. If you use hyphenation, you must also put fop-hyph.jar in that directory.

+

In both cases the arguments consist of the options and infile and outfile specifications as shown above for the standard scripts.

+

FOP's dynamical classpath construction

+

If FOP is started without a proper classpath, it tries to add its dependencies dynamically. If the system property fop.home contains the name of a directory, then FOP uses that directory as the base directory for its search. Otherwise the current working directory is the base directory. If the base directory is called build , then its parent directory becomes the base directory.

+

FOP expects to find fop.jar in the build subdirectory of the base directory, and adds it to the classpath. Subsequently FOP adds all jar files in the lib directory to the classpath. The lib directory is either the lib subdirectory of the base directory, or, if that does not exist, the base directory itself.

+

If the system property fop.optional.lib contains the name of a directory, then all jar files in that directory are also added to the classpath. See the methods getJARList and checkDependencies in org.apache.fop.cli.Main .

+

Using Xalan to Check XSL-FO Input

+

FOP sessions that use -xml and -xsl input instead of -fo input are actually controlling two distinct conversions: Tranforming XML to XSL-FO, then formatting the XSL-FO to PDF (or another FOP output format). Although FOP controls both of these processes, the first is included merely as a convenience and for performance reasons. Only the second is part of FOP's core processing. If a user has a problem running FOP, it is important to determine which of these two processes is causing the problem. If the problem is in the first process, the user's stylesheet is likely the cause. The FOP development team does not have resources to help with stylesheet issues, although we have included links to some useful Specifications and Books/Articles . If the problem is in the second process, FOP may have a bug or an unimplemented feature that does require attention from the FOP development team. +The user is always responsible to provide correct XSL-FO code to FOP. +In the case of using -xml and -xsl input, although the user is responsible for the XSL-FO code that is FOP's input, it is not visible to the user. To make the intermediate FO file visible, the FOP distribution includes the "-foout" option which causes FOP to run only the first (transformation) step, and write the results to a file. (See also the Xalan command-line below) +When asking for help on the FOP mailing lists, never attach XML and XSL to illustrate the issue. Always run the XSLT step (-foout) and send the resulting XSL-FO file instead. Of course, be sure that the XSL-FO file is correct before sending it. +The -foout option works the same way as if you would call the Xalan command-line :

+

java org.apache.xalan.xslt.Process -IN xmlfile -XSL file -OUT outfile

+

Note that there are some subtle differences between the FOP and Xalan command-lines.

+

Memory Usage

+

FOP can consume quite a bit of memory, even though this has been continually improved. This is partly inherent to the formatting process and partly caused by implementation choices. All FO processors currently on the market have memory problems with certain layouts.

+

If you are running out of memory when using FOP, here are some ideas that may help:

+
    +
  • +

    Increase memory available to the JVM. See the -Xmx option for more information.It is usually unwise to increase the memory allocated to the JVM beyond the amount of physical RAM, as this will generally cause significantly slower performance.

    +
  • +
  • +

    Avoid forward references. Forward references are references to some later part of a document. Examples include page number citations which refer to pages which follow the citation, tables of contents at the beginning of a document, and page numbering schemes that include the total number of pages in the document ( "page N of TOTAL" ). Forward references cause all subsequent pages to be held in memory until the reference can be resolved, i.e. until the page with the referenced element is encountered. Forward references may be required by the task, but if you are getting a memory overflow, at least consider the possibility of eliminating them. A table of contents could be replaced by PDF bookmarks instead or moved to the end of the document (reshuffle the paper could after printing).

    +
  • +
  • +

    Avoid large images, especially if they are scaled down. If they need to be scaled, scale them in another application upstream from FOP. For many image formats, memory consumption is driven mainly by the size of the image file itself, not its dimensions (width*height), so increasing the compression rate may help.

    +
  • +
  • +

    Use multiple page sequences. FOP starts rendering after the end of a page sequence is encountered. While the actual rendering is done page-by-page, some additional memory is freed after the page sequence has been rendered. This can be substantial if the page sequence contains lots of FO elements.

    +
  • +
+

Problems

+

If you have problems running FOP, please see the "How to get Help" page .

+
+ + + + Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/servlets.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/servlets.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/servlets.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,227 @@ + + + + Apache™ FOP: Servlets + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Apache™ FOP: Servlets

+
+

Home » Fop » Trunk

+ +

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

+

Overview

+

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

+

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:

+
    +
  • +

    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 {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

+

This section assumes you are familiar with embedding FOP .

+

A minimal Servlet

+

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

+

public void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException { + try { + response.setContentType("application/pdf"); + Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, response.getOutputStream()); + Transformer transformer = tFactory.newTransformer(); + Source src = new StreamSource("foo.fo"); + Result res = new SAXResult(fop.getDefaultHandler()); + transformer.transform(src, res); + } catch (Exception ex) { + 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)

+

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();

+

public void init() throws ServletException { + //Optionally customize the FopFactory and TransformerFactory here +}

+

[..]

+
//Setup a buffer to obtain the content length
+ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+//Setup FOP
+Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
+
+//Setup Transformer
+Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl"));
+Transformer transformer = tFactory.newTransformer(xsltSrc);
+
+//Make sure the XSL transformation's result is piped through to FOP
+Result res = new SAXResult(fop.getDefaultHandler());
+
+//Setup input
+Source src = new StreamSource(new File("foo.xml"));
+
+//Start the transformation and rendering process
+transformer.transform(src, res);
+
+//Prepare response
+response.setContentType("application/pdf");
+response.setContentLength(out.size());
+
+//Send content to Browser
+response.getOutputStream().write(out.toByteArray());
+response.getOutputStream().flush();Buffering the generated PDF in a ByteArrayOutputStream is done to avoid potential problems with the Acrobat Reader Plug-in in Microsoft Internet Explorer.
+
+ + +

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

+

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

+

Improving performance

+

There are several options to consider:

+
    +
  • +

    Instead of java.io.ByteArrayOutputStream consider using the ByteArrayOutputStream implementation from the Jakarta Commons IO project which allocates less memory. The full class name is: org.apache.commons.io.output.ByteArrayOutputStream

    +
  • +
  • +

    In certain cases it can help to write the generated PDF to a temporary file so you can quickly reuse the file. This is especially useful, if Internet Explorer calls the servlet multiple times with the same request or if you often generate equal PDFs.

    +
  • +
+

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

+

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 */
+protected URIResolver uriResolver;
+
+public void init() throws ServletException {
+    this.uriResolver = new ServletContextURIResolver(getServletContext());
+    [..]
+}
+
+ + +

The ServletContextURIResolver reacts on URIs beginning with "servlet-context:". If you want to access an image in a subdirectory of your web application, you could, for example, use: "servlet-context:/images/myimage.png". Don't forget the leading slash after the colon!

+

Further down, you can use the URIResolver for various things:

+
    +
  • +

    With the Transformer (JAXP/XSLT) so things like document() functions can resolver "servlet-context:" URIs.

    +
  • +
  • +

    With the FopFactory so every resource FOP loads can be loaded using a "servlet-context:" URI.

    +
  • +
  • +

    You can the ServletContextURIResolver yourself in your servlet code to access stylesheets or XML files bundled with your web application.

    +
  • +
+

Here are some example snippets:

+

//Setting up the JAXP TransformerFactory +this.transFactory = TransformerFactory.newInstance(); +this.transFactory.setURIResolver(this.uriResolver);

+

[..]

+

//Setting up the FOP factory +this.fopFactory = FopFactory.newInstance(); +this.fopFactory.setURIResolver(this.uriResolver);

+

[..]

+

//The stylesheet for the JAXP Transfomer +Source xsltSrc = this.uriResolver.resolve( + "servlet-context:/xslt/mystylesheet.xsl", null); +Transformer transformer = this.transFactory.newTransformer(xsltSrc); +transformer.setURIResolver(this.uriResolver);

+

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:

+
    +
  • +

    Use an URL ending in .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.

    +
  • +
  • +

    Give IEx the opportunity to cache. In particular, ensure the server does not set any headers causing IEx not to cache the content. This may be a real problem if the document is sent over HTTPS, because most IEx installations will by default not cache any content retrieved over HTTPS. Setting the Expires header entry may help in this case:

    response.setDateHeader("Expires", + System.currentTimeMillis() + cacheExpiringDuration * + 1000);

    Consult your server manual and the relevant RFCs for further details on HTTP headers and caching.

    +
  • +
  • +

    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

+

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

+

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

+

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

+

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.

+
+ + + + Added: websites/staging/xmlgraphics/trunk/content/fop/trunk/upgrading.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/upgrading.html (added) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/upgrading.html Sun Apr 15 05:39:50 2012 @@ -0,0 +1,122 @@ + + + + Upgrading from an Earlier Version of Apache™ FOP + + + + + + + + + + + + + + + + + + + +
+ The Apache XML Graphics Project +

Upgrading from an Earlier Version of Apache™ FOP

+
+

Home » Fop » Trunk

+ +

$Revision: 1298724 $

+

Important!

+

If you're planning to upgrade to the latest Apache™ FOP version there are a few very important things to consider:

+
    +
  • +

    The API of FOP has changed considerably and is not backwards-compatible with versions 0.20.5 and 0.91beta. Version 0.92 introduced the new stable API .

    +
  • +
  • +

    Since version 0.92 some deprecated methods which were part of the old API have been removed. If you upgrade from 0.91 beta, you will need to adjust your Java code. Similarly if you upgrade from 0.92 and use deprecated methods.

    +
  • +
  • +

    If you are using a configuration file for version 0.20.5, you have to rebuild it in the new format. The format of the configuration files has changed since version 0.20.5. See conf/fop.xconf for an example configuration file. A XML Schema file can be found under src/foschema/fop-configuration.xsd.

    +
  • +
  • +

    Beginning with version 0.94 you can skip the generation of font metric files and remove the "font-metrics" attribute in the font configuration. In the unlikely case that due to a bug you still need to use font metrics files you will need to regenerate the font metrics file if yours are from a FOP version before 0.93.

    +
  • +
  • +

    The new code is much more strict about the interpretation of the XSL-FO 1.1 specification. Things that worked fine in version 0.20.5 might start to produce warnings or even errors now. FOP 0.20.5 contains many bugs which have been corrected in the new code. +While FOP 0.20.5 allowed you to have empty fo:table-cell elements, the new code will complain about that (unless relaxed validation is enabled) because the specification demands at least one block-level element ( (%block;)+ , see XSL-FO 1.1, 6.7.10 ) inside an fo:table-cell element.

    +
  • +
  • +

    Extensions and Renderers written for version 0.20.5 will not work with the new code! The new FOP extension for Barcode4J is available since January 2007.

    +
  • +
  • +

    The SVG Renderer and the MIF Handler have not been resurrected, yet! They are currently non-functional and hope for someone to step up and reimplement them.

    +
  • +
+

What you need to know when you upgrade!

+

When you use your existing FO files or XML/XSL files which work fine with FOP version 0.20.5 against this FOP version some things may not work as expected. The following list will hopefully help you to identify and correct those problems.

+
    +
  • +

    Check the Compliance page for the feature causing trouble. It may contain the necessary information to understand and resolve the problem.

    +
  • +
  • +

    Not all 0.20.5 output formats are supported. PDF and Postscript should be fully supported. See Output Targets for a more complete description.

    +
  • +
  • +

    As stated above empty table cells <fo:table-cell></fo:table-cell> are not allowed by the specification. The same applies to empty static-content and block-container elements, for example.

    +
  • +
  • +

    0.20.5 is not XSL-FO compliant with respect to sizing images ( external-graphic ) or instream-foreign-object objects. If images or SVGs are sized differently in your outputs with the new FOP version check Bug 37136 as it contains some hints on what to do. The file has a number of good examples that show the new, more correct behaviour.

    +
  • +
  • +

    The fox:outline extension is not implemented in this version anymore. It has been superseded by the new bookmark elements from XSL-FO 1.1.

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