Presentation is loading. Please wait.

Presentation is loading. Please wait.

Formatting Objects

Similar presentations


Presentation on theme: "Formatting Objects"— Presentation transcript:

1 Formatting Objects http://apache.roweboat.net/xml/fop/

2 What is it? Why would I use it? FOP (Formatting Objects Processor) is the world's first print formatter driven by XSL formatting objects (XSL-FO) and the world's first output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PCL, PS, SVG, XML (area tree representation), Print, AWT, MIF and TXT. The primary output target is PDF.Output formats

3 More about FOP FOP (Formatting Objects Processor) is the world's first print formatter driven by XSL formatting objects (XSL-FO) and the world's first output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PCL, PS, SVG, XML (area tree representation), Print, AWT, MIF and TXT. The primary output target is PDF.Output formats

4 downloads You’ll have to download FOP from xml.apache.org/fop FOP uses Xalan and Xerces parsers. FOP includes java programs for which you’ll need J2SE

5 the batch file The FOP download includes a batch file FOP.bat. To run this, build a DOS prompt to point to the FOP directory (FOP-0.20.5 is the version number for the directory I downloaded on 8/12/05) The FOP batch file expects the name of an fo file as the first (input) parameter and a pdf as the second (output) parameter.

6 OPTIONS -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 -s (-at output) omit tree below block areas -txt.encoding (-txt output encoding use the encoding for the output file. The encoding must be a valid java encoding. -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

7 [INPUT] infile XSLFO input file (the same as the next) -fo infile xsl:fo input file -xml infile xml input file, must be used together with -xsl -xsl stylesheet xslt stylesheet

8 [OUTPUT] outfile input will be rendered as pdf file into outfile -pdf outfile input will be rendered as pdf file (outfile req'd) - awt input will be displayed on screen -mif outfile input will be rendered as mif file (outfile req'd) - pcl outfile input will be rendered as pcl file (outfile req'd) - ps outfile input will be rendered as PostScript file (outfile req'd) -txt outfile input will be rendered as text file (outfile req'd) - svg outfile input will be rendered as an svg slides file (outfile req'd) -at outfile representation of area tree as XML (outfile req'd) -print input file will be rendered and sent to the printer see print specific options with "-print help"

9 [Examples] fop foo.fo foo.pdf fop -fo foo.fo -pdf foo.pdf (does the same as the previous line) fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf fop foo.fo -mif foo.mif fop foo.fo -print (or) fop -print foo.fo fop foo.fo -awt

10 your own batch files You may wish to make You may wish to make your own batch files (you’ll need to fix paths) to run xalan. This batch file requires 3 parameters, the xml file, the xsl file and a fo file: java -classpath C:\xalan-j-current-bin\xalan- j_2_6_0\bin\xalan.jar;C:\xalan-j-current- bin\xalan-j_2_6_0\bin\xercesImpl.jar org.apache.xalan.xslt.Process -IN %1 - XSL %2 -OUT %3

11 A batch file to run fop – you’ll need to fix paths. This batch file requires 2 parameters set LIBDIR=C:\fop\fop-0.20.5\lib set LOCALCLASSPATH=C:\fop\fop-0.20.5\build\fop.jar Set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xml-apis.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xercesImpl- 2.2.1.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.4.1.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon- framework-cvs-20020806.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_codec.jar java -cp "%LOCALCLASSPATH%" org.apache.fop.apps.Fop %1 %2

12 running FOP

13 simple.pdf created from simple.fo

14 simple.fo the file simple.fo is in the notes. typically a formatted object file would be built with a special editing tool. An fo file is an xml file, so it can have extension xml, xsl or fo (or whatever).

15 C:\pathtofop\>FOP readme.fo readme.pdf

16 fo file Xalan parser can produce an fo from xml using a stylesheet.

17 Running fop (excerpt from readme.pdf)

18 running fop on table.fo C:\FIT\FOP-02~1.5>fop table.fo table.pdf [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] FOP 0.20.5 [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] building formatting object tree [INFO] setting up fonts [INFO] [1] [INFO] [2] [INFO] [3] [INFO] [4] [INFO] [5] [INFO] [6] [INFO] [7] [INFO] Parsing of document complete, stopping renderer

19 an fo table this is normal text. this is normal text. this is normal text. this is normal text. this is normal text. this is normal text. good bad ugly nice dice vice literature music art java perl python this is normal text. this is normal text. this is normal text.

20 table.pdf

21 fonts.fo to fonts.pdf

22 more fop: fo file in notes

23 Text examples don’t seem to work Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990-2001. C:\FOP\FOP-02~1.5>fop topic_list.fo topics.pdf [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] FOP 0.20.5 [INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser [INFO] building formatting object tree [INFO] setting up fonts [WARNING] A 'flow-name' is required for fo:flow. This constraint will be enforce d in future versions of FOP [ERROR] file:/c:/fop/FOP-02~1.5/topic_list.fo:24:42 master-reference '' for fo:p age-sequence matches no simple-page-master or page-sequence-master C:\FOP\FOP-02~1.5>


Download ppt "Formatting Objects"

Similar presentations


Ads by Google