Browse Source

Branch


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-2_8@1905006 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_8
ssteiner 1 year ago
commit
43db0d56dd
100 changed files with 24800 additions and 0 deletions
  1. 48
    0
      build.properties
  2. 1435
    0
      build.xml
  3. 466
    0
      conf/fop.xconf
  4. 17
    0
      examples/embedding/README
  5. 158
    0
      examples/embedding/build.xml
  6. 108
    0
      examples/embedding/java/embedding/ExampleAWTViewer.java
  7. 190
    0
      examples/embedding/java/embedding/ExampleDOM2PDF.java
  8. 64
    0
      examples/embedding/java/embedding/ExampleEPS.java
  9. 52
    0
      examples/embedding/java/embedding/ExampleEPSSimple.java
  10. 142
    0
      examples/embedding/java/embedding/ExampleFO2JPSPrint.java
  11. 119
    0
      examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
  12. 142
    0
      examples/embedding/java/embedding/ExampleFO2PDF.java
  13. 133
    0
      examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java
  14. 135
    0
      examples/embedding/java/embedding/ExampleFO2RTF.java
  15. 182
    0
      examples/embedding/java/embedding/ExampleJava2D2PDF.java
  16. 125
    0
      examples/embedding/java/embedding/ExampleObj2PDF.java
  17. 123
    0
      examples/embedding/java/embedding/ExampleObj2XML.java
  18. 109
    0
      examples/embedding/java/embedding/ExampleSVG2PDF.java
  19. 108
    0
      examples/embedding/java/embedding/ExampleXML2FO.java
  20. 108
    0
      examples/embedding/java/embedding/ExampleXML2PDF.java
  21. 174
    0
      examples/embedding/java/embedding/MultipleFO2PDF.java
  22. 218
    0
      examples/embedding/java/embedding/atxml/ExampleConcat.java
  23. 143
    0
      examples/embedding/java/embedding/atxml/ExampleStamp.java
  24. 227
    0
      examples/embedding/java/embedding/events/ExampleEvents.java
  25. 33
    0
      examples/embedding/java/embedding/events/missing-image.fo
  26. 226
    0
      examples/embedding/java/embedding/intermediate/ExampleConcat.java
  27. 146
    0
      examples/embedding/java/embedding/intermediate/ExampleStamp.java
  28. 104
    0
      examples/embedding/java/embedding/model/ProjectMember.java
  29. 83
    0
      examples/embedding/java/embedding/model/ProjectTeam.java
  30. 56
    0
      examples/embedding/java/embedding/model/ProjectTeamInputSource.java
  31. 116
    0
      examples/embedding/java/embedding/model/ProjectTeamXMLReader.java
  32. 179
    0
      examples/embedding/java/embedding/tools/AbstractObjectReader.java
  33. 214
    0
      examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java
  34. 30
    0
      examples/embedding/xml/fo/helloworld.fo
  35. 26
    0
      examples/embedding/xml/svg/helloworld.svg
  36. 46
    0
      examples/embedding/xml/xml/projectteam.xml
  37. 58
    0
      examples/embedding/xml/xslt/atstamp.xsl
  38. 49
    0
      examples/embedding/xml/xslt/ifstamp.xsl
  39. 77
    0
      examples/embedding/xml/xslt/projectteam2fo.xsl
  40. 6
    0
      examples/fo/advanced/K3.README
  41. BIN
      examples/fo/advanced/K3.TTF
  42. 1
    0
      examples/fo/advanced/K3.xml
  43. 87
    0
      examples/fo/advanced/bar.conf.xml
  44. 99
    0
      examples/fo/advanced/barcode.fo
  45. 155
    0
      examples/fo/advanced/bleed-and-crop-marks.fo
  46. 455
    0
      examples/fo/advanced/cid-fonts.fo
  47. 561
    0
      examples/fo/advanced/cid-fonts.pdf
  48. 1258
    0
      examples/fo/advanced/giro.fo
  49. 126
    0
      examples/fo/advanced/rounded-corners.fo
  50. 207
    0
      examples/fo/basic/alignment.fo
  51. 170
    0
      examples/fo/basic/blockcontainer.fo
  52. 199
    0
      examples/fo/basic/border.fo
  53. 160
    0
      examples/fo/basic/bordershorthand.fo
  54. 105
    0
      examples/fo/basic/character.fo
  55. 228
    0
      examples/fo/basic/corresprop.fo
  56. 148
    0
      examples/fo/basic/extensive.fo
  57. 195
    0
      examples/fo/basic/fonts.fo
  58. 428
    0
      examples/fo/basic/hyphen.fo
  59. 168
    0
      examples/fo/basic/images.fo
  60. 166
    0
      examples/fo/basic/inhprop.fo
  61. 114
    0
      examples/fo/basic/instream.fo
  62. 781
    0
      examples/fo/basic/leader.fo
  63. 146
    0
      examples/fo/basic/link.fo
  64. 2690
    0
      examples/fo/basic/list.fo
  65. 148
    0
      examples/fo/basic/newlinktest.fo
  66. 140
    0
      examples/fo/basic/normal.fo
  67. 140
    0
      examples/fo/basic/normalex.fo
  68. 1402
    0
      examples/fo/basic/pdfoutline.fo
  69. 1341
    0
      examples/fo/basic/readme.fo
  70. 99
    0
      examples/fo/basic/simple.fo
  71. 504
    0
      examples/fo/basic/table.fo
  72. 220
    0
      examples/fo/basic/tableunits.fo
  73. 254
    0
      examples/fo/basic/textdeko.fo
  74. 164
    0
      examples/fo/build.xml
  75. 217
    0
      examples/fo/fo-reference/xml2pdf.xsl
  76. 1809
    0
      examples/fo/fo-reference/xslfoRef.xml
  77. 249
    0
      examples/fo/footnotes/columns.fo
  78. 122
    0
      examples/fo/footnotes/simple.fo
  79. BIN
      examples/fo/graphics/asf-logo-nt.png
  80. BIN
      examples/fo/graphics/asf-logo.png
  81. BIN
      examples/fo/graphics/asf-logo.tif
  82. BIN
      examples/fo/graphics/fop.jpg
  83. BIN
      examples/fo/graphics/linux.bmp
  84. BIN
      examples/fo/graphics/listgeometry.gif
  85. BIN
      examples/fo/graphics/page.gif
  86. BIN
      examples/fo/graphics/xml_fax.tif
  87. BIN
      examples/fo/graphics/xml_feather.gif
  88. BIN
      examples/fo/graphics/xml_feather_transparent.gif
  89. 289
    0
      examples/fo/keeps_and_breaks/columnlevel1.fo
  90. 137
    0
      examples/fo/keeps_and_breaks/pagelevel1.fo
  91. 292
    0
      examples/fo/keeps_and_breaks/pagelevel2.fo
  92. 288
    0
      examples/fo/keeps_and_breaks/pagelevel3.fo
  93. 291
    0
      examples/fo/keeps_and_breaks/pagelevel4.fo
  94. 314
    0
      examples/fo/markers/glossary.xml
  95. 78
    0
      examples/fo/markers/glossary.xsl
  96. 131
    0
      examples/fo/markers/hide.fo
  97. 141
    0
      examples/fo/pagination/allregions.fo
  98. 130
    0
      examples/fo/pagination/basic2.fo
  99. 1078
    0
      examples/fo/pagination/franklin_2pageseqs.fo
  100. 0
    0
      examples/fo/pagination/franklin_alt.fo

+ 48
- 0
build.properties View File

@@ -0,0 +1,48 @@
## This is a template for settings which are useful to be
## overridden in a developer specific property files.
## Copy this to build-local.properties, uncomment and change
## properties which should be overridden.
## The file buil-local.properties is not stored in the code
## repository and ignored for file adds.

## ===================================================================
## 1. Path settings

## All Jars from the optional lib directory are added used for
## compilation and JUnit tests. Put your jars for additional
## dependencies and tools here.
# optional.lib.dir = /home/bart/java/lib

## Checkstyle home directory. This is meant to be the top level of the
## checkstyle binary distribution.
# checkstyle.home.dir = /home/bart/stuff/checkstyle-4.0-beta6

## ===================================================================
## 2. Switches for common tasks

## Javac switches
# javac.debug = on
# javac.optimize = off
# javac.deprecation = on
# javac.source = 1.4
# javac.target = 1.4
# javac.fork = on

## JUnit task switches
# junit.fork = on

## Packages to produce javadoc.
## Add packages for FOP extensions if necessary.
# javadoc.packages = org.apache.fop.*,fopextension.*

## ===================================================================
## 3. FOP specific properties

## Specify an alternate file that contains a list of disabled layout
## engine tests.
# layoutengine.disabled = test/layoutengine/disabled-testcases.txt

## Specify an alternate directory to scan for user supplied
## hyphenation pattern files and Unicode data files.
# user.hyph.dir = /home/bart/offo
# unidata.dir = /usr/share/doc/Unicode/UNIDATA

+ 1435
- 0
build.xml
File diff suppressed because it is too large
View File


+ 466
- 0
conf/fop.xconf View File

@@ -0,0 +1,466 @@
<?xml version="1.0"?>
<!-- $Id$ -->

<!--

This is an example configuration file for FOP.
This file contains the same settings as the default values
and will have no effect if used unchanged.

Relative config url's will be resolved relative to
the location of this file.

-->

<!-- NOTE: This is the version of the configuration -->
<fop version="1.0">

<!-- Base URL for resolving relative URLs -->
<base>.</base>
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
<source-resolution>72</source-resolution>
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
<target-resolution>72</target-resolution>
<!-- Default page-height and page-width, in case value is specified as auto -->
<default-page-settings height="11.00in" width="8.50in"/>
<!-- Information for specific renderers -->
<!-- Uses renderer mime type for renderers -->
<renderers>
<renderer mime="application/pdf">
<filterList>
<!-- provides compression using zlib flate (default is on) -->
<value>flate</value>
<!-- encodes binary data into printable ascii characters (default off)
This provides about a 4:5 expansion of data size -->
<!-- <value>ascii-85</value> -->
<!-- encodes binary data with hex representation (default off)
This filter is not recommended as it doubles the data size -->
<!-- <value>ascii-hex</value> -->
</filterList>

<fonts>
<!-- embedded fonts -->
<!--
This information must exactly match the font specified
in the fo file. Otherwise it will use a default font.

For example,
<fo:inline font-family="Arial" font-weight="bold" font-style="normal">
Arial-normal-normal font
</fo:inline>
for the font triplet specified by:
<font-triplet name="Arial" style="normal" weight="bold"/>

If you do not want to embed the font in the pdf document
then do not include the "embed-url" attribute.
The font will be needed where the document is viewed
for it to be displayed properly.

possible styles: normal | italic | oblique | backslant
possible weights: normal | bold | 100 | 200 | 300 | 400
| 500 | 600 | 700 | 800 | 900
(normal = 400, bold = 700)
-->

<!--
<font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
<font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
-->

<!-- auto-detect fonts -->
<auto-detect/>

</fonts>

<!-- This option lets you specify additional options on an XML handler -->
<!--xml-handler namespace="http://www.w3.org/2000/svg">
<stroke-text>false</stroke-text>
</xml-handler-->

</renderer>

<renderer mime="application/x-afp">
<!--
The bit depth and type of images produced
(this is the default setting)
-->
<images mode="b+w" bits-per-pixel="8"/>
<renderer-resolution>240</renderer-resolution>
<line-width-correction>2.5</line-width-correction>
<resource-group-file>resources.afp</resource-group-file>

<fonts>
<!--
Below is an example using raster font configuration using FOP builtin base-14 font metrics.
for Times Roman, Helvetica and Courier.

Depending on AFP raster and outline font availability on your installation you will
most likely need to modify the configuration provided below.

See http://xmlgraphics.apache.org/fop/trunk/output.html#afp-configuration
for details of FOP configuration for AFP
-->

<!-- Times Roman -->
<font>
<afp-font name="Times Roman" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0N20060" base14-font="TimesRoman"/>
<afp-raster-font size="7" characterset="C0N20070" base14-font="TimesRoman"/>
<afp-raster-font size="8" characterset="C0N20080" base14-font="TimesRoman"/>
<afp-raster-font size="9" characterset="C0N20090" base14-font="TimesRoman"/>
<afp-raster-font size="10" characterset="C0N20000" base14-font="TimesRoman"/>
<afp-raster-font size="11" characterset="C0N200A0" base14-font="TimesRoman"/>
<afp-raster-font size="12" characterset="C0N200B0" base14-font="TimesRoman"/>
<afp-raster-font size="14" characterset="C0N200D0" base14-font="TimesRoman"/>
<afp-raster-font size="16" characterset="C0N200F0" base14-font="TimesRoman"/>
<afp-raster-font size="18" characterset="C0N200H0" base14-font="TimesRoman"/>
<afp-raster-font size="20" characterset="C0N200J0" base14-font="TimesRoman"/>
<afp-raster-font size="24" characterset="C0N200N0" base14-font="TimesRoman"/>
<afp-raster-font size="30" characterset="C0N200T0" base14-font="TimesRoman"/>
<afp-raster-font size="36" characterset="C0N200Z0" base14-font="TimesRoman"/>
</afp-font>
<font-triplet name="Times" style="normal" weight="normal"/>
<font-triplet name="TimesRoman" style="normal" weight="normal"/>
<font-triplet name="Times Roman" style="normal" weight="normal"/>
<font-triplet name="Times-Roman" style="normal" weight="normal"/>
<font-triplet name="Times New Roman" style="normal" weight="normal"/>
<font-triplet name="TimesNewRoman" style="normal" weight="normal"/>
<font-triplet name="serif" style="normal" weight="normal"/>
</font>
<!-- Times Roman Italic -->
<font>
<afp-font name="Times Roman Italic" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0N30060" base14-font="TimesItalic"/>
<afp-raster-font size="7" characterset="C0N30070" base14-font="TimesItalic"/>
<afp-raster-font size="8" characterset="C0N30080" base14-font="TimesItalic"/>
<afp-raster-font size="9" characterset="C0N30090" base14-font="TimesItalic"/>
<afp-raster-font size="10" characterset="C0N30000" base14-font="TimesItalic"/>
<afp-raster-font size="11" characterset="C0N300A0" base14-font="TimesItalic"/>
<afp-raster-font size="12" characterset="C0N300B0" base14-font="TimesItalic"/>
<afp-raster-font size="14" characterset="C0N300D0" base14-font="TimesItalic"/>
<afp-raster-font size="16" characterset="C0N300F0" base14-font="TimesItalic"/>
<afp-raster-font size="18" characterset="C0N300H0" base14-font="TimesItalic"/>
<afp-raster-font size="20" characterset="C0N300J0" base14-font="TimesItalic"/>
<afp-raster-font size="24" characterset="C0N300N0" base14-font="TimesItalic"/>
<afp-raster-font size="30" characterset="C0N300T0" base14-font="TimesItalic"/>
<afp-raster-font size="36" characterset="C0N300Z0" base14-font="TimesItalic"/>
</afp-font>
<font-triplet name="Times" style="italic" weight="normal"/>
<font-triplet name="TimesRoman" style="italic" weight="normal"/>
<font-triplet name="Times Roman" style="italic" weight="normal"/>
<font-triplet name="Times-Roman" style="italic" weight="normal"/>
<font-triplet name="Times New Roman" style="italic" weight="normal"/>
<font-triplet name="TimesNewRoman" style="italic" weight="normal"/>
<font-triplet name="serif" style="italic" weight="normal"/>
</font>
<!-- Times Roman Bold -->
<font>
<afp-font name="Times Roman Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0N40060" base14-font="TimesBold"/>
<afp-raster-font size="7" characterset="C0N40070" base14-font="TimesBold"/>
<afp-raster-font size="8" characterset="C0N40080" base14-font="TimesBold"/>
<afp-raster-font size="9" characterset="C0N40090" base14-font="TimesBold"/>
<afp-raster-font size="10" characterset="C0N40000" base14-font="TimesBold"/>
<afp-raster-font size="11" characterset="C0N400A0" base14-font="TimesBold"/>
<afp-raster-font size="12" characterset="C0N400B0" base14-font="TimesBold"/>
<afp-raster-font size="14" characterset="C0N400D0" base14-font="TimesBold"/>
<afp-raster-font size="16" characterset="C0N400F0" base14-font="TimesBold"/>
<afp-raster-font size="18" characterset="C0N400H0" base14-font="TimesBold"/>
<afp-raster-font size="20" characterset="C0N400J0" base14-font="TimesBold"/>
<afp-raster-font size="24" characterset="C0N400N0" base14-font="TimesBold"/>
<afp-raster-font size="30" characterset="C0N400T0" base14-font="TimesBold"/>
<afp-raster-font size="36" characterset="C0N400Z0" base14-font="TimesBold"/>
</afp-font>
<font-triplet name="Times" style="normal" weight="bold"/>
<font-triplet name="TimesRoman" style="normal" weight="bold"/>
<font-triplet name="Times Roman" style="normal" weight="bold"/>
<font-triplet name="Times-Roman" style="normal" weight="bold"/>
<font-triplet name="Times New Roman" style="normal" weight="bold"/>
<font-triplet name="TimesNewRoman" style="normal" weight="bold"/>
<font-triplet name="serif" style="normal" weight="bold"/>
</font>

<!-- Times Roman Italic Bold -->
<font>
<afp-font name="Times Roman Italic Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0N50060" base14-font="TimesBoldItalic"/>
<afp-raster-font size="7" characterset="C0N50070" base14-font="TimesBoldItalic"/>
<afp-raster-font size="8" characterset="C0N50080" base14-font="TimesBoldItalic"/>
<afp-raster-font size="9" characterset="C0N50090" base14-font="TimesBoldItalic"/>
<afp-raster-font size="10" characterset="C0N50000" base14-font="TimesBoldItalic"/>
<afp-raster-font size="11" characterset="C0N500A0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="12" characterset="C0N500B0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="14" characterset="C0N500D0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="16" characterset="C0N500F0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="18" characterset="C0N500H0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="20" characterset="C0N500J0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="24" characterset="C0N500N0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="30" characterset="C0N500T0" base14-font="TimesBoldItalic"/>
<afp-raster-font size="36" characterset="C0N500Z0" base14-font="TimesBoldItalic"/>
</afp-font>
<font-triplet name="Times" style="italic" weight="bold"/>
<font-triplet name="TimesRoman" style="italic" weight="bold"/>
<font-triplet name="Times Roman" style="italic" weight="bold"/>
<font-triplet name="Times-Roman" style="italic" weight="bold"/>
<font-triplet name="Times New Roman" style="italic" weight="bold"/>
<font-triplet name="TimesNewRoman" style="italic" weight="bold"/>
<font-triplet name="serif" style="italic" weight="bold"/>
</font>

<!-- Helvetica -->
<font>
<afp-font name="Helvetica" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0H20060" base14-font="Helvetica"/>
<afp-raster-font size="7" characterset="C0H20070" base14-font="Helvetica"/>
<afp-raster-font size="8" characterset="C0H20080" base14-font="Helvetica"/>
<afp-raster-font size="9" characterset="C0H20090" base14-font="Helvetica"/>
<afp-raster-font size="10" characterset="C0H20000" base14-font="Helvetica"/>
<afp-raster-font size="11" characterset="C0H200A0" base14-font="Helvetica"/>
<afp-raster-font size="12" characterset="C0H200B0" base14-font="Helvetica"/>
<afp-raster-font size="14" characterset="C0H200D0" base14-font="Helvetica"/>
<afp-raster-font size="16" characterset="C0H200F0" base14-font="Helvetica"/>
<afp-raster-font size="18" characterset="C0H200H0" base14-font="Helvetica"/>
<afp-raster-font size="20" characterset="C0H200J0" base14-font="Helvetica"/>
<afp-raster-font size="24" characterset="C0H200N0" base14-font="Helvetica"/>
<afp-raster-font size="30" characterset="C0H200T0" base14-font="Helvetica"/>
<afp-raster-font size="36" characterset="C0H200Z0" base14-font="Helvetica"/>
</afp-font>
<font-triplet name="Helvetica" style="normal" weight="normal"/>
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="sans-serif" style="normal" weight="normal"/>
<font-triplet name="any" style="normal" weight="normal"/>
</font>

<!-- Helvetica Italic -->
<font>
<afp-font name="Helvetica Italic" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0H30060" base14-font="HelveticaOblique"/>
<afp-raster-font size="7" characterset="C0H30070" base14-font="HelveticaOblique"/>
<afp-raster-font size="8" characterset="C0H30080" base14-font="HelveticaOblique"/>
<afp-raster-font size="9" characterset="C0H30090" base14-font="HelveticaOblique"/>
<afp-raster-font size="10" characterset="C0H30000" base14-font="HelveticaOblique"/>
<afp-raster-font size="11" characterset="C0H300A0" base14-font="HelveticaOblique"/>
<afp-raster-font size="12" characterset="C0H300B0" base14-font="HelveticaOblique"/>
<afp-raster-font size="14" characterset="C0H300D0" base14-font="HelveticaOblique"/>
<afp-raster-font size="16" characterset="C0H300F0" base14-font="HelveticaOblique"/>
<afp-raster-font size="18" characterset="C0H300H0" base14-font="HelveticaOblique"/>
<afp-raster-font size="20" characterset="C0H300J0" base14-font="HelveticaOblique"/>
<afp-raster-font size="24" characterset="C0H300N0" base14-font="HelveticaOblique"/>
<afp-raster-font size="30" characterset="C0H300T0" base14-font="HelveticaOblique"/>
<afp-raster-font size="36" characterset="C0H300Z0" base14-font="HelveticaOblique"/>
</afp-font>
<font-triplet name="Helvetica" style="italic" weight="normal"/>
<font-triplet name="Arial" style="italic" weight="normal"/>
<font-triplet name="sans-serif" style="italic" weight="normal"/>
</font>

<!-- Helvetica (Semi) Bold -->
<font>
<afp-font name="Helvetica (Semi) Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0H40060" base14-font="HelveticaBold"/>
<afp-raster-font size="7" characterset="C0H40070" base14-font="HelveticaBold"/>
<afp-raster-font size="8" characterset="C0H40080" base14-font="HelveticaBold"/>
<afp-raster-font size="9" characterset="C0H40090" base14-font="HelveticaBold"/>
<afp-raster-font size="10" characterset="C0H40000" base14-font="HelveticaBold"/>
<afp-raster-font size="11" characterset="C0H400A0" base14-font="HelveticaBold"/>
<afp-raster-font size="12" characterset="C0H400B0" base14-font="HelveticaBold"/>
<afp-raster-font size="14" characterset="C0H400D0" base14-font="HelveticaBold"/>
<afp-raster-font size="16" characterset="C0H400F0" base14-font="HelveticaBold"/>
<afp-raster-font size="18" characterset="C0H400H0" base14-font="HelveticaBold"/>
<afp-raster-font size="20" characterset="C0H400J0" base14-font="HelveticaBold"/>
<afp-raster-font size="24" characterset="C0H400N0" base14-font="HelveticaBold"/>
<afp-raster-font size="30" characterset="C0H400T0" base14-font="HelveticaBold"/>
<afp-raster-font size="36" characterset="C0H400Z0" base14-font="HelveticaBold"/>
</afp-font>
<font-triplet name="Helvetica" style="normal" weight="bold"/>
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="sans-serif" style="normal" weight="bold"/>
</font>

<!-- Helvetica Italic (Semi) Bold -->
<font>
<afp-font name="Helvetica Italic (Semi) Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0H50060" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="7" characterset="C0H50070" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="8" characterset="C0H50080" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="9" characterset="C0H50090" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="10" characterset="C0H50000" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="11" characterset="C0H500A0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="12" characterset="C0H500B0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="14" characterset="C0H500D0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="16" characterset="C0H500F0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="18" characterset="C0H500H0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="20" characterset="C0H500J0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="24" characterset="C0H500N0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="30" characterset="C0H500T0" base14-font="HelveticaBoldOblique"/>
<afp-raster-font size="36" characterset="C0H500Z0" base14-font="HelveticaBoldOblique"/>
</afp-font>
<font-triplet name="Helvetica" style="italic" weight="bold"/>
<font-triplet name="Arial" style="italic" weight="bold"/>
<font-triplet name="sans-serif" style="italic" weight="bold"/>
</font>

<!-- Courier -->
<font>
<afp-font name="Courier" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0420060" base14-font="Courier"/>
<afp-raster-font size="7" characterset="C0420070" base14-font="Courier"/>
<afp-raster-font size="8" characterset="C0420080" base14-font="Courier"/>
<afp-raster-font size="9" characterset="C0420090" base14-font="Courier"/>
<afp-raster-font size="10" characterset="C0420000" base14-font="Courier"/>
<afp-raster-font size="11" characterset="C04200A0" base14-font="Courier"/>
<afp-raster-font size="12" characterset="C04200B0" base14-font="Courier"/>
<afp-raster-font size="14" characterset="C04200D0" base14-font="Courier"/>
<afp-raster-font size="16" characterset="C04200F0" base14-font="Courier"/>
<afp-raster-font size="18" characterset="C04200H0" base14-font="Courier"/>
<afp-raster-font size="20" characterset="C04200J0" base14-font="Courier"/>
<afp-raster-font size="24" characterset="C04200N0" base14-font="Courier"/>
<afp-raster-font size="30" characterset="C04200T0" base14-font="Courier"/>
<afp-raster-font size="36" characterset="C04200Z0" base14-font="Courier"/>
</afp-font>
<font-triplet name="Courier" style="normal" weight="normal"/>
<font-triplet name="monospace" style="normal" weight="normal"/>
</font>

<!-- Courier Italic -->
<font>
<afp-font name="Courier Italic" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0430060" base14-font="CourierOblique"/>
<afp-raster-font size="7" characterset="C0430070" base14-font="CourierOblique"/>
<afp-raster-font size="8" characterset="C0430080" base14-font="CourierOblique"/>
<afp-raster-font size="9" characterset="C0430090" base14-font="CourierOblique"/>
<afp-raster-font size="10" characterset="C0430000" base14-font="CourierOblique"/>
<afp-raster-font size="11" characterset="C04300A0" base14-font="CourierOblique"/>
<afp-raster-font size="12" characterset="C04300B0" base14-font="CourierOblique"/>
<afp-raster-font size="14" characterset="C04300D0" base14-font="CourierOblique"/>
<afp-raster-font size="16" characterset="C04300F0" base14-font="CourierOblique"/>
<afp-raster-font size="18" characterset="C04300H0" base14-font="CourierOblique"/>
<afp-raster-font size="20" characterset="C04300J0" base14-font="CourierOblique"/>
<afp-raster-font size="24" characterset="C04300N0" base14-font="CourierOblique"/>
<afp-raster-font size="30" characterset="C04300T0" base14-font="CourierOblique"/>
<afp-raster-font size="36" characterset="C04300Z0" base14-font="CourierOblique"/>
</afp-font>
<font-triplet name="Courier" style="italic" weight="normal"/>
<font-triplet name="monospace" style="italic" weight="normal"/>
</font>

<!-- Courier Bold -->
<font>
<afp-font name="Courier Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0440060" base14-font="CourierBold"/>
<afp-raster-font size="7" characterset="C0440070" base14-font="CourierBold"/>
<afp-raster-font size="8" characterset="C0440080" base14-font="CourierBold"/>
<afp-raster-font size="9" characterset="C0440090" base14-font="CourierBold"/>
<afp-raster-font size="10" characterset="C0440000" base14-font="CourierBold"/>
<afp-raster-font size="11" characterset="C04400A0" base14-font="CourierBold"/>
<afp-raster-font size="12" characterset="C04400B0" base14-font="CourierBold"/>
<afp-raster-font size="14" characterset="C04400D0" base14-font="CourierBold"/>
<afp-raster-font size="16" characterset="C04400F0" base14-font="CourierBold"/>
<afp-raster-font size="18" characterset="C04400H0" base14-font="CourierBold"/>
<afp-raster-font size="20" characterset="C04400J0" base14-font="CourierBold"/>
<afp-raster-font size="24" characterset="C04400N0" base14-font="CourierBold"/>
<afp-raster-font size="30" characterset="C04400T0" base14-font="CourierBold"/>
<afp-raster-font size="36" characterset="C04400Z0" base14-font="CourierBold"/>
</afp-font>
<font-triplet name="Courier" style="normal" weight="bold"/>
<font-triplet name="monospace" style="normal" weight="bold"/>
</font>

<!-- Courier Italic Bold -->
<font>
<afp-font name="Courier Italic Bold" type="raster" codepage="T1V10500" encoding="Cp500">
<afp-raster-font size="6" characterset="C0450060" base14-font="CourierBoldOblique"/>
<afp-raster-font size="7" characterset="C0450070" base14-font="CourierBoldOblique"/>
<afp-raster-font size="8" characterset="C0450080" base14-font="CourierBoldOblique"/>
<afp-raster-font size="9" characterset="C0450090" base14-font="CourierBoldOblique"/>
<afp-raster-font size="10" characterset="C0450000" base14-font="CourierBoldOblique"/>
<afp-raster-font size="11" characterset="C04500A0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="12" characterset="C04500B0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="14" characterset="C04500D0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="16" characterset="C04500F0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="18" characterset="C04500H0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="20" characterset="C04500J0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="24" characterset="C04500N0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="30" characterset="C04500T0" base14-font="CourierBoldOblique"/>
<afp-raster-font size="36" characterset="C04500Z0" base14-font="CourierBoldOblique"/>
</afp-font>
<font-triplet name="Courier" style="italic" weight="bold"/>
<font-triplet name="monospace" style="italic" weight="bold"/>
</font>
<!--
Configure double-byte (CID Keyed font (Type 0)) AFP fonts with type="CIDKeyed".
example:
<font>
<afp-font type="CIDKeyed" encoding="UnicodeBigUnmarked"
codepage="T1120000" characterset="CZJHMNU"
base-uri="fonts" />
<font-triplet name="J-Heisei Mincho" style="normal" weight="normal" />
</font>
-->
</fonts>
</renderer>

<renderer mime="application/postscript">
<!-- This option forces the PS renderer to rotate landscape pages -->
<!--auto-rotate-landscape>true</auto-rotate-landscape-->
<!-- This option lets you specify additional options on an XML handler -->
<!--xml-handler namespace="http://www.w3.org/2000/svg">
<stroke-text>false</stroke-text>
</xml-handler-->
</renderer>

<renderer mime="application/vnd.hp-PCL">
</renderer>

<!-- MIF does not have a renderer
<renderer mime="application/vnd.mif">
</renderer>
-->

<renderer mime="image/svg+xml">
<format type="paginated"/>
<link value="true"/>
<strokeText value="false"/>
</renderer>

<renderer mime="application/awt">
</renderer>

<renderer mime="image/png">
<!--transparent-page-background>true</transparent-page-background-->
</renderer>

<renderer mime="image/tiff">
<!--transparent-page-background>true</transparent-page-background-->
<!--compression>CCITT T.6</compression-->
</renderer>

<renderer mime="text/xml">
</renderer>

<!-- RTF does not have a renderer
<renderer mime="text/rtf">
</renderer>
-->

</renderers>

</fop>

+ 17
- 0
examples/embedding/README View File

@@ -0,0 +1,17 @@
FOP Embedding Examples Readme
This directory contains several examples on using FOP in Java.
To compile the examples you can call "ant" from the directory where
build.xml is found. (Apache Ant must be installed!)
You can also directly run the individual examples with these scripts.
Just call
ant -projecthelp
for a listing of all available examples.
Please go to the page indicated below to find more information:
http://xmlgraphics.apache.org/fop/embedding.html

+ 158
- 0
examples/embedding/build.xml View File

@@ -0,0 +1,158 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<project default="compile" basedir=".">
<property name="Name" value="Apache FOP - Embedding Examples"/>
<property name="name" value="embedding"/>
<!-- compiler switches -->
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="on"/>
<!-- directories -->
<property name="src.dir" value="./java"/>
<property name="fop.lib.dir" value="../../lib"/>
<property name="lib.dir" value="./lib"/>
<property name="build.dir" value="./build"/>
<property name="build.src" value="./build/src"/>
<property name="build.dest" value="./build/classes"/>
<!-- stuff -->
<path id="project.class.path">
<fileset dir="${fop.lib.dir}">
<include name="batik*.jar"/>
<include name="xml-apis*.jar"/>
<include name="xerces*.jar"/>
<include name="xalan*.jar"/>
<include name="serializer*.jar"/>
<include name="commons-io*.jar"/>
<include name="commons-logging*.jar"/>
<include name="xmlgraphics-commons*.jar"/>
</fileset>
<fileset dir="${fop.lib.dir}/../build">
<include name="fop.jar"/>
</fileset>
</path>
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<target name="init">
<tstamp/>
<property name="year" value="2002-2004,2006"/>
<echo message="------------------- ${Name} [${year}] ----------------"/>
</target>
<!-- =================================================================== -->
<!-- Prepares the build directory -->
<!-- =================================================================== -->
<target name="prepare" depends="init">
<!-- create directories -->
<echo message="Preparing the build directories"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dest}"/>
</target>
<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile" depends="prepare" description="Compiles the examples">
<echo message="Compiling the sources"/>
<javac srcdir="${src.dir}" destdir="${build.dest}" debug="${debug}" deprecation="${deprecation}" optimize="${optimize}" includeAntRuntime="true">
<classpath refid="project.class.path"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- Runs the various examples -->
<!-- =================================================================== -->
<target name="example1" depends="compile" description="Runs the FO to PDF example">
<echo message="Running the FO to PDF example"/>
<java classname="${name}.ExampleFO2PDF" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example2" depends="compile" description="Runs the FO to PDF example using a SAXParser">
<echo message="Running the FO to PDF example using a SAXParser"/>
<java classname="${name}.ExampleFO2PDFUsingSAXParser" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example3" depends="compile" description="Runs the XML to FO example">
<echo message="Running the XML to FO example"/>
<java classname="${name}.ExampleXML2FO" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example4" depends="compile" description="Runs the XML to PDF example">
<echo message="Running the XML to PDF example"/>
<java classname="${name}.ExampleXML2PDF" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example5" depends="compile" description="Runs the Object to XML example">
<echo message="Running the Object to XML example"/>
<java classname="${name}.ExampleObj2XML" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example6" depends="compile" description="Runs the Object to PDF example">
<echo message="Running the Object to PDF example"/>
<java classname="${name}.ExampleObj2PDF" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example7" depends="compile" description="Runs the DOM to PDF example">
<echo message="Running the DOM to PDF example"/>
<java classname="${name}.ExampleDOM2PDF" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
</java>
</target>
<target name="example8" depends="compile" description="Runs the SVG to PDF example">
<echo message="Running the SVG to PDF example"/>
<java classname="${name}.ExampleSVG2PDF" fork="yes">
<classpath>
<path refid="project.class.path"/>
<pathelement location="${build.dest}"/>
</classpath>
<jvmarg value="-Xmx1024m"/>
</java>
</target>
<target name="run" depends="example1,example2,example3,example4,example5,example5,example7,example8" description="Runs examples"/>
<!-- =================================================================== -->
<!-- Clean targets -->
<!-- =================================================================== -->
<target name="clean" depends="init" description="Cleans the build directory">
<delete dir="${build.dir}"/>
</target>
</project>

+ 108
- 0
examples/embedding/java/embedding/ExampleAWTViewer.java View File

@@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

//Java
import java.io.File;
import java.io.IOException;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the use of the AWT Viewer.
*/
public class ExampleAWTViewer {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Display an FO file in the AWT Preview.
* @param fo the FO file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a problem during layout
* @throws TransformerException In case of a problem during XML processing
*/
public void viewFO(File fo)
throws IOException, FOPException, TransformerException {

//Setup FOP
Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AWT_PREVIEW);

try {

//Load XSL-FO file (you can also do an XSL transformation here)
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(fo);
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);

} catch (Exception e) {
if (e instanceof FOPException) {
throw (FOPException)e;
}
throw new FOPException(e);
}
}

/**
* Main method.
* @param args the command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleAWTViewer\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: AWT Viewer");
System.out.println();
System.out.println("Starting AWT Viewer...");

ExampleAWTViewer app = new ExampleAWTViewer();
app.viewFO(fofile);

System.out.println("Success!");
} catch (Exception e) {
// System.err.println(ExceptionUtil.printStackTrace(e));
System.exit(-1);
}
}
}

+ 190
- 0
examples/embedding/java/embedding/ExampleDOM2PDF.java View File

@@ -0,0 +1,190 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.File;
import java.io.OutputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;


/**
* This class demonstrates the conversion of a DOM Document to PDF
* using JAXP (XSLT) and FOP (XSL-FO).
*/
public class ExampleDOM2PDF {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/** xsl-fo namespace URI */
protected static String foNS = "http://www.w3.org/1999/XSL/Format";

/**
* Converts a DOM Document to a PDF file using FOP.
* @param xslfoDoc the DOM Document
* @param pdf the target PDF file
*/
public void convertDOM2PDF(Document xslfoDoc, File pdf) {
try {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
out = new java.io.BufferedOutputStream(out);

try {
// Construct fop with desired output format and output stream
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup Identity Transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input for XSLT transformation
Source src = new DOMSource(xslfoDoc);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}

}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleDOM2PDF\n");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup output file
File pdffile = new File(outDir, "ResultDOM2PDF.pdf");
System.out.println("PDF Output File: " + pdffile);
System.out.println();

Document foDoc = buildDOMDocument();

ExampleDOM2PDF app = new ExampleDOM2PDF();
app.convertDOM2PDF(foDoc, pdffile);

System.out.println("Success!");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}

/**
* Builds the example FO document as a DOM in memory.
* @return the FO document
* @throws ParserConfigurationException In case there is a problem creating a DOM document
*/
private static Document buildDOMDocument() throws ParserConfigurationException {
// Create a sample XSL-FO DOM document
Document foDoc = null;
Element root = null, ele1 = null, ele2 = null, ele3 = null;

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
foDoc = db.newDocument();

root = foDoc.createElementNS(foNS, "fo:root");
foDoc.appendChild(root);

ele1 = foDoc.createElementNS(foNS, "fo:layout-master-set");
root.appendChild(ele1);
ele2 = foDoc.createElementNS(foNS, "fo:simple-page-master");
ele1.appendChild(ele2);
ele2.setAttributeNS(null, "master-name", "letter");
ele2.setAttributeNS(null, "page-height", "11in");
ele2.setAttributeNS(null, "page-width", "8.5in");
ele2.setAttributeNS(null, "margin-top", "1in");
ele2.setAttributeNS(null, "margin-bottom", "1in");
ele2.setAttributeNS(null, "margin-left", "1in");
ele2.setAttributeNS(null, "margin-right", "1in");
ele3 = foDoc.createElementNS(foNS, "fo:region-body");
ele2.appendChild(ele3);
ele1 = foDoc.createElementNS(foNS, "fo:page-sequence");
root.appendChild(ele1);
ele1.setAttributeNS(null, "master-reference", "letter");
ele2 = foDoc.createElementNS(foNS, "fo:flow");
ele1.appendChild(ele2);
ele2.setAttributeNS(null, "flow-name", "xsl-region-body");
addElement(ele2, "fo:block", "Hello World!");
return foDoc;
}

/**
* Adds an element to the DOM.
* @param parent parent node to attach the new element to
* @param newNodeName name of the new node
* @param textVal content of the element
*/
protected static void addElement(Node parent, String newNodeName,
String textVal) {
if (textVal == null) {
return;
} // use only with text nodes
Element newElement = parent.getOwnerDocument().createElementNS(
foNS, newNodeName);
Text elementText = parent.getOwnerDocument().createTextNode(textVal);
newElement.appendChild(elementText);
parent.appendChild(newElement);
}
}


+ 64
- 0
examples/embedding/java/embedding/ExampleEPS.java View File

@@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */


package embedding;

import java.awt.Font;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

import org.apache.fop.configuration.Configuration;
import org.apache.fop.configuration.DefaultConfigurationBuilder;
import org.apache.xmlgraphics.java2d.GraphicContext;
import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;

import org.apache.fop.fonts.FontInfo;
import org.apache.fop.render.ps.NativeTextHandler;
import org.apache.fop.svg.PDFDocumentGraphics2DConfigurator;

public class ExampleEPS {

/**
* @param args
*/
public static void main(String[] args) {
try {
String configFile = "examples/fop-eps.xconf";
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration c = cfgBuilder.buildFromFile(new File(configFile));

FontInfo fontInfo = PDFDocumentGraphics2DConfigurator.createFontInfo(c, false);

OutputStream out = new FileOutputStream("example_eps.eps");
EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new GraphicContext());
g2d.setCustomTextHandler(new NativeTextHandler(g2d, fontInfo));
g2d.setupDocument(out, 200, 100);
g2d.setFont(new Font("Arial", Font.PLAIN, 12));
g2d.drawString("Hi there Arial", 50, 50);
g2d.finish();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}

}

+ 52
- 0
examples/embedding/java/embedding/ExampleEPSSimple.java View File

@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

import java.awt.Font;
import java.io.FileOutputStream;
import java.io.OutputStream;

import org.apache.xmlgraphics.java2d.GraphicContext;
import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D;

import org.apache.fop.render.ps.NativeTextHandler;

public class ExampleEPSSimple {

/**
* @param args
*/
public static void main(String[] args) {
try {
OutputStream out = new FileOutputStream("example_eps_simple.eps");
EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new GraphicContext());
g2d.setCustomTextHandler(new NativeTextHandler(g2d, null));
g2d.setupDocument(out, 200, 100);
g2d.setFont(new Font("Helvetica", Font.PLAIN, 12));
g2d.drawString("Hi there Helvetica", 50, 50);
g2d.finish();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}

}

+ 142
- 0
examples/embedding/java/embedding/ExampleFO2JPSPrint.java View File

@@ -0,0 +1,142 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.File;
import java.io.IOException;

import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.SimpleDoc;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.render.print.PageableRenderer;

/**
* This class demonstrates printing an FO file using JPS (Java Printing System).
*/
public class ExampleFO2JPSPrint {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

private DocPrintJob createDocPrintJob() {
PrintService[] services = PrintServiceLookup.lookupPrintServices(
DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
PrintService printService = ServiceUI.printDialog(null, 50, 50,
services, services[0], null, attributes);
if (printService != null) {
return printService.createPrintJob();
} else {
return null;
}
}

/**
* Prints an FO file using JPS.
* @param fo the FO file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
* @throws TransformerException In case of a problem during XSLT processing
* @throws PrintException If an error occurs while printing
*/
public void printFO(File fo)
throws IOException, FOPException, TransformerException, PrintException {

//Set up DocPrintJob instance
DocPrintJob printJob = createDocPrintJob();

//Set up a custom user agent so we can supply our own renderer instance
FOUserAgent userAgent = fopFactory.newFOUserAgent();

PageableRenderer renderer = new PageableRenderer(userAgent);
userAgent.setRendererOverride(renderer);

// Construct FOP with desired output format
Fop fop = fopFactory.newFop(userAgent);

// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
printJob.print(doc, null);
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleFO2JPSPrint\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: JPS (Java Printing System)");
System.out.println();
System.out.println("Transforming...");

ExampleFO2JPSPrint app = new ExampleFO2JPSPrint();
app.printFO(fofile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 119
- 0
examples/embedding/java/embedding/ExampleFO2OldStylePrint.java View File

@@ -0,0 +1,119 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates printing an FO file to a PrinterJob instance.
*/
public class ExampleFO2OldStylePrint {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Prints an FO file using an old-style PrinterJob.
* @param fo the FO file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
*/
public void printFO(File fo) throws IOException, FOPException {

//Set up PrinterJob instance
PrinterJob printerJob = PrinterJob.getPrinterJob();
printerJob.setJobName("FOP Printing Example");

try {
//Set up a custom user agent so we can supply our own renderer instance
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.getRendererOptions().put("printerjob", printerJob);

// Construct FOP with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_PRINT, userAgent);

// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleFO2OldStylePrint\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: old-style printing using PrinterJob");
System.out.println();
System.out.println("Transforming...");

ExampleFO2OldStylePrint app = new ExampleFO2OldStylePrint();
app.printFO(fofile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 142
- 0
examples/embedding/java/embedding/ExampleFO2PDF.java View File

@@ -0,0 +1,142 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FormattingResults;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PageSequenceResults;

/**
* This class demonstrates the conversion of an FO file to PDF using FOP.
*/
public class ExampleFO2PDF {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Converts an FO file to a PDF file using FOP
* @param fo the FO file
* @param pdf the target PDF file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
*/
public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException {

OutputStream out = null;

try {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);

// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

// Result processing
FormattingResults foResults = fop.getResults();
java.util.List pageSequences = foResults.getPageSequences();
for (Object pageSequence : pageSequences) {
PageSequenceResults pageSequenceResults = (PageSequenceResults) pageSequence;
System.out.println("PageSequence "
+ (String.valueOf(pageSequenceResults.getID()).length() > 0
? pageSequenceResults.getID() : "<no id>")
+ " generated " + pageSequenceResults.getPageCount() + " pages.");
}
System.out.println("Generated " + foResults.getPageCount() + " pages in total.");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
} finally {
out.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleFO2PDF\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");
//File fofile = new File(baseDir, "../fo/pagination/franklin_2pageseqs.fo");
File pdffile = new File(outDir, "ResultFO2PDF.pdf");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleFO2PDF app = new ExampleFO2PDF();
app.convertFO2PDF(fofile, pdffile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 133
- 0
examples/embedding/java/embedding/ExampleFO2PDFUsingSAXParser.java View File

@@ -0,0 +1,133 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an FO file to PDF using FOP.
* It uses a SAXParser with FOP as the DefaultHandler
*/
public class ExampleFO2PDFUsingSAXParser {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Converts an FO file to a PDF file using FOP
* @param fo the FO file
* @param pdf the target PDF file
* @throws FactoryConfigurationError In case of a problem with the JAXP factory configuration
* @throws ParserConfigurationException In case of a problem with the parser configuration
* @throws SAXException In case of a problem during XML processing
* @throws IOException In case of an I/O problem
*/
public void convertFO2PDF(File fo, File pdf)
throws FactoryConfigurationError,
ParserConfigurationException,
SAXException, IOException {

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

OutputStream out = null;

try {
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);

// Construct fop and setup output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup SAX parser
// throws FactoryConfigurationError
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
// throws ParserConfigurationException
SAXParser parser = factory.newSAXParser();

// Obtain FOP's DefaultHandler
// throws FOPException
DefaultHandler dh = fop.getDefaultHandler();

// Start parsing and FOP processing
// throws SAXException, IOException
parser.parse(fo, dh);

} finally {
out.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleFO2PDFUsingSAXParser\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");
File pdffile = new File(outDir, "ResultFO2PDFUsingSAXParser.pdf");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleFO2PDFUsingSAXParser app = new ExampleFO2PDFUsingSAXParser();
app.convertFO2PDF(fofile, pdffile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}


+ 135
- 0
examples/embedding/java/embedding/ExampleFO2RTF.java View File

@@ -0,0 +1,135 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an FO file to RTF using FOP.
* <p>
* Please note that this is practically the same as the ExampleFO2PDF example. Only
* the MIME parameter to the newFop() method is different!
*/
public class ExampleFO2RTF {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Converts an FO file to a RTF file using FOP
* @param fo the FO file
* @param rtf the target RTF file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
*/
public void convertFO2RTF(File fo, File rtf) throws IOException, FOPException {

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

OutputStream out = null;

try {
// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(rtf);
out = new BufferedOutputStream(out);

// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, out);

// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

// Please note: getResults() won't work for RTF and other flow formats (like MIF)
// as the layout engine is not involved in the conversion. The page-breaking
// is done by the application opening the generated file (like MS Word).
//FormattingResults foResults = fop.getResults();

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
} finally {
out.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleFO2RTF\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File fofile = new File(baseDir, "xml/fo/helloworld.fo");
File rtffile = new File(outDir, "ResultFO2RTF.rtf");

System.out.println("Input: XSL-FO (" + fofile + ")");
System.out.println("Output: PDF (" + rtffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleFO2RTF app = new ExampleFO2RTF();
app.convertFO2RTF(fofile, rtffile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 182
- 0
examples/embedding/java/embedding/ExampleJava2D2PDF.java View File

@@ -0,0 +1,182 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;

import javax.swing.JEditorPane;

import org.apache.commons.io.IOUtils;

import org.apache.xmlgraphics.util.UnitConv;

import org.apache.fop.configuration.Configuration;
import org.apache.fop.configuration.ConfigurationException;
import org.apache.fop.configuration.DefaultConfiguration;
import org.apache.fop.svg.PDFDocumentGraphics2D;
import org.apache.fop.svg.PDFDocumentGraphics2DConfigurator;

/**
* This example class demonstrates the use of {@link PDFDocumentGraphics2D} that can be
* used to create a PDF file from Java2D graphics (using the {@link Graphics2D} API).
*/
public class ExampleJava2D2PDF {

private Configuration createAutoFontsConfiguration() {
//Create a default configuration using auto-detection of fonts.
//This can be a bit slow but covers most use cases.
DefaultConfiguration c = new DefaultConfiguration("cfg");
DefaultConfiguration fonts = new DefaultConfiguration("fonts");
c.addChild(fonts);
DefaultConfiguration autodetect = new DefaultConfiguration("auto-detect");
fonts.addChild(autodetect);
return c;

/* You can also load the configuration from a file:
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
return cfgBuilder.buildFromFile(configFile);
*/
}

private void configure(PDFDocumentGraphics2D g2d, Configuration cfg)
throws ConfigurationException {

PDFDocumentGraphics2DConfigurator configurator = new PDFDocumentGraphics2DConfigurator();
boolean useComplexScriptFeatures = false;
configurator.configure(g2d, cfg, useComplexScriptFeatures);
}

/**
* Creates a PDF file. The contents are painted using a Graphics2D implementation that
* generates an PDF file.
* @param outputFile the target file
* @throws IOException In case of an I/O error
* @throws ConfigurationException if an error occurs configuring the PDF output
*/
public void generatePDF(File outputFile) throws IOException, ConfigurationException {
OutputStream out = new java.io.FileOutputStream(outputFile);
out = new java.io.BufferedOutputStream(out);
try {

//Instantiate the PDFDocumentGraphics2D instance
PDFDocumentGraphics2D g2d = new PDFDocumentGraphics2D(false);
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());

//Configure the G2D with the necessary fonts
configure(g2d, createAutoFontsConfiguration());

//Set up the document size
Dimension pageSize = new Dimension(
(int)Math.ceil(UnitConv.mm2pt(210)),
(int)Math.ceil(UnitConv.mm2pt(297))); //page size A4 (in pt)
g2d.setupDocument(out, pageSize.width, pageSize.height);
g2d.translate(144, 72); //Establish some page borders

//A few rectangles rotated and with different color
Graphics2D copy = (Graphics2D)g2d.create();
int c = 12;
for (int i = 0; i < c; i++) {
float f = ((i + 1) / (float)c);
Color col = new Color(0.0f, 1 - f, 0.0f);
copy.setColor(col);
copy.fillRect(70, 90, 50, 50);
copy.rotate(-2 * Math.PI / c, 70, 90);
}
copy.dispose();

//Some text
g2d.rotate(-0.25);
g2d.setColor(Color.RED);
g2d.setFont(new Font("sans-serif", Font.PLAIN, 36));
g2d.drawString("Hello world!", 140, 140);
g2d.setColor(Color.RED.darker());
g2d.setFont(new Font("serif", Font.PLAIN, 36));
g2d.drawString("Hello world!", 140, 180);

pageSize = new Dimension(pageSize.height, pageSize.width);
g2d.nextPage(pageSize.width, pageSize.height);

//Demonstrate painting rich text
String someHTML = "<html><body style=\"font-family:Verdana\">"
+ "<p>Welcome to <b>page 2!</b></p>"
+ "<h2>PDFDocumentGraphics2D Demonstration</h2>"
+ "<p>We can <i>easily</i> paint some HTML here!</p>"
+ "<p style=\"color:green;\">"
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin accumsan"
+ " condimentum ullamcorper. Sed varius quam id arcu fermentum luctus. Praesent"
+ " nisi ligula, cursus sed vestibulum vel, sodales sed lectus.</p>"
+ "</body></html>";
JEditorPane htmlComp = new JEditorPane();
htmlComp.setContentType("text/html");
htmlComp.read(new StringReader(someHTML), null);
htmlComp.setSize(new Dimension(pageSize.width - 72, pageSize.height - 72));
//htmlComp.setBackground(Color.ORANGE);
htmlComp.validate();
htmlComp.printAll(g2d);

//Cleanup
g2d.finish();
} finally {
IOUtils.closeQuietly(out);
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP " + ExampleJava2D2PDF.class.getSimpleName() + "\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
if (!outDir.isDirectory()) {
if (!outDir.mkdirs()) {
throw new IOException("Could not create output directory: " + outDir);
}
}

//Setup output file
File pdffile = new File(outDir, "ResultJava2D2PDF.pdf");

System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Generating...");

ExampleJava2D2PDF app = new ExampleJava2D2PDF();
app.generatePDF(pdffile);

System.out.println("Success!");
} catch (Throwable t) {
t.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 125
- 0
examples/embedding/java/embedding/ExampleObj2PDF.java View File

@@ -0,0 +1,125 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

import embedding.model.ProjectTeam;

/**
* This class demonstrates the conversion of an arbitrary object file to a
* PDF using JAXP (XSLT) and FOP (XSL:FO).
*/
public class ExampleObj2PDF {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Converts a ProjectTeam object to a PDF file.
* @param team the ProjectTeam object
* @param xslt the stylesheet file
* @param pdf the target PDF file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
* @throws TransformerException In case of a XSL transformation problem
*/
public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf)
throws IOException, FOPException, TransformerException {

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
out = new java.io.BufferedOutputStream(out);
try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslt));

// Setup input for XSLT transformation
Source src = team.getSourceForProjectTeam();

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleObj2PDF\n");
System.out.println("Preparing...");

// Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

// Setup input and output
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File pdffile = new File(outDir, "ResultObj2PDF.pdf");

System.out.println("Input: a ProjectTeam object");
System.out.println("Stylesheet: " + xsltfile);
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleObj2PDF app = new ExampleObj2PDF();
app.convertProjectTeam2PDF(ExampleObj2XML.createSampleProjectTeam(), xsltfile, pdffile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 123
- 0
examples/embedding/java/embedding/ExampleObj2XML.java View File

@@ -0,0 +1,123 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

//Hava
import java.io.File;
import java.io.IOException;

//JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;

import embedding.model.ProjectMember;
import embedding.model.ProjectTeam;


/**
* This class demonstrates the conversion of an arbitrary object file to an
* XML file.
*/
public class ExampleObj2XML {

/**
* Converts a ProjectTeam object to XML.
* @param team the ProjectTeam object
* @param xml the target XML file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
*/
public void convertProjectTeam2XML(ProjectTeam team, File xml)
throws IOException, TransformerException {

//Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
/* Note:
We use the identity transformer, no XSL transformation is done.
The transformer is basically just used to serialize the
generated document to XML. */

//Setup input
Source src = team.getSourceForProjectTeam();

//Setup output
Result res = new StreamResult(xml);

//Start XSLT transformation
transformer.transform(src, res);
}


/**
* Creates a sample ProjectTeam instance for this demo.
* @return ProjectTeam the newly created ProjectTeam instance
*/
public static ProjectTeam createSampleProjectTeam() {
ProjectTeam team = new ProjectTeam();
team.setProjectName("Rule the Galaxy");
team.addMember(new ProjectMember(
"Emperor Palpatine", "lead", "palpatine@empire.gxy"));
team.addMember(new ProjectMember(
"Lord Darth Vader", "Jedi-Killer", "vader@empire.gxy"));
team.addMember(new ProjectMember(
"Grand Moff Tarkin", "Planet-Killer", "tarkin@empire.gxy"));
team.addMember(new ProjectMember(
"Admiral Motti", "Death Star operations", "motti@empire.gxy"));
return team;
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleObj2XML\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output
File xmlfile = new File(outDir, "ResultObj2XML.xml");

System.out.println("Input: a ProjectTeam object");
System.out.println("Output: XML (" + xmlfile + ")");
System.out.println();
System.out.println("Serializing...");

ExampleObj2XML app = new ExampleObj2XML();
app.convertProjectTeam2XML(createSampleProjectTeam(), xmlfile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 109
- 0
examples/embedding/java/embedding/ExampleSVG2PDF.java View File

@@ -0,0 +1,109 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

//Java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

//Batik
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;

//FOP
import org.apache.fop.svg.PDFTranscoder;

/**
* This class demonstrates the conversion of an SVG file to PDF using FOP.
*/
public class ExampleSVG2PDF {

/**
* Converts an FO file to a PDF file using FOP
* @param svg the SVG file
* @param pdf the target PDF file
* @throws IOException In case of an I/O problem
* @throws TranscoderException In case of a transcoding problem
*/
public void convertSVG2PDF(File svg, File pdf) throws IOException, TranscoderException {

//Create transcoder
Transcoder transcoder = new PDFTranscoder();
//Transcoder transcoder = new org.apache.fop.render.ps.PSTranscoder();

//Setup input
InputStream in = new java.io.FileInputStream(svg);
try {
TranscoderInput input = new TranscoderInput(in);

//Setup output
OutputStream out = new java.io.FileOutputStream(pdf);
out = new java.io.BufferedOutputStream(out);
try {
TranscoderOutput output = new TranscoderOutput(out);

//Do the transformation
transcoder.transcode(input, output);
} finally {
out.close();
}
} finally {
in.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleSVG2PDF\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File svgfile = new File(baseDir, "xml/svg/helloworld.svg");
File pdffile = new File(outDir, "ResultSVG2PDF.pdf");

System.out.println("Input: SVG (" + svgfile + ")");
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleSVG2PDF app = new ExampleSVG2PDF();
app.convertSVG2PDF(svgfile, pdffile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 108
- 0
examples/embedding/java/embedding/ExampleXML2FO.java View File

@@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

//Java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

//JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
* This class demonstrates the conversion of an XML file to an XSL-FO file
* using JAXP (XSLT).
*/
public class ExampleXML2FO {

/**
* Converts an XML file to an XSL-FO file using JAXP (XSLT).
* @param xml the XML file
* @param xslt the stylesheet file
* @param fo the target XSL-FO file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
*/
public void convertXML2FO(File xml, File xslt, File fo)
throws IOException, TransformerException {

//Setup output
OutputStream out = new java.io.FileOutputStream(fo);
try {
//Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslt));

//Setup input for XSLT transformation
Source src = new StreamSource(xml);

//Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new StreamResult(out);

//Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
}


/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleXML2FO\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
File xmlfile = new File(baseDir, "xml/xml/projectteam.xml");
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File fofile = new File(outDir, "ResultXML2FO.fo");

System.out.println("Input: XML (" + xmlfile + ")");
System.out.println("Stylesheet: " + xsltfile);
System.out.println("Output: XSL-FO (" + fofile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleXML2FO app = new ExampleXML2FO();
app.convertXML2FO(xmlfile, xsltfile, fofile);

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 108
- 0
examples/embedding/java/embedding/ExampleXML2PDF.java View File

@@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

//Java
import java.io.File;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;

/**
* This class demonstrates the conversion of an XML file to PDF using
* JAXP (XSLT) and FOP (XSL-FO).
*/
public class ExampleXML2PDF {

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleXML2PDF\n");
System.out.println("Preparing...");

// Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

// Setup input and output files
File xmlfile = new File(baseDir, "xml/xml/projectteam.xml");
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File pdffile = new File(outDir, "ResultXML2PDF.pdf");

System.out.println("Input: XML (" + xmlfile + ")");
System.out.println("Stylesheet: " + xsltfile);
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

// configure fopFactory as desired
final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);

try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));

// Set the value of a <param> in the stylesheet
transformer.setParameter("versionParam", "2.0");

// Setup input for XSLT transformation
Source src = new StreamSource(xmlfile);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}

System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}
}

+ 174
- 0
examples/embedding/java/embedding/MultipleFO2PDF.java View File

@@ -0,0 +1,174 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding;

// Java
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.commons.io.IOUtils;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.FormattingResults;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.apps.PageSequenceResults;

/**
* This class demonstrates the conversion of multiple FO files to PDF using FOP.
* The FopFactory is reused. Its configuration is applied to each rendering run.
* The FOUserAgent and Fop are newly created by the FopFactory for each run.
* The FOUserAgent can be configured differently for each run.
*/
public class MultipleFO2PDF {

// configure fopFactory as desired
// JAXP TransformerFactory can be reused, too
private TransformerFactory factory = TransformerFactory.newInstance();

/**
* Converts an FO file to a PDF file using FOP
* @param fo the FO file
* @param pdf the target PDF file
* @throws TransformerException in case of a transformation problem
* @throws IOException in case of an I/O problem
* @throws FOPException in case of a FOP problem
* @return the formatting results of the run
*/
public FormattingResults convertFO2PDF(File fo, File pdf)
throws TransformerException, IOException, FOPException {
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

OutputStream out = null;
Fop fop;

try {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);

// Construct fop with desired output format and output stream
fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup JAXP using identity transformer
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
IOUtils.closeQuietly(out);
}

return fop.getResults();
}

/**
* Listens on standard in for names of fo files to be transformed to pdf.
* 'quit' or the null string (for piped input) cause the listener to stop listening.
*/
public void listen() {

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();
BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in));

while (true) {
try {
// Listen for the input file name
System.out.print("Input XSL-FO file ('quit' to stop): ");
String foname = in.readLine();
if (foname == null) {
System.out.println("Null input, quitting");
return;
}
foname.trim();
if (foname.equals("quit")) {
System.out.println("Quitting");
return;
}
File fofile = new File(baseDir, foname);
String pdfname = foname;
int p = foname.lastIndexOf('.');
pdfname = foname.substring(0, p) + ".pdf";
File pdffile = new File(outDir, pdfname);

// transform and render
System.out.print("Transforming " + fofile + " to PDF file " + pdffile + "...");
FormattingResults foResults = convertFO2PDF(fofile, pdffile);
System.out.println("done!");

// Result processing
java.util.List pageSequences = foResults.getPageSequences();
for (Object pageSequence : pageSequences) {
PageSequenceResults pageSequenceResults = (PageSequenceResults) pageSequence;
System.out.println("PageSequence "
+ (String.valueOf(pageSequenceResults.getID()).length() > 0
? pageSequenceResults.getID() : "<no id>")
+ " generated " + pageSequenceResults.getPageCount() + " pages.");
}
System.out.println("Generated " + foResults.getPageCount() + " pages in total.");

} catch (Exception e) {
System.out.println("failure!");
e.printStackTrace(System.out);
} finally {
System.out.println("");
}
}
}

/**
* Main method. Set up the listener.
* @param args command-line arguments
*/
public static void main(String[] args) {
System.out.println("FOP MultipleFO2PDF\n");
System.out.println("Preparing...");
MultipleFO2PDF m = new MultipleFO2PDF();
m.listen();
}

}

+ 218
- 0
examples/embedding/java/embedding/atxml/ExampleConcat.java View File

@@ -0,0 +1,218 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.atxml;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.AreaTreeParser;
import org.apache.fop.area.RenderPagesModel;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.xml.XMLRenderer;

import embedding.ExampleObj2XML;
import embedding.model.ProjectMember;
import embedding.model.ProjectTeam;

/**
* Example for the area tree XML format that demonstrates the concatenation of two documents
* rendered to the area tree XML format. A single PDF file is generated from the two area tree
* files.
*/
public class ExampleConcat {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Creates a sample ProjectTeam instance for this demo.
* @return ProjectTeam the newly created ProjectTeam instance
*/
public static ProjectTeam createAnotherProjectTeam() {
ProjectTeam team = new ProjectTeam();
team.setProjectName("The Dynamic Duo");
team.addMember(new ProjectMember(
"Batman", "lead", "batman@heroes.org"));
team.addMember(new ProjectMember(
"Robin", "aid", "robin@heroes.org"));
return team;
}

/**
* Converts an XSL-FO document to an area tree XML file.
* @param src the source file
* @param xslt the stylesheet file
* @param areaTreeFile the target area tree XML file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
* @throws TransformerException In case of a XSL transformation problem
*/
public void convertToAreaTreeXML(Source src, Source xslt, File areaTreeFile)
throws IOException, FOPException, TransformerException {

//Create a user agent
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Create an instance of the target renderer so the XMLRenderer can use its font setup
Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
userAgent, MimeConstants.MIME_PDF);

//Create the XMLRenderer to create the area tree XML
XMLRenderer xmlRenderer = new XMLRenderer(userAgent);

//Tell the XMLRenderer to mimic the target renderer
xmlRenderer.mimicRenderer(targetRenderer);

//Make sure the prepared XMLRenderer is used
userAgent.setRendererOverride(xmlRenderer);

// Setup output
OutputStream out = new java.io.FileOutputStream(areaTreeFile);
out = new java.io.BufferedOutputStream(out);
try {
// Construct fop (the MIME type here is unimportant due to the override
// on the user agent)
Fop fop = fopFactory.newFop(null, userAgent, out);

// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer;
if (xslt != null) {
transformer = factory.newTransformer(xslt);
} else {
transformer = factory.newTransformer();
}

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
}

/**
* Concatenates an array of area tree XML files to a single PDF file.
* @param files the array of area tree XML files
* @param pdffile the target PDF file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
* @throws SAXException In case of an XML-related problem
*/
public void concatToPDF(File[] files, File pdffile)
throws IOException, TransformerException, SAXException {
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
//Setup fonts and user agent
FontInfo fontInfo = new FontInfo();
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Construct the AreaTreeModel that will received the individual pages
AreaTreeModel treeModel = new RenderPagesModel(userAgent,
MimeConstants.MIME_PDF, fontInfo, out);

//Iterate over all area tree files
AreaTreeParser parser = new AreaTreeParser();
for (File file : files) {
Source src = new StreamSource(file);
parser.parse(src, treeModel, userAgent);
}

//Signal the end of the processing. The renderer can finalize the target document.
treeModel.endDocument();
} finally {
out.close();
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleConcat\n");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup output file
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File[] files = new File[] {
new File(outDir, "team1.at.xml"),
new File(outDir, "team2.at.xml")};
File pdffile = new File(outDir, "ResultConcat.pdf");
for (int i = 0; i < files.length; i++) {
System.out.println("Area Tree XML file " + (i + 1) + ": "
+ files[i].getCanonicalPath());
}
System.out.println("PDF Output File: " + pdffile.getCanonicalPath());
System.out.println();


ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam();
ProjectTeam team2 = createAnotherProjectTeam();

ExampleConcat app = new ExampleConcat();

//Create area tree XML files
app.convertToAreaTreeXML(
team1.getSourceForProjectTeam(),
new StreamSource(xsltfile), files[0]);
app.convertToAreaTreeXML(
team2.getSourceForProjectTeam(),
new StreamSource(xsltfile), files[1]);

//Concatenate the individual area tree files to one document
app.concatToPDF(files, pdffile);

System.out.println("Success!");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}

}

+ 143
- 0
examples/embedding/java/embedding/atxml/ExampleStamp.java View File

@@ -0,0 +1,143 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.atxml;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.AreaTreeParser;
import org.apache.fop.area.RenderPagesModel;
import org.apache.fop.fonts.FontInfo;

import embedding.ExampleObj2XML;
import embedding.model.ProjectTeam;

/**
* Example for the area tree XML format that demonstrates the stamping of a document with some
* kind of watermark. The resulting document is then rendered to a PDF file.
*/
public class ExampleStamp {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Stamps an area tree XML file and renders it to a PDF file.
* @param atfile the area tree XML file
* @param stampSheet the stylesheet that does the stamping
* @param pdffile the target PDF file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
* @throws SAXException In case of an XML-related problem
*/
public void stampToPDF(File atfile, File stampSheet, File pdffile)
throws IOException, TransformerException, SAXException {
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
//Setup fonts and user agent
FontInfo fontInfo = new FontInfo();
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Construct the AreaTreeModel that will received the individual pages
AreaTreeModel treeModel = new RenderPagesModel(userAgent,
MimeConstants.MIME_PDF, fontInfo, out);

//Iterate over all area tree files
AreaTreeParser parser = new AreaTreeParser();
Source src = new StreamSource(atfile);
Source xslt = new StreamSource(stampSheet);

//Setup Transformer for XSLT processing
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslt);

//Send XSLT result to AreaTreeParser
SAXResult res = new SAXResult(parser.getContentHandler(treeModel, userAgent));

//Start XSLT transformation and area tree parsing
transformer.transform(src, res);

//Signal the end of the processing. The renderer can finalize the target document.
treeModel.endDocument();
} finally {
out.close();
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleConcat\n");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup output file
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File atfile = new File(outDir, "team.at.xml");
File stampxsltfile = new File(baseDir, "xml/xslt/atstamp.xsl");
File pdffile = new File(outDir, "ResultStamped.pdf");
System.out.println("Area Tree XML file : " + atfile.getCanonicalPath());
System.out.println("Stamp XSLT: " + stampxsltfile.getCanonicalPath());
System.out.println("PDF Output File: " + pdffile.getCanonicalPath());
System.out.println();

ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam();

//Create area tree XML file
ExampleConcat concatapp = new ExampleConcat();
concatapp.convertToAreaTreeXML(
team1.getSourceForProjectTeam(),
new StreamSource(xsltfile), atfile);

//Stamp document and produce a PDF from the area tree XML format
ExampleStamp app = new ExampleStamp();
app.stampToPDF(atfile, stampxsltfile, pdffile);

System.out.println("Success!");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}

}

+ 227
- 0
examples/embedding/java/embedding/events/ExampleEvents.java View File

@@ -0,0 +1,227 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.events;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;

import org.apache.commons.io.IOUtils;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.events.Event;
import org.apache.fop.events.EventFormatter;
import org.apache.fop.events.EventListener;
import org.apache.fop.events.model.EventSeverity;

/**
* This class demonstrates how to register an event listener with FOP so you can customize
* FOP's error behaviour.
*/
public class ExampleEvents {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Converts an FO file to a PDF file using FOP
* @param fo the FO file
* @param pdf the target PDF file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
* @throws TransformerException In case of a problem with XSLT
*/
public void convertFO2PDF(URL fo, File pdf)
throws IOException, FOPException, TransformerException {

OutputStream out = null;

try {
//Create the user agent for this processing run
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

//Adding a simple logging listener that writes to stdout and stderr
foUserAgent.getEventBroadcaster().addEventListener(new SysOutEventListener());

// Add your own event listener
foUserAgent.getEventBroadcaster().addEventListener(new MyEventListener());

// configure foUserAgent further as desired

// Setup output stream. Note: Using BufferedOutputStream
// for performance reasons (helpful with FileOutputStreams).
out = new FileOutputStream(pdf);
out = new BufferedOutputStream(out);

// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer

// Setup input stream
Source src = new StreamSource(fo.toExternalForm());

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);

} finally {
IOUtils.closeQuietly(out);
}
}

private static class MyEventListener implements EventListener {

public void processEvent(Event event) {
if ("org.apache.fop.ResourceEventProducer.imageNotFound"
.equals(event.getEventID())) {

//Get the FileNotFoundException that's part of the event's parameters
FileNotFoundException fnfe = (FileNotFoundException)event.getParam("fnfe");

System.out.println("---=== imageNotFound Event for " + event.getParam("uri")
+ "!!! ===---");
//Stop processing when an image could not be found. Otherwise, FOP would just
//continue without the image!

System.out.println("Throwing a RuntimeException...");
throw new RuntimeException(EventFormatter.format(event), fnfe);
} else {
//ignore all other events
}
}

}

/** A simple event listener that writes the events to stdout and sterr. */
private static class SysOutEventListener implements EventListener {

/** {@inheritDoc} */
public void processEvent(Event event) {
String msg = EventFormatter.format(event);
EventSeverity severity = event.getSeverity();
if (severity == EventSeverity.INFO) {
System.out.println("[INFO ] " + msg);
} else if (severity == EventSeverity.WARN) {
System.out.println("[WARN ] " + msg);
} else if (severity == EventSeverity.ERROR) {
System.err.println("[ERROR] " + msg);
} else if (severity == EventSeverity.FATAL) {
System.err.println("[FATAL] " + msg);
} else {
assert false;
}
}
}


/**
* This method extracts the original exception from some exception. The exception
* might be nested multiple levels deep.
* @param t the Throwable to inspect
* @return the original Throwable or the method parameter t if there are no nested Throwables.
*/
private static Throwable getOriginalThrowable(Throwable t) {
if (t instanceof SAXException) {
SAXException saxe = (SAXException)t;
if (saxe.getException() != null) {
return getOriginalThrowable(saxe.getException());
} else {
return saxe;
}
} else {
if (t.getCause() != null) {
return getOriginalThrowable(t.getCause());
} else {
return t;
}
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleEvents\n");
System.out.println("Preparing...");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup input and output files
URL fo = ExampleEvents.class.getResource("missing-image.fo");
File pdffile = new File(outDir, "out.pdf");

System.out.println("Input: XSL-FO (" + fo.toExternalForm() + ")");
System.out.println("Output: PDF (" + pdffile + ")");
System.out.println();
System.out.println("Transforming...");

ExampleEvents app = new ExampleEvents();

try {
app.convertFO2PDF(fo, pdffile);
} catch (TransformerException te) {
//Note: We don't get the original exception here!
//FOP needs to embed the exception in a SAXException and the TraX transformer
//again wraps the SAXException in a TransformerException. Even our own
//RuntimeException just wraps the original FileNotFoundException.
//So we need to unpack to get the original exception (about three layers deep).
Throwable originalThrowable = getOriginalThrowable(te);
originalThrowable.printStackTrace(System.err);
System.out.println("Aborted!");
System.exit(-1);
}

System.out.println("Success!");
} catch (Exception e) {
//Some other error (shouldn't happen in this example)
e.printStackTrace(System.err);
System.exit(-1);
}
}

}

+ 33
- 0
examples/embedding/java/embedding/events/missing-image.fo View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block>
The following image is not available:
<fo:external-graphic src="my-missing-image.png"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 226
- 0
examples/embedding/java/embedding/intermediate/ExampleConcat.java View File

@@ -0,0 +1,226 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.intermediate;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;

import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.intermediate.IFContext;
import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFSerializer;
import org.apache.fop.render.intermediate.IFUtil;
import org.apache.fop.render.intermediate.util.IFConcatenator;

import embedding.ExampleObj2XML;
import embedding.model.ProjectMember;
import embedding.model.ProjectTeam;

/**
* Example for the intermediate format that demonstrates the concatenation of two documents
* rendered to the intermediate format. A single PDF file is generated from the two intermediate
* files.
*/
public class ExampleConcat {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Creates a sample ProjectTeam instance for this demo.
* @return ProjectTeam the newly created ProjectTeam instance
*/
public static ProjectTeam createAnotherProjectTeam() {
ProjectTeam team = new ProjectTeam();
team.setProjectName("The Dynamic Duo");
team.addMember(new ProjectMember(
"Batman", "lead", "batman@heroes.org"));
team.addMember(new ProjectMember(
"Robin", "aid", "robin@heroes.org"));
return team;
}

/**
* Converts an XSL-FO document to an intermediate file.
* @param src the source file
* @param xslt the stylesheet file
* @param intermediate the target intermediate file
* @throws IOException In case of an I/O problem
* @throws FOPException In case of a FOP problem
* @throws TransformerException In case of a XSL transformation problem
*/
public void convertToIntermediate(Source src, Source xslt, File intermediate)
throws IOException, FOPException, TransformerException {

//Create a user agent
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Create an instance of the target document handler so the IFSerializer
//can use its font setup
IFDocumentHandler targetHandler = userAgent.getRendererFactory().createDocumentHandler(
userAgent, MimeConstants.MIME_PDF);

//Create the IFSerializer to write the intermediate format
IFSerializer ifSerializer = new IFSerializer(new IFContext(userAgent));

//Tell the IFSerializer to mimic the target format
ifSerializer.mimicDocumentHandler(targetHandler);

//Make sure the prepared document handler is used
userAgent.setDocumentHandlerOverride(ifSerializer);

// Setup output
OutputStream out = new java.io.FileOutputStream(intermediate);
out = new java.io.BufferedOutputStream(out);
try {
// Construct FOP (the MIME type here is unimportant due to the override
// on the user agent)
Fop fop = fopFactory.newFop(null, userAgent, out);

// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer;
if (xslt != null) {
transformer = factory.newTransformer(xslt);
} else {
transformer = factory.newTransformer();
}

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());

// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
}

/**
* Concatenates an array of intermediate files to a single PDF file.
* @param files the array of intermediate files
* @param pdffile the target PDF file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
* @throws SAXException In case of an XML-related problem
* @throws IFException if there was an IF-related error while creating the output file
*/
public void concatToPDF(File[] files, File pdffile)
throws IOException, TransformerException, SAXException, IFException {
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
//Setup user agent
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Setup target handler
String mime = MimeConstants.MIME_PDF;
IFDocumentHandler targetHandler = fopFactory.getRendererFactory().createDocumentHandler(
userAgent, mime);

//Setup fonts
IFUtil.setupFonts(targetHandler);
targetHandler.setResult(new StreamResult(pdffile));

IFConcatenator concatenator = new IFConcatenator(targetHandler, null);

//Iterate over all intermediate files
for (File file : files) {
Source src = new StreamSource(file);
concatenator.appendDocument(src);
}

//Signal the end of the processing so the target file can be finalized properly.
concatenator.finish();
} finally {
out.close();
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleConcat (for the Intermediate Format)\n");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup output file
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File[] files = new File[] {
new File(outDir, "team1.if.xml"),
new File(outDir, "team2.if.xml")};
File pdffile = new File(outDir, "ResultIFConcat.pdf");
for (int i = 0; i < files.length; i++) {
System.out.println("Intermediate file " + (i + 1) + ": "
+ files[i].getCanonicalPath());
}
System.out.println("PDF Output File: " + pdffile.getCanonicalPath());
System.out.println();


ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam();
ProjectTeam team2 = createAnotherProjectTeam();

ExampleConcat app = new ExampleConcat();

//Create intermediate files
app.convertToIntermediate(
team1.getSourceForProjectTeam(),
new StreamSource(xsltfile), files[0]);
app.convertToIntermediate(
team2.getSourceForProjectTeam(),
new StreamSource(xsltfile), files[1]);

//Concatenate the individual intermediate files to one document
app.concatToPDF(files, pdffile);

System.out.println("Success!");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}

}

+ 146
- 0
examples/embedding/java/embedding/intermediate/ExampleStamp.java View File

@@ -0,0 +1,146 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.intermediate;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFParser;
import org.apache.fop.render.intermediate.IFUtil;

import embedding.ExampleObj2XML;
import embedding.model.ProjectTeam;

/**
* Example for the intermediate format that demonstrates the stamping of a document with some
* kind of watermark. The resulting document is then rendered to a PDF file.
*/
public class ExampleStamp {

// configure fopFactory as desired
private final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());

/**
* Stamps an intermediate file and renders it to a PDF file.
* @param iffile the intermediate file (area tree XML)
* @param stampSheet the stylesheet that does the stamping
* @param pdffile the target PDF file
* @throws IOException In case of an I/O problem
* @throws TransformerException In case of a XSL transformation problem
* @throws SAXException In case of an XML-related problem
* @throws IFException if there was an IF-related error while creating the output file
*/
public void stampToPDF(File iffile, File stampSheet, File pdffile)
throws IOException, TransformerException, SAXException, IFException {
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
//user agent
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Setup target handler
String mime = MimeConstants.MIME_PDF;
IFDocumentHandler targetHandler = fopFactory.getRendererFactory().createDocumentHandler(
userAgent, mime);

//Setup fonts
IFUtil.setupFonts(targetHandler);
targetHandler.setResult(new StreamResult(pdffile));

IFParser parser = new IFParser();

Source src = new StreamSource(iffile);
Source xslt = new StreamSource(stampSheet);

//Setup Transformer for XSLT processing
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xslt);

//Send XSLT result to AreaTreeParser
SAXResult res = new SAXResult(parser.getContentHandler(targetHandler, userAgent));

//Start XSLT transformation and area tree parsing
transformer.transform(src, res);
} finally {
out.close();
}
}

/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
System.out.println("FOP ExampleConcat (for the Intermediate Format)\n");

//Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();

//Setup output file
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File iffile = new File(outDir, "team.if.xml");
File stampxsltfile = new File(baseDir, "xml/xslt/ifstamp.xsl");
File pdffile = new File(outDir, "ResultIFStamped.pdf");
System.out.println("Intermediate file : " + iffile.getCanonicalPath());
System.out.println("Stamp XSLT: " + stampxsltfile.getCanonicalPath());
System.out.println("PDF Output File: " + pdffile.getCanonicalPath());
System.out.println();

ProjectTeam team1 = ExampleObj2XML.createSampleProjectTeam();

//Create intermediate file
ExampleConcat concatapp = new ExampleConcat();
concatapp.convertToIntermediate(
team1.getSourceForProjectTeam(),
new StreamSource(xsltfile), iffile);

//Stamp document and produce a PDF from the intermediate format
ExampleStamp app = new ExampleStamp();
app.stampToPDF(iffile, stampxsltfile, pdffile);

System.out.println("Success!");

} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
}
}

}

+ 104
- 0
examples/embedding/java/embedding/model/ProjectMember.java View File

@@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.model;

/**
* This bean represents a project member.
*/
public class ProjectMember {

private String name;
private String function;
private String email;


/**
* Default no-parameter constructor.
*/
public ProjectMember() {
}


/**
* Convenience constructor.
* @param name name of the project member
* @param function function in the team
* @param email email address
*/
public ProjectMember(String name, String function, String email) {
setName(name);
setFunction(function);
setEmail(email);
}

/**
* Returns the name.
* @return String the name
*/
public String getName() {
return name;
}


/**
* Returns the function.
* @return String the function
*/
public String getFunction() {
return function;
}


/**
* Returns the email address.
* @return String the email address
*/
public String getEmail() {
return email;
}


/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}


/**
* Sets the function.
* @param function The function to set
*/
public void setFunction(String function) {
this.function = function;
}


/**
* Sets the email address.
* @param email The email address to set
*/
public void setEmail(String email) {
this.email = email;
}

}

+ 83
- 0
examples/embedding/java/embedding/model/ProjectTeam.java View File

@@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.model;

import java.util.List;

import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;

/**
* This bean represents a ProjectTeam.
*/
public class ProjectTeam {

private String projectName;
private List members = new java.util.ArrayList();


/**
* Returns a list of project members.
* @return List a list of ProjectMember objects
*/
public List getMembers() {
return this.members;
}


/**
* Adds a ProjectMember to this project team.
* @param member the member to add
*/
public void addMember(ProjectMember member) {
this.members.add(member);
}


/**
* Returns the name of the project
* @return String the name of the project
*/
public String getProjectName() {
return projectName;
}


/**
* Sets the name of the project.
* @param projectName the project name to set
*/
public void setProjectName(String projectName) {
this.projectName = projectName;
}


/**
* Resturns a Source object for this object so it can be used as input for
* a JAXP transformation.
* @return Source The Source object
*/
public Source getSourceForProjectTeam() {
return new SAXSource(new ProjectTeamXMLReader(),
new ProjectTeamInputSource(this));
}


}

+ 56
- 0
examples/embedding/java/embedding/model/ProjectTeamInputSource.java View File

@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.model;

import org.xml.sax.InputSource;

/**
* This class is a special InputSource decendant for using ProjectTeam
* instances as XML sources.
*/
public class ProjectTeamInputSource extends InputSource {

private ProjectTeam projectTeam;

/**
* Constructor for the ProjectTeamInputSource
* @param projectTeam The ProjectTeam object to use
*/
public ProjectTeamInputSource(ProjectTeam projectTeam) {
this.projectTeam = projectTeam;
}

/**
* Returns the projectTeam.
* @return ProjectTeam
*/
public ProjectTeam getProjectTeam() {
return projectTeam;
}

/**
* Sets the projectTeam.
* @param projectTeam The projectTeam to set
*/
public void setProjectTeam(ProjectTeam projectTeam) {
this.projectTeam = projectTeam;
}

}

+ 116
- 0
examples/embedding/java/embedding/model/ProjectTeamXMLReader.java View File

@@ -0,0 +1,116 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.model;

//Java
import java.io.IOException;

//SAX
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import embedding.tools.AbstractObjectReader;

/**
* XMLReader implementation for the ProjectTeam class. This class is used to
* generate SAX events from the ProjectTeam class.
*/
public class ProjectTeamXMLReader extends AbstractObjectReader {

/**
* @see org.xml.sax.XMLReader#parse(InputSource)
*/
public void parse(InputSource input) throws IOException, SAXException {
if (input instanceof ProjectTeamInputSource) {
parse(((ProjectTeamInputSource)input).getProjectTeam());
} else {
throw new SAXException("Unsupported InputSource specified. "
+ "Must be a ProjectTeamInputSource");
}
}


/**
* Starts parsing the ProjectTeam object.
* @param projectTeam The object to parse
* @throws SAXException In case of a problem during SAX event generation
*/
public void parse(ProjectTeam projectTeam) throws SAXException {
if (projectTeam == null) {
throw new NullPointerException("Parameter projectTeam must not be null");
}
if (handler == null) {
throw new IllegalStateException("ContentHandler not set");
}

//Start the document
handler.startDocument();

//Generate SAX events for the ProjectTeam
generateFor(projectTeam);

//End the document
handler.endDocument();
}


/**
* Generates SAX events for a ProjectTeam object.
* @param projectTeam ProjectTeam object to use
* @throws SAXException In case of a problem during SAX event generation
*/
protected void generateFor(ProjectTeam projectTeam) throws SAXException {
if (projectTeam == null) {
throw new NullPointerException("Parameter projectTeam must not be null");
}
if (handler == null) {
throw new IllegalStateException("ContentHandler not set");
}

handler.startElement("projectteam");
handler.element("projectname", projectTeam.getProjectName());
for (Object o : projectTeam.getMembers()) {
ProjectMember member = (ProjectMember) o;
generateFor(member);
}
handler.endElement("projectteam");
}

/**
* Generates SAX events for a ProjectMember object.
* @param projectMember ProjectMember object to use
* @throws SAXException In case of a problem during SAX event generation
*/
protected void generateFor(ProjectMember projectMember) throws SAXException {
if (projectMember == null) {
throw new NullPointerException("Parameter projectMember must not be null");
}
if (handler == null) {
throw new IllegalStateException("ContentHandler not set");
}

handler.startElement("member");
handler.element("name", projectMember.getName());
handler.element("function", projectMember.getFunction());
handler.element("email", projectMember.getEmail());
handler.endElement("member");
}

}

+ 179
- 0
examples/embedding/java/embedding/tools/AbstractObjectReader.java View File

@@ -0,0 +1,179 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.tools;

//Java
import java.io.IOException;
import java.util.Map;

//SAX
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.EntityResolver;

/**
* This class can be used as base class for XMLReaders that generate SAX
* events from Java objects.
*/

public abstract class AbstractObjectReader implements XMLReader {

private static final String NAMESPACES =
"http://xml.org/sax/features/namespaces";
private static final String NS_PREFIXES =
"http://xml.org/sax/features/namespace-prefixes";

private Map features = new java.util.HashMap();
private ContentHandler orgHandler;

/** Proxy for easy SAX event generation */
protected EasyGenerationContentHandlerProxy handler;
/** Error handler */
protected ErrorHandler errorHandler;


/**
* Constructor for the AbstractObjectReader object
*/
public AbstractObjectReader() {
setFeature(NAMESPACES, false);
setFeature(NS_PREFIXES, false);
}

/* ============ XMLReader interface ============ */

/**
* @see org.xml.sax.XMLReader#getContentHandler()
*/
public ContentHandler getContentHandler() {
return this.orgHandler;
}

/**
* @see org.xml.sax.XMLReader#setContentHandler(ContentHandler)
*/
public void setContentHandler(ContentHandler handler) {
this.orgHandler = handler;
this.handler = new EasyGenerationContentHandlerProxy(handler);
}

/**
* @see org.xml.sax.XMLReader#getErrorHandler()
*/
public ErrorHandler getErrorHandler() {
return this.errorHandler;
}

/**
* @see org.xml.sax.XMLReader#setErrorHandler(ErrorHandler)
*/
public void setErrorHandler(ErrorHandler handler) {
this.errorHandler = handler;
}

/**
* @see org.xml.sax.XMLReader#getDTDHandler()
*/
public DTDHandler getDTDHandler() {
return null;
}

/**
* @see org.xml.sax.XMLReader#setDTDHandler(DTDHandler)
*/
public void setDTDHandler(DTDHandler handler) {
}

/**
* @see org.xml.sax.XMLReader#getEntityResolver()
*/
public EntityResolver getEntityResolver() {
return null;
}

/**
* @see org.xml.sax.XMLReader#setEntityResolver(EntityResolver)
*/
public void setEntityResolver(EntityResolver resolver) {
}

/**
* @see org.xml.sax.XMLReader#getProperty(String)
*/
public Object getProperty(String name) {
return null;
}

/**
* @see org.xml.sax.XMLReader#setProperty(String, Object)
*/
public void setProperty(String name, Object value) {
}

/**
* @see org.xml.sax.XMLReader#getFeature(String)
*/
public boolean getFeature(String name) {
return (Boolean) features.get(name);
}

/**
* Returns true if the NAMESPACES feature is enabled.
* @return boolean true if enabled
*/
protected boolean isNamespaces() {
return getFeature(NAMESPACES);
}

/**
* Returns true if the MS_PREFIXES feature is enabled.
* @return boolean true if enabled
*/
protected boolean isNamespacePrefixes() {
return getFeature(NS_PREFIXES);
}

/**
* @see org.xml.sax.XMLReader#setFeature(String, boolean)
*/
public void setFeature(String name, boolean value) {
this.features.put(name, value);
}

/**
* @see org.xml.sax.XMLReader#parse(String)
*/
public void parse(String systemId) throws IOException, SAXException {
throw new SAXException(
this.getClass().getName()
+ " cannot be used with system identifiers (URIs)");
}

/**
* @see org.xml.sax.XMLReader#parse(InputSource)
*/
public abstract void parse(InputSource input)
throws IOException, SAXException;

}

+ 214
- 0
examples/embedding/java/embedding/tools/EasyGenerationContentHandlerProxy.java View File

@@ -0,0 +1,214 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* $Id$ */

package embedding.tools;

//SAX
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

/**
* This class is an implementation of ContentHandler which acts as a proxy to
* another ContentHandler and has the purpose to provide a few handy methods
* that make life easier when generating SAX events.
* <br>
* Note: This class is only useful for simple cases with no namespaces.
*/

public class EasyGenerationContentHandlerProxy implements ContentHandler {

/** An empty Attributes object used when no attributes are needed. */
public static final Attributes EMPTY_ATTS = new AttributesImpl();

private ContentHandler target;


/**
* Main constructor.
* @param forwardTo ContentHandler to forward the SAX event to.
*/
public EasyGenerationContentHandlerProxy(ContentHandler forwardTo) {
this.target = forwardTo;
}


/**
* Sends the notification of the beginning of an element.
* @param name Name for the element.
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void startElement(String name) throws SAXException {
startElement(name, EMPTY_ATTS);
}


/**
* Sends the notification of the beginning of an element.
* @param name Name for the element.
* @param atts The attributes attached to the element. If there are no
* attributes, it shall be an empty Attributes object.
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void startElement(String name, Attributes atts) throws SAXException {
startElement(null, name, name, atts);
}


/**
* Send a String of character data.
* @param s The content String
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void characters(String s) throws SAXException {
target.characters(s.toCharArray(), 0, s.length());
}


/**
* Send the notification of the end of an element.
* @param name Name for the element.
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void endElement(String name) throws SAXException {
endElement(null, name, name);
}


/**
* Sends notifications for a whole element with some String content.
* @param name Name for the element.
* @param value Content of the element.
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void element(String name, String value) throws SAXException {
element(name, value, EMPTY_ATTS);
}


/**
* Sends notifications for a whole element with some String content.
* @param name Name for the element.
* @param value Content of the element.
* @param atts The attributes attached to the element. If there are no
* attributes, it shall be an empty Attributes object.
* @throws SAXException Any SAX exception, possibly wrapping another exception.
*/
public void element(String name, String value, Attributes atts) throws SAXException {
startElement(name, atts);
if (value != null) {
characters(value.toCharArray(), 0, value.length());
}
endElement(name);
}

/* =========== ContentHandler interface =========== */

/**
* @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
*/
public void setDocumentLocator(Locator locator) {
target.setDocumentLocator(locator);
}


/**
* @see org.xml.sax.ContentHandler#startDocument()
*/
public void startDocument() throws SAXException {
target.startDocument();
}


/**
* @see org.xml.sax.ContentHandler#endDocument()
*/
public void endDocument() throws SAXException {
target.endDocument();
}


/**
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
*/
public void startPrefixMapping(String prefix, String uri) throws SAXException {
target.startPrefixMapping(prefix, uri);
}


/**
* @see org.xml.sax.ContentHandler#endPrefixMapping(String)
*/
public void endPrefixMapping(String prefix) throws SAXException {
target.endPrefixMapping(prefix);
}


/**
* @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
*/
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException {
target.startElement(namespaceURI, localName, qName, atts);
}


/**
* @see org.xml.sax.ContentHandler#endElement(String, String, String)
*/
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
target.endElement(namespaceURI, localName, qName);
}


/**
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
*/
public void characters(char[] ch, int start, int length) throws SAXException {
target.characters(ch, start, length);
}


/**
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
*/
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
target.ignorableWhitespace(ch, start, length);
}


/**
* @see org.xml.sax.ContentHandler#processingInstruction(String, String)
*/
public void processingInstruction(String target, String data) throws SAXException {
this.target.processingInstruction(target, data);
}


/**
* @see org.xml.sax.ContentHandler#skippedEntity(String)
*/
public void skippedEntity(String name) throws SAXException {
target.skippedEntity(name);
}

}

+ 30
- 0
examples/embedding/xml/fo/helloworld.fo View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 26
- 0
examples/embedding/xml/svg/helloworld.svg View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">
<svg xml:space="preserve" x="-1.70458in" y="0.198315in" width="2.6622in" height="1.89672in" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality"
viewBox="-4330 0 6762 4818">
<rect style="fill:none;stroke:#009BE1;stroke-width:35" x="-4312" y="18" width="6727" height="4782"/>
<text x="-3653" y="841" style="fill:#1F1A17;font-weight:normal;font-size:639;font-family:Helvetica">Hello World!</text>
<ellipse style="fill:#E77919" cx="-2697" cy="2934" rx="925" ry="925"/>
<path style="fill:none;stroke:#A3D01C;stroke-width:35" d="M209 1102l799 239 798 239 191 811 192 811 -606 572 -607 571 -798 -239 -798 -240 -192 -810 -192 -811 607 -572 606 -571z"/>
</svg>

+ 46
- 0
examples/embedding/xml/xml/projectteam.xml View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<projectteam>
<projectname>The Killer Application</projectname>
<member>
<name>John Doe</name>
<function>lead</function>
<email>jon.doe@killerapp.fun</email>
</member>
<member>
<name>Paul Coder</name>
<function>dev</function>
<email>paul.coder@killerapp.fun</email>
</member>
<member>
<name>Max Hacker</name>
<function>dev</function>
<email>max.hacker@killerapp.fun</email>
</member>
<member>
<name>Donna Book</name>
<function>doc</function>
<email>donna.book@killerapp.fun</email>
</member>
<member>
<name>Henry Tester</name>
<function>qa</function>
<email>henry.tester@killerapp.fun</email>
</member>
</projectteam>

+ 58
- 0
examples/embedding/xml/xslt/atstamp.xsl View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<!-- ========================= -->
<!-- stamping... -->
<!-- ========================= -->
<xsl:template match="flow">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<!-- Stamp a big "SPECIMEN" text over the whole page using an area tree fragment inserted at the right place... -->
<block ipd="595275" bpd="841889" is-viewport-area="true" left-position="0" top-position="0" ctm="[1.0 0.0 0.0 1.0 0.0 0.0]" positioning="fixed">
<block ipd="595275" bpd="841889" is-reference-area="true">
<block ipd="595275" bpd="841889">
<lineArea ipd="595275" bpd="841889">
<viewport ipd="595275" bpd="841889" offset="0" pos="0 0 595275 841889">
<foreignObject ipd="0" bpd="0" ns="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<g transform="rotate(-50 50 50)">
<text x="50" y="60" style="font-size:20;fill:#dfdfdf;stroke:none;font-family:sans-serif" text-anchor="middle">SPECIMEN</text>
</g>
</svg>
</foreignObject>
</viewport>
</lineArea>
</block>
</block>
</block>
<xsl:apply-templates select="child::*"/>
</xsl:copy>
</xsl:template>
<!-- ========================= -->
<!-- identity transformation -->
<!-- ========================= -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

+ 49
- 0
examples/embedding/xml/xslt/ifstamp.xsl View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:if="http://xmlgraphics.apache.org/fop/intermediate">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<!-- ========================= -->
<!-- stamping... -->
<!-- ========================= -->
<xsl:template match="if:content">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<!-- Stamp a big "SPECIMEN" text over the whole page using an area tree fragment inserted at the right place... -->
<if:g transform="translate(100000, 750000) rotate(-55)">
<if:font family="sans-serif" style="normal" weight="400" variant="normal" size="160000"
color="#dfdfdf"/>
<if:text xml:space="preserve" x="0" y="0">SPECIMEN</if:text>
</if:g>
<!-- Note: The free transformation above will not work with AFP output. In such a case,
using an embedded SVG graphic is better. -->
<xsl:apply-templates select="child::*"/>
</xsl:copy>
</xsl:template>
<!-- ========================= -->
<!-- identity transformation -->
<!-- ========================= -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

+ 77
- 0
examples/embedding/xml/xslt/projectteam2fo.xsl View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:param name="versionParam" select="'1.0'"/>
<!-- ========================= -->
<!-- root element: projectteam -->
<!-- ========================= -->
<xsl:template match="projectteam">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="16pt" font-weight="bold" space-after="5mm">Project: <xsl:value-of select="projectname"/>
</fo:block>
<fo:block font-size="12pt" space-after="5mm">Version <xsl:value-of select="$versionParam"/>
</fo:block>
<fo:block font-size="10pt">
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="5cm"/>
<fo:table-body>
<xsl:apply-templates select="member"/>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- ========================= -->
<!-- child element: member -->
<!-- ========================= -->
<xsl:template match="member">
<fo:table-row>
<xsl:if test="function = 'lead'">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:if>
<fo:table-cell>
<fo:block>
<xsl:value-of select="name"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="function"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="email"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>

+ 6
- 0
examples/fo/advanced/K3.README View File

@@ -0,0 +1,6 @@
The K3 3 of 9 barcode font is available from:
http://www.geocities.com/keith_dimmock/
Keith Dimmock states:
Unless otherwise indicated all downloads are FREE, no cost and no nag screens.

BIN
examples/fo/advanced/K3.TTF View File


+ 1
- 0
examples/fo/advanced/K3.xml View File

@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><font-metrics type="TYPE0"><font-name>New</font-name><embed/><cap-height>390</cap-height><x-height>0</x-height><ascender>390</ascender><descender>0</descender><bbox><left>0</left><bottom>0</bottom><right>219</right><top>390</top></bbox><flags>33</flags><stemv>0</stemv><italicangle>0</italicangle><subtype>TYPE0</subtype><multibyte-extras><cid-type>CIDFontType2</cid-type><default-width>0</default-width><bfranges><bf gi="47" ue="32" us="32"/><bf gi="45" ue="36" us="36"/><bf gi="43" ue="37" us="37"/><bf gi="40" ue="42" us="42"/><bf gi="42" ue="43" us="43"/><bf gi="0" ue="44" us="44"/><bf gi="41" ue="45" us="45"/><bf gi="46" ue="46" us="46"/><bf gi="44" ue="47" us="47"/><bf gi="5" ue="50" us="48"/><bf gi="9" ue="56" us="51"/><bf gi="8" ue="57" us="57"/><bf gi="15" ue="83" us="65"/><bf gi="4" ue="84" us="84"/><bf gi="34" ue="90" us="85"/><bf gi="0" ue="65535" us="65535"/></bfranges><cid-widths start-index="0"><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/><wx w="156"/></cid-widths></multibyte-extras></font-metrics>

+ 87
- 0
examples/fo/advanced/bar.conf.xml View File

@@ -0,0 +1,87 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->

<!--
FOP configuration for the barcode.fo example.
-->

<fop version="1.0">

<!-- Base URL for resolving relative URLs -->
<base>.</base>
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
<source-resolution>72</source-resolution>
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
<target-resolution>72</target-resolution>
<!-- Default page-height and page-width, in case
value is specified as auto -->
<default-page-settings height="11in" width="8.26in"/>
<!-- Information for specific renderers -->
<!-- Uses renderer mime type for renderers -->
<renderers>
<renderer mime="application/pdf">
<filterList>
<!-- provides compression using zlib flate (default is on) -->
<value>flate</value>
<!-- encodes binary data into printable ascii characters (default off)
This provides about a 4:5 expansion of data size -->
<!-- <value>ascii-85</value> -->
<!-- encodes binary data with hex representation (default off)
This filter is not recommended as it doubles the data size -->
<!-- <value>ascii-hex</value> -->
</filterList>

<fonts>
<font metrics-url="examples/fo/advanced/K3.xml" kerning="no" embed-url="examples/fo/advanced/K3.ttf">
<font-triplet name="Barcode" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>

<renderer mime="application/postscript"/>
<renderer mime="application/vnd.hp-PCL"/>

<renderer mime="image/svg+xml">
<format type="paginated"/>
<link value="true"/>
<strokeText value="false"/>
</renderer>

<renderer mime="application/awt"/>

<renderer mime="image/png"/>

<renderer mime="image/tiff/">
</renderer>

<renderer mime="text/xml"/>

<renderer mime="text/plain">
<pageSize columns="80"/>
</renderer>

</renderers>

</fop>


+ 99
- 0
examples/fo/advanced/barcode.fo View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-width="21cm"
page-height="29.7cm"
margin-top="5mm">
<fo:region-body
margin-bottom="4.5in"
margin-right="5mm"
margin-left="5mm"
margin-top="5mm"/>
<fo:region-after
extent="4in" />
</fo:simple-page-master>

<fo:simple-page-master master-name="rest"
page-width="21cm"
page-height="29.7cm"
margin-right="5mm"
margin-left="5mm"
margin-top="5mm"
margin-bottom="5mm">
<fo:region-body/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="A4">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="first"/>
<fo:conditional-page-master-reference master-reference="rest" page-position="rest"/>
<fo:conditional-page-master-reference master-reference="rest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body" font-size="12pt">

<fo:block font-size="14pt" font-weight="bold">
Example embedding Font
</fo:block>
<fo:block>
This example shows how to use an embedded font and
uses a free barcode font as an example. The barcode font is from
<fo:basic-link external-destination="http://www.geocities.com/keith_dimmock/">http://www.geocities.com/keith_dimmock/</fo:basic-link>
and is free.
</fo:block>
<fo:block>
To generate the PDF from this example, set the following build parameters
(for example in build-local.properties) and run "build examples" from the
top-level FOP source code directory.
<fo:block font-family="Courier" font-size="10pt" margin-left="2em">
<fo:block>fo.examples.dir = ./examples/fo/advanced</fo:block>
<fo:block>fo.examples.include = **/barcode.fo</fo:block>
<fo:block>fo.examples.userconfig = examples/fo/advanced/bar.conf.xml</fo:block>
<fo:block>fo.examples.force = true</fo:block>
</fo:block>
</fo:block>
<fo:block>
If the character encoding is correct in the generated PDF (bugzilla 5335), searching for "123456" should
find the first barcode, and "234567" the second.
</fo:block>
<fo:block font-weight="bold" space-before.optimum="2em">
First barcode: *ID123456*
</fo:block>
<fo:block
font-family="Barcode"
font-size="74pt">
*ID123456*
</fo:block>
<fo:block>
normal text, follows first barcode.
</fo:block>
<fo:block font-weight="bold" space-before.optimum="2em">
Second barcode: *ID234567* and some text
</fo:block>
<fo:block
font-family="Barcode, Helvetica"
font-size="74pt">
*ID234567* and some text
</fo:block>

<fo:block>
normal text, follows second barcode.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 155
- 0
examples/fo/advanced/bleed-and-crop-marks.fo View File

@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
font-family="sans-serif" font-size="9pt">

<fo:layout-master-set>
<fo:simple-page-master master-name="business-card"
page-width="84mm" page-height="53mm"
fox:bleed="3mm" fox:crop-box="media-box" fox:crop-offset="10mm" fox:scale="4">
<fo:region-body margin-bottom="3mm" margin-left="3mm" margin-right="3mm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="business-card">
<fo:flow flow-name="xsl-region-body">
<fo:block-container id="crop-marks" absolute-position="fixed">
<fo:block line-height="1" font-size="0pt">
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="84mm" height="53mm" viewBox="0 0 84 53" overflow="visible">
<style type="text/css"><![CDATA[
.line { fill:none; stroke:black; stroke-width:0.1 }
.colorbox { stroke:black; stroke-width:0.1 }
]]></style>
<defs>
<rect id="box" class="colorbox" width="5" height="4"/>
</defs>
<g id="cut-marks">
<polyline class="line" points="0,-3 0,-10" />
<polyline class="line" points="84,-3 84,-10" />
<polyline class="line" points="-3,0 -10,0" />
<polyline class="line" points="-3,53 -10,53" />
<polyline class="line" points="0,56 0,63" />
<polyline class="line" points="84,56 84,63" />
<polyline class="line" points="87,0 94,0" />
<polyline class="line" points="87,53 94,53" />
</g>
<g id="grays" transform="translate(88,4)">
<use xlink:href="#box" y="0" style="fill:rgb(0%,0%,0%)"/>
<use xlink:href="#box" y="4" style="fill:rgb(10%,10%,10%)"/>
<use xlink:href="#box" y="8" style="fill:rgb(20%,20%,20%)"/>
<use xlink:href="#box" y="12" style="fill:rgb(30%,30%,30%)"/>
<use xlink:href="#box" y="16" style="fill:rgb(40%,40%,40%)"/>
<use xlink:href="#box" y="20" style="fill:rgb(50%,50%,50%)"/>
<use xlink:href="#box" y="24" style="fill:rgb(60%,60%,60%)"/>
<use xlink:href="#box" y="28" style="fill:rgb(70%,70%,70%)"/>
<use xlink:href="#box" y="32" style="fill:rgb(80%,80%,80%)"/>
<use xlink:href="#box" y="36" style="fill:rgb(90%,90%,90%)"/>
<use xlink:href="#box" y="40" style="fill:rgb(100%,100%,100%)"/>
</g>

<g id="cyan" transform="translate(4,-9)">
<use xlink:href="#box" x="0" style="fill:rgb(0%,100%,100%)"/>
<use xlink:href="#box" x="5" style="fill:rgb(5%,100%,100%)"/>
<use xlink:href="#box" x="10" style="fill:rgb(25%,100%,100%)"/>
<use xlink:href="#box" x="15" style="fill:rgb(50%,100%,100%)"/>
<use xlink:href="#box" x="20" style="fill:rgb(75%,100%,100%)"/>
<use xlink:href="#box" x="25" style="fill:rgb(95%,100%,100%)"/>
</g>
<g id="magenta" transform="translate(50,-9)">
<use xlink:href="#box" x="0" style="fill:rgb(100%,0%,100%)"/>
<use xlink:href="#box" x="5" style="fill:rgb(100%,5%,100%)"/>
<use xlink:href="#box" x="10" style="fill:rgb(100%,25%,100%)"/>
<use xlink:href="#box" x="15" style="fill:rgb(100%,50%,100%)"/>
<use xlink:href="#box" x="20" style="fill:rgb(100%,75%,100%)"/>
<use xlink:href="#box" x="25" style="fill:rgb(100%,95%,100%)"/>
</g>
<g id="yellow" transform="translate(4,58)">
<use xlink:href="#box" x="0" style="fill:rgb(100%,100%,0%)"/>
<use xlink:href="#box" x="5" style="fill:rgb(100%,100%,5%)"/>
<use xlink:href="#box" x="10" style="fill:rgb(100%,100%,25%)"/>
<use xlink:href="#box" x="15" style="fill:rgb(100%,100%,50%)"/>
<use xlink:href="#box" x="20" style="fill:rgb(100%,100%,75%)"/>
<use xlink:href="#box" x="25" style="fill:rgb(100%,100%,95%)"/>
</g>
<g id="base-colors" transform="translate(50,58)">
<use xlink:href="#box" x="0" style="fill:red"/>
<use xlink:href="#box" x="5" style="fill:green"/>
<use xlink:href="#box" x="10" style="fill:blue"/>
<use xlink:href="#box" x="15" style="fill:cyan"/>
<use xlink:href="#box" x="20" style="fill:magenta"/>
<use xlink:href="#box" x="25" style="fill:yellow"/>
</g>
</svg>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
<fo:block-container id="background" absolute-position="fixed"
inline-progression-dimension="84mm" block-progression-dimension="14mm"
overflow="visible">
<fo:block line-height="1" font-size="0pt">
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
width="84mm" height="14mm" viewBox="0 0 84 14" overflow="visible">
<defs>
<linearGradient id="MyGradient">
<stop offset="0%" stop-color="#FF0000"/>
<stop offset="30%" stop-color="#FF0000"/>
<stop offset="55%" stop-color="#FFFFFF"/>
<stop offset="100%" stop-color="#FFFFFF"/>
</linearGradient>
</defs>
<rect x="-3" y="-3" width="87" height="17" style="fill:url(#MyGradient); stroke:none"/>
</svg>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
<fo:block-container block-progression-dimension="14mm" display-align="center">
<fo:block font-weight="bold" font-size="9mm" line-height="1.5" color="white">ACME</fo:block>
</fo:block-container>
<fo:block start-indent="3mm" end-indent="3mm"/>
<fo:block text-align="end" space-before="3mm" space-before.conditionality="retain">
<fo:block font-size="14pt" font-weight="bold" space-after="2mm">
Pepé Le Pew
</fo:block>
<fo:block font-size="12pt" space-after="4mm">
Expert d'Amour
</fo:block>
</fo:block>
<fo:block>
<fo:block>13 Pleasantstreet</fo:block>
<fo:block>Acme Acres</fo:block>
<fo:block>+1 (23) 456-7890</fo:block>
<fo:block>pepe@looney.toon</fo:block>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 455
- 0
examples/fo/advanced/cid-fonts.fo View File

@@ -0,0 +1,455 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fo:root [
<!ENTITY nbsp "&#160;">
]>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4"
page-width="21cm"
page-height="29.7cm" >
<fo:region-body
margin-bottom="1.5cm"
margin-right="2cm"
margin-left="2cm"
margin-top="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:bookmark-tree>
<fo:bookmark internal-destination="sec0">
<fo:bookmark-title>Adding Fonts to FOP</fo:bookmark-title>
</fo:bookmark>

<fo:bookmark internal-destination="sec1">
<fo:bookmark-title>Adding additional Type 1 fonts</fo:bookmark-title>

<fo:bookmark internal-destination="sec1-1">
<fo:bookmark-title>Generating a font metrics file</fo:bookmark-title>
</fo:bookmark>
<fo:bookmark internal-destination="sec1-2">
<fo:bookmark-title>Register the fonts within FOP</fo:bookmark-title>
</fo:bookmark>
</fo:bookmark>

<fo:bookmark internal-destination="sec2">
<fo:bookmark-title>Adding additional TrueType fonts</fo:bookmark-title>

<fo:bookmark internal-destination="sec2-1">
<fo:bookmark-title>Generating a font metrics file</fo:bookmark-title>
</fo:bookmark>
<fo:bookmark internal-destination="sec2-2">
<fo:bookmark-title>TrueType collections</fo:bookmark-title>
</fo:bookmark>
<fo:bookmark internal-destination="sec2-3">
<fo:bookmark-title>Register the fonts within FOP</fo:bookmark-title>
</fo:bookmark>

</fo:bookmark>

<fo:bookmark internal-destination="sec3">
<fo:bookmark-title>Embedding fonts in the PDF</fo:bookmark-title>
</fo:bookmark>

<fo:bookmark internal-destination="sec4">
<fo:bookmark-title>Example embedding MSGothic</fo:bookmark-title>

<fo:bookmark internal-destination="sec4-1">
<fo:bookmark-title>Setup CLASSPATH</fo:bookmark-title>
</fo:bookmark>

<fo:bookmark internal-destination="sec4-2">
<fo:bookmark-title>Create the metrics file</fo:bookmark-title>
</fo:bookmark>

<fo:bookmark internal-destination="sec4-3">
<fo:bookmark-title>Edit msgothic.xml</fo:bookmark-title>
</fo:bookmark>

<fo:bookmark internal-destination="sec4-4">
<fo:bookmark-title>Register the font with FOP</fo:bookmark-title>
</fo:bookmark>
</fo:bookmark>

<fo:bookmark internal-destination="sec5">
<fo:bookmark-title>Japanese Examples</fo:bookmark-title>
</fo:bookmark>
</fo:bookmark-tree>

<fo:page-sequence master-reference="A4">

<fo:flow flow-name="xsl-region-body">
<fo:wrapper font-family="Times" font-size="12pt" text-align="justify">
<fo:block id="sec0"
text-align="center"
font-family="Helvetica"
font-weight="bold"
font-size="18pt"
color="#0050B2" space-after.optimum="6pt">
Adding Fonts to FOP
</fo:block>

<fo:block space-after.optimum="6pt">
When building PDF files, FOP normally supports only the base 14 font
package defined in the Adobe PDF specification. That includes the
following fonts: Helvetica, Times, Courier, Symbol and ZapfDingbats.
</fo:block>

<fo:block space-after.optimum="6pt">
Font support in FOP can be extended by the addition of font metric
files (written in XML) created from Adobe Type 1 fonts and Truetype
fonts. No other font types (Type 3, etc.) are supported at this time.
</fo:block>

<fo:block id="sec1"
font-family="Helvetica"
font-weight="bold"
font-size="14pt"
color="#0050B2"
space-after.optimum="6pt"
space-before.optimum="12pt">
Adding additional Type 1 fonts
</fo:block>

<fo:block space-after.optimum="6pt" >
As mentioned above you need an XML file containing font metrics to
be able to use an additional font. FOP contains a tool that can generate
such a font metrics file from a PFM file, which normally comes with the
font file.
</fo:block>

<fo:block id="sec1-1"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt" >
Generating a font metrics file
</fo:block>

<fo:block space-after.optimum="6pt" >
Run the class <fo:inline font-family="Courier">org.apache.fop.fonts.apps.PFMReader</fo:inline>
to generate the XML file.
<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
java org.apache.fop.fonts.apps.PFMReader pfm-file xml-file
</fo:block>
</fo:block>

<fo:block space-after.optimum="6pt" margin-left="6pt">
Note: 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.
The PFMReader tool does not yet interpret PFB 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.
</fo:block>


<fo:block id="sec1-2"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt" >
Register the fonts within FOP
</fo:block>

<fo:block space-after.optimum="6pt">
Edit conf/userconfig.xml and add entries for the font if the fonts section, ie:
<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt"
white-space-collapse="false" margin-left="6pt" text-align="start">
<![CDATA[
<font metrics-file="cyberbit.xml" kerning="yes" embed-file="C:\WINNT\Fonts\Cyberbit.ttf">
<font-triplet name="Cyberbit" style="normal" weight="normal">
</font>]]></fo:block>
</fo:block>


<fo:block id="sec2"
font-family="Helvetica"
font-weight="bold"
font-size="14pt"
color="#0050B2"
space-after.optimum="6pt"
space-before.optimum="12pt">
Adding additional TrueType fonts
</fo:block>

<fo:block space-after.optimum="6pt">
Adding Truetype fonts is almost identical to the process of adding type 1 fonts.
The main difference is in the first step.
</fo:block>

<fo:block id="sec2-1"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt" >
Generating a font metrics file
</fo:block>

<fo:block space-after.optimum="6pt">
As mentioned above you need an XML file containing font metrics to be able to use
an additional font. FOP contains a tool that can generate such a font metrics file
from your truetype font file.
</fo:block>

<fo:block space-after.optimum="6pt">
Create metrics for the fontfile. We'll use MS Gothic as an example:

<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
java org.apache.fop.fonts.apps.TTFReader C:\WINNT\Fonts\msgothic.ttf msgothic.xml
</fo:block>
</fo:block>

<fo:block id="sec2-2"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt" >
TrueType collections
</fo:block>

<fo:block space-after.optimum="6pt">
TrueType collections (.ttc files) contains more than one font. To create metrics
for a ttc file you must specify the font in the collection with the -ttcname
option to TTFReader.
</fo:block>

<fo:block space-after.optimum="6pt">
To get a list of the fonts in a collection, just start the TTFReader as if it
were a normal truetype file (without the -ttcname option). It will then display
all the font names and exit with an Exception.
</fo:block>

<fo:block space-after.optimum="6pt">
Example on generating metrics for a .ttc file:
<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt" space-after.optimum="6pt" margin-left="6pt" text-align="start">
java org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" msmincho.ttc msminch.xml
</fo:block>
</fo:block>

<fo:block id="sec2-3"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt" >
Register the fonts within FOP
</fo:block>

<fo:block space-after.optimum="6pt">
Same as for <fo:basic-link internal-destination="sec1-2" color="blue">
<fo:inline text-decoration="underline">Type&nbsp;1&nbsp;fonts</fo:inline></fo:basic-link>.
</fo:block>


<fo:block id="sec3"
font-family="Helvetica"
font-weight="bold"
font-size="14pt"
color="#0050B2"
space-after.optimum="6pt"
space-before.optimum="12pt">
Embedding fonts
</fo:block>

<fo:block space-after.optimum="6pt">
Font embedding is enabled in the userconfig.xml file. Start Fop with -c userconfig.xml
</fo:block>


<fo:block id="sec4"
font-family="Helvetica"
font-weight="bold"
font-size="14pt"
color="#0050B2"
space-after.optimum="6pt"
space-before.optimum="12pt">
Example embedding MSGothic
</fo:block>

<fo:block space-after.optimum="6pt">
This example will use the Microsoft Gothic TrueType font. This is the font used to render this examples
given in the last section of this file. If you don't have it installed,
you can download an installer at <fo:basic-link color="blue"
external-destination="ftp://ftp.cc.monash.edu.au/pub/nihongo/ie3lpkja.exe">
<fo:inline text-decoration="underline">ftp://ftp.cc.monash.edu.au/pub/nihongo/ie3lpkja.exe</fo:inline>
</fo:basic-link>.
</fo:block>

<fo:block id="sec4-1"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt">
Setup your classpath to run FOP:
</fo:block>
<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt"
white-space-collapse="false" margin-left="6pt" text-align="start">
C:\Fop-0.18.1> set CLASSPATH=fop.jar;lib\xerces-1.2.3.jar;lib\xalan-2.0.0.jar;lib\batik.jar
</fo:block>


<fo:block id="sec4-2"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt">
Create the metrics file:
</fo:block>

<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt"
white-space-collapse="false" margin-left="6pt" text-align="start">
C:\Fop-0.18.1> java org.apache.fop.fonts.apps.TTFReader c:\WINNT\Fonts\msgothic.ttf msgothic.xml
TTF Reader v1.1.1

Reading /home/camk/cjkv/msgothic.ttf...

Number of glyphs in font: 13104
Postscript format 3
Creating xml font file...

Creating CID encoded metrics
Writing xml font file msgothic.xml...

This font contains no embedding license restrictions

</fo:block>


<fo:block id="sec4-3"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt">
Edit the msgothic.xml file and set the <fo:inline font-family="Courier">font-name</fo:inline>
to "MSGothic".
</fo:block>

<fo:block id="sec4-4"
font-family="Helvetica"
font-weight="bold"
space-after.optimum="6pt"
space-before.optimum="12pt">
Edit conf/userconfig.xml and add the following to the &lt;fonts&gt; section:
</fo:block>

<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt"
white-space-collapse="false" margin-left="6pt" text-align="start">
<![CDATA[
<font metrics-file="msgothic.xml" kerning="yes"
embed-file="C:\WINNT\Fonts\msgothic.ttf">
<font-triplet name="MSGothic" style="normal" weight="normal"/>
</font>
]]>
</fo:block>

<fo:block space-after.optimum="6pt">
Now you can use MSGothic in your .fo files by setting font-family="MSGothic". You'll need to
start FOP specifying the config file as in this example:
<fo:block font-family="Courier" font-size="10pt"
space-before.optimum="6pt"
white-space-collapse="false" margin-left="6pt" text-align="start"
>java -jar fop.jar -c conf/userconfig.xml -fo myfo.fo -pdf mypdf.pdf</fo:block>
</fo:block>

<fo:block id="sec5"
font-family="Helvetica"
font-weight="bold"
font-size="14pt"
color="#0050B2"
space-after.optimum="6pt"
space-before.optimum="12pt">
Examples from <fo:basic-link color="blue" external-destination="http://www.csse.monash.edu.au/~jwb/j_jmdict.html">
<fo:inline text-decoration="underline">JMDict</fo:inline></fo:basic-link> Japanese glossary:
</fo:block>

</fo:wrapper>
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">Japanese (kanji or kanadzukai)</fo:block></fo:table-cell>
<fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">English</fo:block></fo:table-cell>
<fo:table-cell ><fo:block font-weight="bold" font-family="Helvetica">German</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">うん</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>"yeah" or "uh huh"</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">アウタースペース</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>outer space</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">スペースクラフト</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>spacecraft</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">スペースシャトル</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>space shuttle</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">著わす</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>"to write", "to publish"</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>veröffentlichen</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">電子出版</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>electronic publishing</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">五輪</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>the Olympics</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Olympische Spiele</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">空港</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>airport</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Flughafen</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">チューリッヒ</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Zurich</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Z&#252;rich</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">コロラド</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Colorado</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row>
<fo:table-cell ><fo:block font-family="MSGothic">コロラドスプリングス</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>Colorado Springs</fo:block></fo:table-cell>
<fo:table-cell ><fo:block></fo:block></fo:table-cell>
</fo:table-row>


</fo:table-body>
</fo:table>

</fo:flow>

</fo:page-sequence>
</fo:root>

+ 561
- 0
examples/fo/advanced/cid-fonts.pdf
File diff suppressed because it is too large
View File


+ 1258
- 0
examples/fo/advanced/giro.fo
File diff suppressed because it is too large
View File


+ 126
- 0
examples/fo/advanced/rounded-corners.fo View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="main" page-width="21cm" page-height="29.7cm" margin-top="5mm">
<fo:region-body margin-bottom="30pt" margin-right="60pt" margin-left="60pt" margin-top="30pt"/>
<fo:region-after extent="4in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="main">
<fo:flow flow-name="xsl-region-body" font-size="12pt">
<fo:block font-size="14pt" font-weight="bold">
Examples using Rounded Corners
</fo:block>
<fo:block margin="20pt 0 40pt 0">
<fo:block>The "border-radius" property in the http://xmlgraphics.apache.org/fop/extensions namespace is a shorthand property for setting appropriate values for "border-*-radius" (see below), and is used to specify round corners on block areas. The property takes one or two values:
</fo:block>
<fo:block-container margin="10 20pt 20pt 20pt">
<fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="20pt" padding="20pt" text-align="center" margin-bottom="10pt"> Circular corners are specified when 'border-radius' is set to a single value. This value is the radius of the outer quadrant of the corner.</fo:block>
<fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="20pt 40pt" padding="20pt" text-align="center" margin-bottom="10pt">Quarter-ellipse corners can be generated by setting two values for the property. The first value is the radius in the Inline Progression Direction. The second value is the radius in the Block Progression Direction.
</fo:block>
</fo:block-container>
</fo:block>
<fo:block margin="20pt 0 40pt 0">
<fo:block>The radii for a specific corner can be specified for each <fo:inline font-style="italic">CORNER</fo:inline> (in 'before-start', 'before-end', 'after-start', 'after-end') with the property "border-<fo:inline font-style="italic">CORNER</fo:inline>-radius". These properties
have the same interpretation as the "border-radius" property. </fo:block>
<fo:table border-collapse="separate" margin-top="10pt">
<fo:table-column column-width="200pt"/>
<fo:table-column column-width="200pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-start-radius="100pt" height="100pt">
<fo:block padding="50pt"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block margin-left="50pt" border-style="solid" border-width="50pt 0 0 50pt" border-color="#00f" fox:border-before-start-radius="200pt 100pt" height="100pt">
<fo:block padding="50pt"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
<fo:block margin="20pt">
<fo:block border-style="solid" background-color="#aaf" border-width="10" border-color="#00f" fox:border-radius="50pt" padding="20pt" text-align="center" margin-bottom="20pt">Backgrounds are cropped&#8230;</fo:block>
<fo:block break-after="page" border-style="solid" background-color="#aaf" border-width="0" border-color="#00f" fox:border-radius="50pt" padding="20pt" text-align="center" margin-bottom="20pt">&#8230;even with zero width borders.</fo:block>
</fo:block>
<fo:block>There are two canonical cases for rounded corners distinguished by the following condition: The width of each border segment is less than the corner radius perpendicular to that segment. This is demonstrated in Case <fo:inline font-style="italic">I</fo:inline> when this condition is <fo:inline font-style="italic">true</fo:inline> and Case <fo:inline font-style="italic">II</fo:inline> when <fo:inline font-style="italic">false</fo:inline>.</fo:block>
<fo:table border-collapse="separate" margin-bottom="25pt">
<fo:table-column column-width="200pt"/>
<fo:table-column column-width="200pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell height="100pt">
<fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-start-radius="100pt" height="100pt">
<fo:block padding="50pt" text-align="center">
<fo:inline font-style="italic">I</fo:inline>
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell height="100pt">
<fo:block margin-left="50pt" border-style="solid" border-width="70pt 0 0 70pt" border-color="#00f" fox:border-before-start-radius="50pt" height="100pt">
<fo:block padding="50pt" text-align="center">
<fo:inline font-style="italic">II</fo:inline>
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table border-collapse="separate" margin="40pt 0 20pt 0" break-after="page">
<fo:table-column column-width="150pt"/>
<fo:table-column column-width="150pt"/>
<fo:table-column column-width="150pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell number-columns-spanned="3">
<fo:block margin-bottom="20pt">The border segments join at a line that coincides with the one that intersects the inner and outer corners of the equivalent rectangular corner. This is clearly demonstrated below where rounded borders are overlayed on top of rectangular borders.</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="50pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="150pt 100pt" border-before-width="50pt" border-start-width="50pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="50pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="0" border-before-color="#afa" border-start-color="#aaf" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-top="-50pt" border-style="solid" border-width="0" border-before-color="#0f0" border-start-color="#00f" fox:border-before-start-radius="150pt 100pt" border-before-width="50pt" border-start-width="100pt" height="100pt">
<fo:block margin-bottom="100pt"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:block margin="20pt 0 40pt 0">
<fo:block> </fo:block>
<fo:block-container margin="10 20pt 20pt 20pt">
<fo:block border-style="solid" border-width="10" border-color="#00f" fox:border-radius="2000pt" padding="20pt" text-align="center" margin-bottom="10pt">If border radii are specified that would produce overlapping curves (as is the case for the block containg <fo:inline font-style="italic">this</fo:inline> text), then all border radii are proportionally reduced until none of them overlap. This is in accordance to the procedure described at http://www.w3.org/TR/css3-background/#corner-overlap.</fo:block>
</fo:block-container>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 207
- 0
examples/fo/basic/alignment.fo View File

@@ -0,0 +1,207 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
<fo:region-body margin-top="25pt" margin-bottom="25pt" margin-left="20pt" margin-right="20pt" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
<fo:block><fo:inline font-weight="bold">Ex 1:</fo:inline> This
is a longer line of text that provides a context for the line with the images aligned on it.
This is a line with before-edge
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="50">
<svg:rect x="0" y="0" width="25" height="50" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="47" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 42l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, after-edge<fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="25" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="40" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, middle<fo:instream-foreign-object vertical-align="middle">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="3" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, and no<fo:instream-foreign-object>
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="40" style="stroke:black;stroke-width:1.5"/>
</svg:svg>
</fo:instream-foreign-object> alignment.
And this is the line of text that follows the line with the aligned objects on it.
And finally, this line illustrates the normal spacing between lines of text in this font.
</fo:block>

<fo:block space-after="15pt"><fo:leader leader-pattern="rule"/></fo:block>

<fo:block><fo:inline font-weight="bold">Ex 2:</fo:inline> This
is a longer line of text that provides a context for the line with the images aligned on it.
This is a line with before-edge
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="50">
<svg:rect x="0" y="0" width="25" height="50" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="47" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 42l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, after-edge<fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="25" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="40" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, middle<fo:instream-foreign-object vertical-align="middle">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="3" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object> alignment.
And this is the line of text that follows the line with the aligned objects on it.
And finally, this line illustrates the normal spacing between lines of text in this font.
</fo:block>

<fo:block space-after="15pt"><fo:leader leader-pattern="rule"/></fo:block>

<fo:block><fo:inline font-weight="bold">Ex 3:</fo:inline> This
is a longer line of text that provides a context for the line with the images aligned on it.
This is a line with before-edge
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="50">
<svg:rect x="0" y="0" width="25" height="50" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="47" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 42l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, after-edge<fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="25" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="40" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object> alignment.
And this is the line of text that follows the line with the aligned objects on it.
And finally, this line illustrates the normal spacing between lines of text in this font.
</fo:block>

<fo:block space-after="15pt"><fo:leader leader-pattern="rule"/></fo:block>

<fo:block><fo:inline font-weight="bold">Ex 4:</fo:inline> This
is a longer line of text that provides a context for the line with the images aligned on it.
This is a line with before-edge
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="37" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 32l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, after-edge<fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="25" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="50">
<svg:rect x="0" y="0" width="25" height="50" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="50" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object> alignment.
And this is the line of text that follows the line with the aligned objects on it.
And finally, this line illustrates the normal spacing between lines of text in this font.
</fo:block>

<fo:block space-after="15pt"><fo:leader leader-pattern="rule"/></fo:block>

<fo:block><fo:inline font-weight="bold">Ex 5:</fo:inline> This
is a longer line of text that provides a context for the line with the images aligned on it.
This is a line with before-edge
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="40">
<svg:rect x="0" y="0" width="25" height="40" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="0" x2="12.5" y2="37" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 32l7.5 8l7.5 -8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, after-edge<fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="25" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object><fo:instream-foreign-object vertical-align="bottom">
<svg:svg width="25" height="50">
<svg:rect x="0" y="0" width="25" height="50" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="2" x2="12.5" y2="50" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>, middle<fo:instream-foreign-object vertical-align="middle">
<svg:svg width="25" height="25">
<svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
<svg:line x1="12.5" y1="3" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
<svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
<svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object> alignment.
And this is the line of text that follows the line with the aligned objects on it.
And finally, this line illustrates the normal spacing between lines of text in this font.
</fo:block>

<fo:block space-after="15pt"><fo:leader leader-pattern="rule"/></fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 170
- 0
examples/fo/basic/blockcontainer.fo View File

@@ -0,0 +1,170 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
<fo:region-body margin-top="25pt" margin-bottom="25pt" margin-left="50pt" margin-right="50pt" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
<fo:block text-align="center" font-size="16pt" font-weight="bold">
Block Containers
</fo:block>

<fo:block>
The fo:block-container object can be used to create an area with
a different writing mode or a different reference orientation.
The areas can be part of the flow or absolutely positioned.
</fo:block>

<fo:block>
This is a normal block container within the flow layout.
<fo:block-container>
<fo:block>
BC:A
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
This block container has a different reference orientation.
<fo:block-container reference-orientation="90" inline-progression-dimension="100pt">
<fo:block>
BC:B
</fo:block>
<fo:block>
The areas are stacked normally but the orientation of the
area is rotated 90 degrees anti-clockwise.
</fo:block>
<fo:block>
The blocks continue until exhausted as the layout
height of this container is fixed in the parent
block progression dimension. The clipping of the result
is determined by the overflow property. The block
progression dimension of this container is effectively
infinite.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
This block container has a different reference orientation.
<fo:block-container reference-orientation="270" inline-progression-dimension="100pt">
<fo:block>
BC:B II
</fo:block>
<fo:block>
The areas are stacked normally but the orientation of the
area is rotated 90 degrees clockwise.
</fo:block>
<fo:block>
The blocks continue until exhausted as the layout
height of this container is fixed in the parent
block progression dimension. The clipping of the result
is determined by the overflow property.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
This block container has a different reference orientation.
<fo:block-container reference-orientation="180" inline-progression-dimension="100pt">
<fo:block>
BC:B III
</fo:block>
<fo:block>
The areas are stacked normally but the orientation of the
area is rotated 180 degrees clockwise.
</fo:block>
<fo:block>
This block container behaves as part of the flow except
the contents are drawn rotated within the viewport by
180 degrees.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
different writing mode
<fo:block-container writing-mode="rl">
<fo:block>
BC:C
</fo:block>
<fo:block>
The areas in this block are stacked according to the rl (tb)
writing mode.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
The next block-container has an absolute position. It does
not affect the flow layout of other blocks.
<fo:block-container absolute-position="absolute"
left="20pt" top="400pt" right="220pt" bottom="550pt">
<fo:block>
BC:D
</fo:block>
<fo:block>
This is a normal block that is confined to the
block container.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
The next block-container has an absolute position. It does
not affect the flow layout of other blocks. This time with
the reference-orientation set.
<fo:block-container reference-orientation="270" absolute-position="absolute"
left="400pt" top="370pt" right="500pt" bottom="270pt">
<fo:block>
BC:E
</fo:block>
<fo:block>
This is a normal block that is confined to the
block container.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block break-after="page">
End of page.
</fo:block>

<fo:block>
The next block-container tests the clipping.
<fo:block-container reference-orientation="180" absolute-position="absolute"
right="100pt" bottom="550pt" left="200pt" top="700pt"
overflow="hidden">
<fo:block>
BC:F
</fo:block>
<fo:block>
This is a normal block that is confined to the
block container. It also has contents that are
larger than the block-container so that this text
will be clipped to the viewport.
</fo:block>
</fo:block-container>
</fo:block>

<fo:block>
The next block-container tests error-if-overflow.
<fo:block-container reference-orientation="90" absolute-position="absolute"
bottom="220pt" left="600pt" top="320pt" right="700pt"
overflow="error-if-overflow">
<fo:block>
BC:G
</fo:block>
<fo:block>
This is a normal block that is confined to the
block container. It also has contents that are
larger than the block-container so that this text
will be clipped to the viewport.
</fo:block>
</fo:block-container>
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 199
- 0
examples/fo/basic/border.fo View File

@@ -0,0 +1,199 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
margin-right="0.5cm"
margin-left="0.5cm"
margin-bottom="0.5cm"
margin-top="0.75cm"
page-width="21cm"
page-height="29.7cm">
<fo:region-body></fo:region-body>
</fo:simple-page-master>
<fo:simple-page-master master-name="rest"
margin-right="2.5cm"
margin-left="2.5cm"
margin-bottom="2cm"
margin-top="1cm"
page-width="21cm"
page-height="29.7cm">
<fo:region-body></fo:region-body>
</fo:simple-page-master>

<fo:page-sequence-master master-name="psmA">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="psmA">
<fo:flow flow-name="xsl-region-body">
<fo:block-container height="4cm" width="12cm" top="0cm" left="0cm" position="absolute">
<fo:block text-align="start" line-height="18pt" font-family="sans-serif" font-weight="bold" font-size="14pt">
PX7.net
</fo:block>
<fo:block text-align="start" line-height="18pt" font-family="sans-serif" font-weight="bold" font-size="14pt">
44 Liberty St
</fo:block>
<fo:block text-align="start" line-height="18pt" font-family="sans-serif" font-weight="bold" font-size="14pt">
Newburyport, MA 01950
</fo:block>
<fo:block text-align="start" line-height="18pt" font-family="sans-serif" font-weight="bold" font-size="14pt">
978-462-1152
</fo:block>
</fo:block-container>
<fo:block-container height="1cm" width="6cm" top="0cm" left="14cm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="22pt" font-family="sans-serif" font-size="23pt">
Sales Receipt
</fo:block>
</fo:block-container>

<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="2.49cm" top="1.2cm" left="13.8cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
DATE
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="2.49cm" top="1.87cm" left="13.8cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="10pt">
01/01/2000
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="2.49cm" top="1.2cm" left="16.46cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
SALE #
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="2.49cm" top="1.87cm" left="16.46cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="10pt">
1
</fo:block>
</fo:block-container>


<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="8.95cm" top="3cm" left="0cm" padding=".6mm" position="absolute">
<fo:block text-align="start" line-height="14pt" font-family="sans-serif" font-size="12pt">
SOLD TO
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="3cm" width="8.95cm" top="3.67cm" left="0cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="8.95cm" top="3cm" left="10cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
SHIP TO
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="3cm" width="8.95cm" top="3.67cm" left="10cm" padding=".6mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
</fo:block>
</fo:block-container>


<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="3.96cm" top="7.25cm" left="10.74cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
PMT METHOD
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="3.96cm" top="8cm" left="10.74cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="10pt">
Check
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="3.96cm" top="7.25cm" left="14.95cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="12pt">
CHECK #
</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width=".5mm" height="0.5cm" width="3.96cm" top="8cm" left="14.95cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="14pt" font-family="sans-serif" font-size="10pt">
1234
</fo:block>
</fo:block-container>


<fo:block-container height="17cm" width="19cm" top="9.4cm" left="0cm" position="absolute">
<fo:table border-collapse="separate" height="17cm" border-color="yellow" border-style="solid" border-width=".6mm" table-layout="fixed" width="100%">
<fo:table-column column-width="2.5cm"/>
<fo:table-column column-width="11.5cm"/>
<fo:table-column column-width="2.5cm"/>
<fo:table-column column-width="2.5cm"/>
<fo:table-body font-family="sans-serif" font-weight="normal" font-size="10pt">
<fo:table-row line-height="12pt">
<fo:table-cell border-width="1pt" border-color="green" border-style="solid" padding="1mm">
<fo:block text-align="end">QUANTITY</fo:block>
</fo:table-cell>
<fo:table-cell border-width="1pt" border-color="red" border-style="solid" padding="1mm">
<fo:block text-align="start">DESCRIPTION</fo:block>
</fo:table-cell>
<fo:table-cell border-color="blue" border-style="solid" padding="1mm">
<fo:block text-align="center">RATE</fo:block>
</fo:table-cell>
<fo:table-cell border-color="orange" border-style="solid" padding="1mm">
<fo:block text-align="center">AMOUNT</fo:block>
</fo:table-cell>

</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell padding="2pt">
<fo:block text-align="end">1</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="start">Wide Widget</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">$22.23</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">22.31</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell padding="2pt">
<fo:block text-align="end">1</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="start">Widget</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">$22.23</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">22.31</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell padding="2pt">
<fo:block text-align="end">3</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="start">Nuts</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">$12.00</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="end">36.00</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width="0.5mm" height="1cm" width="13.31cm" top="26.5cm" left="0cm" padding="1mm" position="absolute">
<fo:block text-align="start" line-height="15pt" font-family="sans-serif" font-size="12pt">Please remit to the above address</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width="0.5mm" height="1cm" width="2.5cm" top="26.5cm" left="13.56cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="25pt" font-family="sans-serif" font-size="22pt">Total</fo:block>
</fo:block-container>
<fo:block-container border-color="black" border-style="solid" border-width="0.5mm" height="1cm" width="2.5cm" top="26.5cm" left="16.31cm" padding="1mm" position="absolute">
<fo:block text-align="start" space-after.optimum="3pt" line-height="15pt" font-family="sans-serif" font-size="10pt">$3.00</fo:block>
</fo:block-container>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 160
- 0
examples/fo/basic/bordershorthand.fo View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>


<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.0cm + 0.5cm"
margin-right="(5cm * 1cm) div 2cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="abs(-30cm + .3cm)"
page-width="(10cm * 2) + 1cm"
margin-top="round(.5) * 1cm"
margin-bottom="round(2.4) * 1cm"
margin-left="2.5 * 1cm"
margin-right="5.5cm - 3cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="1em + 4pt"
>
Border and Padding Shorthand Tests - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="min(18pt,20pt)"
font-family="sans-serif"
line-height="max(24pt,18pt)"
space-after.optimum="5 mod 3 * 7.5pt"
background-color="rgb(128,128,128)"
color="rgb(255,255,255)"
text-align="center"
padding-top="3pt">
Border and Padding Shorthand Tests
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="12pt"
text-align="start"
background-color="rgb(150,150,150)"
start-indent="3mm" end-indent="3mm"
padding-left="3mm" padding-right="3mm"
padding-top="4mm" padding-bottom="4mm"
border-style="dashed"
border-left-width="1pt" border-right-width="1pt"
border-top-width="2pt" border-bottom-width="2pt"
border-top-color="rgb(100,100,100)" border-bottom-color="rgb(200,200,200)">
In this example, padding and border properties are specified using absolute properties:
padding-left, padding-right, padding-top, and padding-bottom, etc.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="12pt"
text-align="start"
background-color="rgb(150,150,150)"
start-indent="3mm" end-indent="3mm"
padding="3mm + 1mm 3mm"
border-top="rgb(100,100,100) 1pt + 1pt dashed"
border-bottom="2pt rgb(200,200,200) solid"
border-left="solid 1pt" border-right="solid 1pt">
In this example, padding and border properties are specified using shorthand properties:
padding, border-width, border-color.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="3pt"
text-align="start"
background-color="rgb(150,150,150)"
start-indent="3mm" end-indent="3mm"
padding-before="4mm" padding-after="4mm"
padding-start.length="3mm" padding-end.length="3mm"
border-style="solid"
border-start-width="1pt" border-end-width="1pt"
border-before-width="2pt" border-after-width="2pt"
border-before-color="rgb(100,100,100)"
border-after-color="rgb(200,200,200)">
In this example, padding and border properties are specified using writing-mode relative properties:
padding-before, padding-after, padding-start, and padding-end, etc.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="3pt"
text-align="start"
background-color="rgb(200,200,200)"
start-indent="3mm" end-indent="3mm"
padding = "3mm"
padding-before="4mm" padding-after="4mm"
border-width = "2pt" border-style="solid"
border-color="black"
border-start-width="1pt" border-end-width="1pt"
border-before-width="2pt" border-after-width="2pt"
border-before-color="rgb(200,200,200)"
border-after-color="rgb(100,100,100)">
In this example, padding and border properties are specified using
shorthand and writing-mode relative properties:
padding-before, padding-after, padding-start, and padding-end, etc.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 105
- 0
examples/fo/basic/character.fo View File

@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
<!-- fo:layout-master-set defines in its children the page layout:
the pagination and layout specifications
- page-masters: have the role of describing the intended subdivisions
of a page and the geometry of these subdivisions
In this case there is only a simple-page-master which defines the
layout for all pages of the text
-->
<!-- layout information -->
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- end: defines page layout -->


<!-- start page-sequence
here comes the text (contained in flow objects)
the page-sequence can contain different fo:flows
the attribute value of master-name refers to the page layout
which is to be used to layout the text contained in this
page-sequence-->
<fo:page-sequence master-reference="simple">

<!-- start fo:flow
each flow is targeted
at one (and only one) of the following:
xsl-region-body (usually: normal text)
xsl-region-before (usually: header)
xsl-region-after (usually: footer)
xsl-region-start (usually: left margin)
xsl-region-end (usually: right margin)
['usually' applies here to languages with left-right and top-down
writing direction like English]
in this case there is only one target: xsl-region-body
-->
<fo:flow flow-name="xsl-region-body"
text-align="justify">

<!-- each paragraph is encapsulated in a block element
the attributes of the block define
font-family and size, line-heigth etc. -->


<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
>
1. Why <fo:character character="T" font-size="16pt" color="red"/><fo:character character="E" font-size="16pt" color="blue"/><fo:character character="I" font-size="16pt" color="green"/>? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why T<fo:character character="E"/>I? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. <fo:character character="Y"/>ou should use it too.
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
>
1. Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
Why TEI? I know, you know, I know (Paul Grice). Using TEI is quite a challenge. ou should use it too.
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
>
1. Why TEI? Using <fo:inline text-decoration="underline">TEI</fo:inline> is quite a challenge. <fo:character character="Y" font-size="16pt" />ou should use it too.
</fo:block>

</fo:flow> <!-- closes the flow element-->
</fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>

+ 228
- 0
examples/fo/basic/corresprop.fo View File

@@ -0,0 +1,228 @@
<?xml version="1.0" encoding="utf-8"?>


<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.0cm + 0.5cm"
margin-right="(5cm * 1cm) div 2cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="abs(-30cm + .3cm)"
page-width="(10cm * 2) + 1cm"
margin-top="round(.5) * 1cm"
margin-bottom="round(2.4) * 1cm"
margin-left="2.5 * 1cm"
margin-right="5.5cm - 3cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="1em + 4pt" >
Corresponding Property Tests - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="min(18pt,20pt)"
font-family="sans-serif"
line-height="max(24pt,18pt)"
space-after.optimum="5 mod 3 * 7.5pt"
background-color="rgb(0,0,255)"
color="rgb(255,255,255)"
text-align="center"
padding-top="3pt">
Corresponding Property Tests
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="12pt"
text-align="start"
background-color="rgb(200,200,200)"
start-indent="3mm" end-indent="3mm"
padding-left="3mm" padding-right="3mm"
padding-top="4mm" padding-bottom="4mm"
border-left-width="1pt" border-right-width="1pt"
border-top-width="2pt" border-bottom-width="2pt"
border-top-color="red" border-bottom-color="blue">
In this example, padding and border properties are specified using absolute properties:
padding-left, padding-right, padding-top, and padding-bottom, etc.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="3pt"
text-align="start"
background-color="rgb(200,200,200)"
start-indent="3mm" end-indent="3mm"
padding-before="4mm" padding-after="4mm"
padding-start.length="3mm" padding-end.length="3mm"
border-start-width="1pt" border-end-width="1pt"
border-before-width="2pt" border-after-width="2pt"
border-before-color="red" border-after-color="blue">
In this example, padding and border properties are specified using writing-mode relative properties:
padding-before, padding-after, padding-start, and padding-end, etc.
According to the specification, a request for the absolute (top, bottom, left, right) versions of these properties should use the relative ones if they are specified.
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="start"
start-indent="1cm">
This block has a start-indent of 1cm and no borders or padding. It has
no margin-left set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="start"
margin-left="1cm">
This block has a margin-left of 1cm and no borders or padding. It has
no start-indent set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="start"
start-indent="1cm"
padding-left="4mm" border-left-width="1mm">
This block has a start-indent of 1cm, padding-left of 4mm and border-left-width of 1mm. It has
no margin-left set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="start"
margin-left="5mm"
padding-left="4mm" border-left-width="1mm">
This block has a margin-left of 5mm, padding-left of 4mm and border-left-width of 1mm. (Margin is outside the border rectangle.) It has
no start-indent set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>

<!-- defines text title level 1-->
<fo:block font-size="14pt"
font-family="serif"
font-weight="bold"
line-height="16pt"
space-after="6pt"
text-align="center"
break-before="page">
End-indent tests
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="end"
end-indent="1cm">
This block has an end-indent of 1cm and no borders or padding. It has
no margin-right set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="end"
margin-right="1cm">
This block has a margin-right of 1cm and no borders or padding. It has
no end-indent set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="end"
end-indent="1cm"
padding-end="4mm" border-end-width="1mm">
This block has an end-indent of 1cm, padding-end of 4mm and border-end-width of 1mm. It has
no margin-right set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="end"
margin-right="5mm"
padding-right="4mm" border-right-width="1mm">
This block has a margin-right of 5mm, padding-right of 4mm and
border-right-width of 1mm. (Margin is outside the border rectangle.) It has
no end-indent set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-before="12pt"
space-after="3pt"
text-align="end"
margin-right="5mm"
padding-end="4mm" border-end-width="1mm">
This block has a margin-right of 5mm, padding-end of 4mm and
border-end-width of 1mm. (Margin is outside the border rectangle.) It has
no end-indent set. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text. Here is some more text to fill out the block. Here is some more text to fill out the block. Here is some more text to fill out the block.
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 148
- 0
examples/fo/basic/extensive.fo View File

@@ -0,0 +1,148 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
<fo:region-body margin-top="50pt" margin-bottom="50pt" margin-left="100pt" margin-right="100pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
<fo:block>A Block</fo:block>
<fo:block text-align="end">An End Aligned Block</fo:block>
<fo:block text-align="center">A Centered Block</fo:block>
<fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks. Alignment is default.</fo:block>
<fo:block text-align="end">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. Alignment is end.</fo:block>
<fo:block text-align="center">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. Alignment is centered.</fo:block>
<fo:block text-align="justify">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. I'm going to keep going so I can get three lines to check how all but the last justify. There, that should do it. Alignment is justified.</fo:block>
<fo:block>A block for comparison</fo:block>
<fo:block space-before.optimum="12pt">A block with 12pt space-before</fo:block>
<fo:block>A block for comparison</fo:block>
<fo:block space-after.optimum="12pt">A block with 12pt space-after</fo:block>
<fo:block>A block for comparison</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block with both 12pt space-before and space-after</fo:block>
<fo:block>A block for comparison</fo:block>
<fo:block start-indent="50pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. There is a start-indent of 50pt.</fo:block>
<fo:block end-indent="50pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. There is an end-indent of 50pt.</fo:block>
<fo:block start-indent="50pt" end-indent="50pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. There is a start-indent and end-indent of 50pt.</fo:block>
<fo:block font-size="15pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. The font-size is set to 15pt.</fo:block>
<fo:block line-height="20pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. The line-height is set to 20pt.</fo:block>
<fo:block font-size="15pt" line-height="20pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. The font-size is set to 15pt and the line-height is set to 20pt.</fo:block>
<fo:block font-size="15pt" line-height="15pt">This is a multiple line block that extends over more than one line. There should be appropriate line breaks. The font-size is set to 15pt and the line-height is set to 15pt.</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt"><fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block within a block</fo:block></fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt">Text before<fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block within a block</fo:block>Text after</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt" start-indent="50pt">Text before<fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block within a block with 50pt start-intent</fo:block>Text after</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt" start-indent="50pt">And again for the page break, text before<fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block within a block with 50pt start-intent</fo:block>Text after</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt" start-indent="50pt">Text before<fo:block space-before.optimum="12pt" space-after.optimum="12pt">A block with 50pt start-indent within a block with 50pt start-intent</fo:block>Text after</fo:block>
<fo:block space-before.optimum="12pt" space-after.optimum="12pt" start-indent="50pt">Text before<fo:block space-before.optimum="12pt" space-after.optimum="12pt" start-indent="100pt">A block with 100pt start-indent within a block with 50pt start-intent</fo:block>Text after</fo:block>
<fo:list-block provisional-distance-between-starts="12pt" space-before.optimum="12pt" text-align="justify">
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block></fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block></fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:list-block start-indent="50pt" provisional-distance-between-starts="12pt" space-before.optimum="12pt" text-align="justify">
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks. The list-block has a start-indent of 50pt and a text-align of justified.</fo:block></fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block>This is a second multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block>This is a third multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block></fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:list-block provisional-distance-between-starts="12pt" space-before.optimum="12pt" text-align="justify">
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block start-indent="100pt">This is a multiple line block with start-indent 100pt that extends over more than one line. There should be appropriate line breaks.</fo:block><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block></fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.<fo:block>This is an embedded multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block>This is a multiple line block that extends over more than one line. There should be appropriate line breaks.</fo:block></fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:list-block provisional-distance-between-starts="12pt" space-before.optimum="12pt">
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>A block in a list-item-body</fo:block></fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:list-block provisional-distance-between-starts="12pt">
<fo:list-item>
<fo:list-item-label end-indent="label-end()"><fo:block>&#x2022;</fo:block></fo:list-item-label>
<fo:list-item-body start-indent="body-start()"><fo:block>This is a list item in a list that is itself a list item</fo:block></fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:block break-before="page" font-size="24pt" line-height="28pt" space-before.optimum="12pt" space-after.optimum="12pt">Next Stage</fo:block>
<fo:block>Right, now we are ready to try some newly implemented things like rules. What follows is a display rule of default thickness 1pt and a space-before and space-after of 12pt.</fo:block>
<fo:block><fo:leader leader-pattern="rule" space-before.optimum="12pt" space-after.optimum="12pt"/></fo:block>
<fo:block>Now what follows is a leader of thickness 5pt with start-indent of 100pt (same space-before/after as before).</fo:block>
<fo:block><fo:leader leader-pattern="rule" space-before.optimum="12pt" space-after.optimum="12pt" rule-thickness="5pt" start-indent="100pt"/></fo:block>
<fo:block font-size="24pt" line-height="28pt" space-before.optimum="12pt" space-after.optimum="12pt"
><fo:inline color="#500">C</fo:inline
><fo:inline color="#700">o</fo:inline
><fo:inline color="#900">l</fo:inline
><fo:inline color="#B00">o</fo:inline
><fo:inline color="#D00">u</fo:inline
><fo:inline color="#F00">r</fo:inline
></fo:block>
<fo:block color="black">black</fo:block>
<fo:block color="green">green</fo:block>
<fo:block color="silver">silver</fo:block>
<fo:block color="lime">lime</fo:block>
<fo:block color="gray">gray</fo:block>
<fo:block color="olive">olive</fo:block>
<fo:block color="white">white</fo:block>
<fo:block color="yellow">yellow</fo:block>
<fo:block color="maroon">maroon</fo:block>
<fo:block color="navy">navy</fo:block>
<fo:block color="red">red</fo:block>
<fo:block color="blue">blue</fo:block>
<fo:block color="purple">purple</fo:block>
<fo:block color="teal">teal</fo:block>
<fo:block color="fuchsia">fuchsia</fo:block>
<fo:block color="aqua">aqua</fo:block>
<fo:block break-before="even-page" font-size="24pt" line-height="28pt" space-before.optimum="12pt" space-after.optimum="12pt">Wrap</fo:block>
<fo:block space-before.optimum="12pt">This is a rather long sentence that is going to keep on going and going, not really to demonstrate anything other that normal wrapping because the following paragraph will show what happens when wrap-option is set to no-wrap.</fo:block>
<fo:block space-before.optimum="12pt" wrap-option="no-wrap">This is a rather long sentence that is going to keep on going and going to demonstrate what happens when wrap-option is set to no-wrap which is unlike the preceding sentence where it defaults to wrap.</fo:block>
<fo:block space-before.optimum="12pt" wrap-option="wrap">This is a rather long sentence that is going to keep on going and going, not really to demonstrate anything other that normal wrapping but it differs from the first of these three sentences in that wrap is set explicitly.</fo:block>
<fo:block font-size="24pt" line-height="28pt" space-before.optimum="12pt" space-after.optimum="12pt">White Space Collapse</fo:block>
<fo:block>This is default!</fo:block>
<fo:block white-space-collapse="false">This is false!</fo:block>
<fo:block white-space-collapse="true">This is true!</fo:block>
<fo:block font-family="monospace"
white-space-collapse="false"
linefeed-treatment="preserve"
white-space-treatment="preserve"
wrap-option="no-wrap">
<![CDATA[<?xml version="1.0"?>
<document>
<heading>This is a heading</heading>
<list>
<item>Item one</item>
<item>Item two</item>
</list>
</document>]]>
</fo:block>
<fo:block break-before="page" font-size="24pt" line-height="28pt" space-before.optimum="12pt" space-after.optimum="12pt">Embedded SVG</fo:block>
<fo:block><fo:instream-foreign-object>
<svg:svg width="400pt" height="200pt">
<svg:rect style="fill:none;stroke:blue" x="20pt" y="20pt" width="100pt" height="100pt"/>
<svg:line x1="20pt" y1="20pt" x2="120pt" y2="120pt"/>
<svg:line x1="120pt" y1="20pt" x2="20pt" y2="120pt"/>
<svg:text x="20pt" y="150pt">Hello SVG!</svg:text>
</svg:svg>
</fo:instream-foreign-object></fo:block>
<fo:block>The above is an example of an SVG graphic</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>



+ 195
- 0
examples/fo/basic/fonts.fo View File

@@ -0,0 +1,195 @@
<?xml version="1.0" ?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines the layout master -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<!-- starts actual layout -->
<fo:page-sequence master-reference="first">


<fo:flow flow-name="xsl-region-body">

<fo:block font-family="Helvetica" font-size="14pt">
Helvetica
</fo:block>
<fo:block space-after.optimum="10pt" font-family="Helvetica">
&#x21; &#x22; &#x23; &#x24; &#x25; &#x26; &#x27; &#x28; &#x29; &#x2A;
&#x2B; &#x2C; &#x2D; &#x2E; &#x2F; &#x30; &#x31; &#x32; &#x33; &#x34;
&#x35; &#x36; &#x37; &#x38; &#x39; &#x3A; &#x3B; &#x3C; &#x3D; &#x3E;
&#x3F; &#x40; &#x41; &#x42; &#x43; &#x44; &#x45; &#x46; &#x47; &#x48;
&#x49; &#x4A; &#x4B; &#x4C; &#x4D; &#x4E; &#x4F; &#x50; &#x51; &#x52;
&#x53; &#x54; &#x55; &#x56; &#x57; &#x58; &#x59; &#x5A; &#x5B; &#x5C;
&#x5D; &#x5E; &#x5F; &#x60; &#x61; &#x62; &#x63; &#x64; &#x65; &#x66;
&#x67; &#x68; &#x69; &#x6A; &#x6B; &#x6C; &#x6D; &#x6E; &#x6F; &#x70;
&#x71; &#x72; &#x73; &#x74; &#x75; &#x76; &#x77; &#x78; &#x79; &#x7A;
&#x7B; &#x7C; &#x7D; &#x7E; &#xA1; &#xA2; &#xA3; &#xA4; &#xA5; &#xA6;
&#xA7; &#xA8; &#xA9; &#xAA; &#xAB; &#xAC; &#xAE; &#xAF; &#xB0; &#xB1;
&#xB2; &#xB3; &#xB4; &#xB5; &#xB6; &#xB7; &#xB8; &#xB9; &#xBA; &#xBB;
&#xBC; &#xBD; &#xBE; &#xBF; &#xC0; &#xC1; &#xC2; &#xC3; &#xC4; &#xC5;
&#xC6; &#xC7; &#xC8; &#xC9; &#xCA; &#xCB; &#xCC; &#xCD; &#xCE; &#xCF;
&#xD0; &#xD1; &#xD2; &#xD3; &#xD4; &#xD5; &#xD6; &#xD7; &#xD8; &#xD9;
&#xDA; &#xDB; &#xDC; &#xDD; &#xDE; &#xDF; &#xE0; &#xE1; &#xE2; &#xE3;
&#xE4; &#xE5; &#xE6; &#xE7; &#xE8; &#xE9; &#xEA; &#xEB; &#xEC; &#xED;
&#xEE; &#xEF; &#xF0; &#xF1; &#xF2; &#xF3; &#xF4; &#xF5; &#xF6; &#xF7;
&#xF8; &#xF9; &#xFA; &#xFB; &#xFC; &#xFD; &#xFE; &#xFF;
&#x0152; &#x0153; &#x0160; &#x0161; &#x0178;
&#x017D; &#x017E; &#x0192; &#x02DC; &#x2013; &#x2014; &#x2018;
&#x2019; &#x201A; &#x201C; &#x201D; &#x201E; &#x2020; &#x2021;
&#x2022; &#x2026; &#x2030; &#x2039; &#x203A; &#x2122;
</fo:block>

<fo:block font-family="Helvetica" font-size="14pt">
Times Roman
</fo:block>
<fo:block space-after.optimum="10pt" font-family="Times Roman">
&#x21; &#x22; &#x23; &#x24; &#x25; &#x26; &#x27; &#x28; &#x29; &#x2A;
&#x2B; &#x2C; &#x2D; &#x2E; &#x2F; &#x30; &#x31; &#x32; &#x33; &#x34;
&#x35; &#x36; &#x37; &#x38; &#x39; &#x3A; &#x3B; &#x3C; &#x3D; &#x3E;
&#x3F; &#x40; &#x41; &#x42; &#x43; &#x44; &#x45; &#x46; &#x47; &#x48;
&#x49; &#x4A; &#x4B; &#x4C; &#x4D; &#x4E; &#x4F; &#x50; &#x51; &#x52;
&#x53; &#x54; &#x55; &#x56; &#x57; &#x58; &#x59; &#x5A; &#x5B; &#x5C;
&#x5D; &#x5E; &#x5F; &#x60; &#x61; &#x62; &#x63; &#x64; &#x65; &#x66;
&#x67; &#x68; &#x69; &#x6A; &#x6B; &#x6C; &#x6D; &#x6E; &#x6F; &#x70;
&#x71; &#x72; &#x73; &#x74; &#x75; &#x76; &#x77; &#x78; &#x79; &#x7A;
&#x7B; &#x7C; &#x7D; &#x7E; &#xA1; &#xA2; &#xA3; &#xA4; &#xA5; &#xA6;
&#xA7; &#xA8; &#xA9; &#xAA; &#xAB; &#xAC; &#xAE; &#xAF; &#xB0; &#xB1;
&#xB2; &#xB3; &#xB4; &#xB5; &#xB6; &#xB7; &#xB8; &#xB9; &#xBA; &#xBB;
&#xBC; &#xBD; &#xBE; &#xBF; &#xC0; &#xC1; &#xC2; &#xC3; &#xC4; &#xC5;
&#xC6; &#xC7; &#xC8; &#xC9; &#xCA; &#xCB; &#xCC; &#xCD; &#xCE; &#xCF;
&#xD0; &#xD1; &#xD2; &#xD3; &#xD4; &#xD5; &#xD6; &#xD7; &#xD8; &#xD9;
&#xDA; &#xDB; &#xDC; &#xDD; &#xDE; &#xDF; &#xE0; &#xE1; &#xE2; &#xE3;
&#xE4; &#xE5; &#xE6; &#xE7; &#xE8; &#xE9; &#xEA; &#xEB; &#xEC; &#xED;
&#xEE; &#xEF; &#xF0; &#xF1; &#xF2; &#xF3; &#xF4; &#xF5; &#xF6; &#xF7;
&#xF8; &#xF9; &#xFA; &#xFB; &#xFC; &#xFD; &#xFE; &#xFF; &#x0152;
&#x0153; &#x0160; &#x0161; &#x0178; &#x017D; &#x017E; &#x0192;
&#x02DC; &#x2013; &#x2014; &#x2018; &#x2019; &#x201A;
&#x201C; &#x201D; &#x201E; &#x2020; &#x2021; &#x2022; &#x2026;
&#x2030; &#x2039; &#x203A; &#x2122;
</fo:block>

<fo:block font-family="Helvetica" font-size="14pt">
Courier
</fo:block>
<fo:block space-after.optimum="10pt" font-family="Courier">
&#x21; &#x22; &#x23; &#x24; &#x25; &#x26; &#x27; &#x28; &#x29; &#x2A;
&#x2B; &#x2C; &#x2D; &#x2E; &#x2F; &#x30; &#x31; &#x32; &#x33; &#x34;
&#x35; &#x36; &#x37; &#x38; &#x39; &#x3A; &#x3B; &#x3C; &#x3D; &#x3E;
&#x3F; &#x40; &#x41; &#x42; &#x43; &#x44; &#x45; &#x46; &#x47; &#x48;
&#x49; &#x4A; &#x4B; &#x4C; &#x4D; &#x4E; &#x4F; &#x50; &#x51; &#x52;
&#x53; &#x54; &#x55; &#x56; &#x57; &#x58; &#x59; &#x5A; &#x5B; &#x5C;
&#x5D; &#x5E; &#x5F; &#x60; &#x61; &#x62; &#x63; &#x64; &#x65; &#x66;
&#x67; &#x68; &#x69; &#x6A; &#x6B; &#x6C; &#x6D; &#x6E; &#x6F; &#x70;
&#x71; &#x72; &#x73; &#x74; &#x75; &#x76; &#x77; &#x78; &#x79; &#x7A;
&#x7B; &#x7C; &#x7D; &#x7E; &#xA1; &#xA2; &#xA3; &#xA4; &#xA5; &#xA6;
&#xA7; &#xA8; &#xA9; &#xAA; &#xAB; &#xAC; &#xAE; &#xAF; &#xB0; &#xB1;
&#xB2; &#xB3; &#xB4; &#xB5; &#xB6; &#xB7; &#xB8; &#xB9; &#xBA; &#xBB;
&#xBC; &#xBD; &#xBE; &#xBF; &#xC0; &#xC1; &#xC2; &#xC3; &#xC4; &#xC5;
&#xC6; &#xC7; &#xC8; &#xC9; &#xCA; &#xCB; &#xCC; &#xCD; &#xCE; &#xCF;
&#xD0; &#xD1; &#xD2; &#xD3; &#xD4; &#xD5; &#xD6; &#xD7; &#xD8; &#xD9;
&#xDA; &#xDB; &#xDC; &#xDD; &#xDE; &#xDF; &#xE0; &#xE1; &#xE2; &#xE3;
&#xE4; &#xE5; &#xE6; &#xE7; &#xE8; &#xE9; &#xEA; &#xEB; &#xEC; &#xED;
&#xEE; &#xEF; &#xF0; &#xF1; &#xF2; &#xF3; &#xF4; &#xF5; &#xF6; &#xF7;
&#xF8; &#xF9; &#xFA; &#xFB; &#xFC; &#xFD; &#xFE; &#xFF; &#x0152;
&#x0153; &#x0160; &#x0161; &#x0178; &#x017D;
&#x017E; &#x0192; &#x02DC; &#x2013; &#x2014; &#x2018;
&#x2019; &#x201A; &#x201C; &#x201D; &#x201E; &#x2020; &#x2021;
&#x2022; &#x2026; &#x2030; &#x2039; &#x203A; &#x2122;
</fo:block>

<fo:block font-family="Helvetica" font-size="14pt">
ZapfDingbats:
</fo:block>
<fo:block space-after.optimum="10pt" font-family="ZapfDingbats">
&#x2701; &#x2702; &#x2703; &#x2704; &#x260E; &#x2706; &#x2707;
&#x2708; &#x2709; &#x261B; &#x261E; &#x270C; &#x270D; &#x270E;
&#x270F; &#x2710; &#x2711; &#x2712; &#x2713; &#x2714; &#x2715;
&#x2716; &#x2717; &#x2718; &#x2719; &#x271A; &#x271B; &#x271C;
&#x271D; &#x271E; &#x271F; &#x2720; &#x2721; &#x2722; &#x2723;
&#x2724; &#x2725; &#x2726; &#x2727; &#x2605; &#x2729; &#x272A;
&#x272B; &#x272C; &#x272D; &#x272E; &#x272F; &#x2730; &#x2731;
&#x2732; &#x2733; &#x2734; &#x2735; &#x2736; &#x2737; &#x2738;
&#x2739; &#x273A; &#x273B; &#x273C; &#x273D; &#x273E; &#x273F;
&#x2740; &#x2741; &#x2742; &#x2743; &#x2744; &#x2745; &#x2746;
&#x2747; &#x2748; &#x2749; &#x274A; &#x274B; &#x25CF; &#x274D;
&#x25A0; &#x274F; &#x2750; &#x2751; &#x2752; &#x25B2; &#x25BC;
&#x25C6; &#x2756; &#x25D7; &#x2758; &#x2759; &#x275A; &#x275B;
&#x275C; &#x275D; &#x275E; &#x2761; &#x2762; &#x2763; &#x2764;
&#x2765; &#x2766; &#x2767; &#x2663; &#x2666; &#x2665; &#x2660;
&#x2460; &#x2461; &#x2462; &#x2463; &#x2464; &#x2465; &#x2466;
&#x2467; &#x2468; &#x2469; &#x2776; &#x2777; &#x2778; &#x2779;
&#x277A; &#x277B; &#x277C; &#x277D; &#x277E; &#x277F; &#x2780;
&#x2781; &#x2782; &#x2783; &#x2784; &#x2785; &#x2786; &#x2787;
&#x2788; &#x2789; &#x278A; &#x278B; &#x278C; &#x278D; &#x278E;
&#x278F; &#x2790; &#x2791; &#x2792; &#x2793; &#x2794; &#x2192;
&#x2194; &#x2195; &#x2798; &#x2799; &#x279A; &#x279B; &#x279C;
&#x279D; &#x279E; &#x279F; &#x27A0; &#x27A1; &#x27A2; &#x27A3;
&#x27A4; &#x27A5; &#x27A6; &#x27A7; &#x27A8; &#x27A9; &#x27AA;
&#x27AB; &#x27AC; &#x27AD; &#x27AE; &#x27AF; &#x27B1; &#x27B2;
&#x27B3; &#x27B4; &#x27B5; &#x27B6; &#x27B7; &#x27B8; &#x27B9;
&#x27BA; &#x27BB; &#x27BC; &#x27BD; &#x27BE; &#xF8E0; &#xF8DE;
&#xF8E3; &#xF8DD; &#xF8D7; &#xF8E1; &#xF8DB; &#xF8D8; &#xF8DF;
&#xF8DA; &#xF8D9; &#xF8DC; &#xF8E4; &#xF8E2;
</fo:block>

<fo:block font-family="Helvetica" font-size="14pt">
Symbol:
</fo:block>
<fo:block space-after.optimum="10pt" font-family="Symbol">
&#x21; &#x23; &#x25; &#x26; &#x28; &#x29; &#x2B; &#x2C; &#x2E; &#x2F;
&#x30; &#x31; &#x32; &#x33; &#x34; &#x35; &#x36; &#x37; &#x38; &#x39;
&#x3A; &#x3B; &#x3C; &#x3D; &#x3E; &#x3F; &#x5B; &#x5D; &#x5F; &#x6D;
&#x7B; &#x7C; &#x7D; &#xAC; &#xB0; &#xB1; &#xB5; &#xD7; &#xF7;
&#x0192; &#x0391; &#x0392; &#x0393; &#x0395; &#x0396; &#x0397;
&#x0398; &#x0399; &#x039A; &#x039B; &#x039C; &#x039D; &#x039E;
&#x039F; &#x03A0; &#x03A1; &#x03A3; &#x03A4; &#x03A5; &#x03A6;
&#x03A7; &#x03A8; &#x03B1; &#x03B2; &#x03B3; &#x03B4; &#x03B5;
&#x03B6; &#x03B7; &#x03B8; &#x03B9; &#x03BA; &#x03BB; &#x03BD;
&#x03BE; &#x03BF; &#x03C0; &#x03C1; &#x03C2; &#x03C3; &#x03C4;
&#x03C5; &#x03C6; &#x03C7; &#x03C8; &#x03C9; &#x03D1; &#x03D2;
&#x03D5; &#x03D6; &#x2022; &#x2026; &#x2032; &#x2033; &#x2044;
&#x2111; &#x2118; &#x211C; &#x2126; &#x2135; &#x2190; &#x2191;
&#x2192; &#x2193; &#x2194; &#x21B5; &#x21D0; &#x21D1; &#x21D2;
&#x21D3; &#x21D4; &#x2200; &#x2202; &#x2203; &#x2205; &#x2206;
&#x2207; &#x2208; &#x2209; &#x220B; &#x220F; &#x2211; &#x2212;
&#x2217; &#x221A; &#x221D; &#x221E; &#x2220; &#x2227; &#x2228;
&#x2229; &#x222A; &#x222B; &#x2234; &#x223C; &#x2245; &#x2248;
&#x2260; &#x2261; &#x2264; &#x2265; &#x2282; &#x2283; &#x2284;
&#x2286; &#x2287; &#x2295; &#x2297; &#x22A5; &#x22C5; &#x2320;
&#x2321; &#x2329; &#x232A; &#x25CA; &#x2660; &#x2663; &#x2665;
&#x2666; &#xF6D9; &#xF6DA; &#xF6DB; &#xF8E5; &#xF8E6; &#xF8E7;
&#xF8E8; &#xF8E9; &#xF8EA; &#xF8EB; &#xF8EC; &#xF8ED; &#xF8EE;
&#xF8EF; &#xF8F0; &#xF8F1; &#xF8F2; &#xF8F3; &#xF8F4; &#xF8F5;
&#xF8F6; &#xF8F7; &#xF8F8; &#xF8F9; &#xF8FA; &#xF8FB; &#xF8FC;
&#xF8FD; &#xF8FE;
</fo:block>

<fo:block font-family="Helvetica" font-size="12pt">
Some special characters:
</fo:block>
<fo:block space-after.optimum="10pt" font-family="Helvetica">
Euro ( dec 8364, hex 20AC): &#x20AC;
</fo:block>


<fo:block space-after.optimum="10pt" font-family="Helvetica">

</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 428
- 0
examples/fo/basic/hyphen.fo View File

@@ -0,0 +1,428 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
<!-- fo:layout-master-set defines in its children the page layout:
the pagination and layout specifications
- page-masters: have the role of describing the intended subdivisions
of a page and the geometry of these subdivisions
In this case there is only a simple-page-master which defines the
layout for all pages of the text
-->
<!-- layout information -->
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="7cm"
margin-right="3cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- end: defines page layout -->


<!-- start page-sequence
here comes the text (contained in flow objects)
the page-sequence can contain different fo:flows
the attribute value of master-name refers to the page layout
which is to be used to layout the text contained in this
page-sequence-->
<fo:page-sequence master-reference="simple">

<!-- start fo:flow
each flow is targeted
at one (and only one) of the following:
xsl-region-body (usually: normal text)
xsl-region-before (usually: header)
xsl-region-after (usually: footer)
xsl-region-start (usually: left margin)
xsl-region-end (usually: right margin)
['usually' applies here to languages with left-right and top-down
writing direction like English]
in this case there is only one target: xsl-region-body
-->
<fo:flow flow-name="xsl-region-body"
text-align="justify">

<!-- each paragraph is encapsulated in a block element
the attributes of the block define
font-family and size, line-heigth etc. -->

<!-- this defines a title -->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
Hyphenation tests
</fo:block>

<!-- this defines a title -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
US English
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="justify"
language="en"
country="US"
hyphenate="true"
hyphenation-push-character-count="2"
hyphenation-remain-character-count="2" >
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="justify"
language="en"
country="US"
hyphenate="true"
hyphenation-push-character-count="2"
hyphenation-remain-character-count="2" >
This document specifies a syntax created by subsetting an existing, widely used international text processing standard
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It
is a product of the W3C XML Activity, details of which can be found at the w3c website. A list of current W3C
Recommendations and other technical documents can be found there too.
</fo:block>


<!-- this defines a title -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
German
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
language="de"
hyphenate="true"
hyphenation-push-character-count="2"
hyphenation-remain-character-count="2" >
1. Warum TEI?
Die Verwendungszeit elektronischer Editionen wird von mehreren
Faktoren verkürzt: der kurzen Lebensdauer der Programme, die zu
ihrer Darstellung verwendet werden, der etwas längeren der
Betriebssysteme, unter denen die Darstellungsprogramme laufen,
der logischen Einrichtung des Datenträgers, auf dem sich die
Edition befindet, und dessen physischer Dauer. Um die besonders
unangenehme Abhängigkeit elektronischer Texte von bestimmten
Programmen und Betriebssystemen zu vermeiden, haben
Wissenschaftler ein Textauszeichnungssystem für philologische
Belange entwickelt, das nach dem Entwicklerteam "Text Encoding
Initiative" (TEI) genannt wird (1).
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
language="de"
hyphenate="true">
Das Auszeichnungssystem TEI ist eine Anwendung der Metasprache
zur Beschreibung programmunabhängiger Auszeichnungssysteme SGML
(Standard Generalized Markup Language), so wie auch HTML, mit
dem die meisten Texte des Internets zur Zeit ausgezeichnet
sind, eine Anwendung von SGML ist. Daten, die entsprechend den
TEI-Richtlinien ausgezeichnet worden sind, können also mit
jedem Programm, das SGML-Daten verarbeiten kann, dargestellt,
umgewandelt oder durchsucht werden. (2)
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
language="de"
hyphenate="true">

Verwendet wurde für die Auszeichnung 'teilite', das eine
Teilmenge des gesamten Auszeichnungssystems TEI bietet, aber
auf einige der komplexeren Merkmale verzichtet und deshalb auch
eine einfache Konvertierung der Daten zu neueren Metasprachen
für Auszeichnungssysteme wie XML, einer Teilmenge von SGML,
ermöglicht.
SGML-Programme mit der Leistungsfähigkeit von Folio Views sind
z.Zt. noch relativ teuer, daher wurde für die vorliegende
Edition der Weg gewählt, den Text doppelt auf die CD zu legen:
Einmal für die sofortige Nutzung mit einer komfortablen
Oberfläche und einmal ohne Software in einem Format, das seine
langfristige Verwendbarkeit garantiert.
Das Nachstehende soll einige Hinweise zur Einrichtung der TEI-
Dateien geben, um deren weitere Verwendung zu erleichtern.
</fo:block>



<!-- Finnish example sent in by Jarno Elovirta -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
Finnish
</fo:block>

<fo:block language="fi"
hyphenate="true">
<fo:block font-weight="bold">Internet - tuo kaiken pahan lähde?</fo:block>
<fo:block>Internet on saanut nauttia lähes täydellisestä sananvapaudesta koko
olemassaolonsa ajan. Parin viimeiksi kuluneen vuoden aikana on kuitenkin
julkisuudessa keskusteltu ahkerasti sen rajoittamisesta. Muutamat ilmaista
kotisivutilaa tarjoavat palvelut ovatkin jo kieltäneet esimerkiksi natsimia
kannattavien sivujen ylläpidon.</fo:block> <fo:block>Astetta pahempaan
suuntaan ollaan kuitenkin menossa. Nettihuutokaupoissa tarjotaan kaikkea
ihmiselimistä lähtien ja itsemurhiin etsitään avustajia itsemurhia suosivilta
nettisivustoilta. Etelä-Koreassa poliisi on pidättänyt 20-vuotiaan miehen,
jota epäillään ns. netti-itsemurhassa avustamisesta. Mies oli luvannut noin
4000 dollarin korvausta vastaan kuristaa 23-vuotiaan naisen kuoliaaksi. Nainen
tuli kuitenkin viime hetkellä toisiin ajatuksiin. Mies väittää kyseessä olleen
pelkän vitsin. Viime kuussa Etelä-Koreassa kaksi opiskelijaa myrkytti itsensä
netistä löytämiensä ohjeiden avulla.</fo:block> <fo:block>FBI puolestaan
tutkii tapausta, jossa äiti oli myynyt kaksostytöt adoptoitavaksi korkeinta
tarjousta vastaan nettihuutokaupalla. Tytöt myytiin ensin Kaliforniaan Allenin
pariskunnalle, josta äiti kuitenkin kävi ryöstämässä lapset, sillä
englantilainen Kilshawin pariskunta oli tarjonnut tytöistä tuplasumman.
Kilshawit kuljettivat lapset Englantiin ja nyt tyttöjen perässä ovat sekä
kahdet adoptiovanhemmat että iso liuta eri viranomaistahoja. Myös
Iso-Britannian pääministeri Tony Blair on pitänyt lehdistötilaisuuden
aiheeseen liittyen. Lue juttu.</fo:block> <fo:block>K2, 23:10. Lähde:
Newsbytes | 5 kommenttia</fo:block> <fo:block font-weight="bold">Mato ryömii
Linux-palvelimiin</fo:block> <fo:block>Internetissä leviää Ramen nimellä
tunnettu mato, joka ilmeisesti hyödyntää kahta tunnettua tietoturva-aukkoa Red
Hat Linuxin 6.2 ja 7.0 versioissa esiintyvissä wu-ftpd ja RPC.statd
-ohjelmissa. Jos mato pääsee sisään järjestelmään, se korvaa palvelimella
sijaitsevan HTML-pääsivun tekstillä, jossa kerrotaan hakkereiden pitävän
nuudeleista. Madon on todettu leviävän erittäin nopeasti, sillä jos kaistaa
riittää se pystyy skannaamaan jopa kaksi B-luokan verkkoa 15 minuutissa. Madon
ei ole todettu avaavan palvelimiin takaovia, joiden kautta madon kirjoittaja
pääsisi sisään järjestelmään. Lue juttu</fo:block> <fo:block>oma, 20:48.
Lähde: ZDNet | 6 kommenttia</fo:block> <fo:block font-weight="bold">Macromedia
ja Allaire yhdistyvät</fo:block> <fo:block>Macromedian ja Allairen
julkaisemissa lehdistötiedotteissa kerrotaan yhtiöiden
yhdistymissuunnitelmista. Macromedialle yrityskauppa maksaa noin 2,2 miljardia
markkaa. Uuden yhdistyneen yrityksen nimenä säilyy Macromedia ja sen johdossa
jatkaa Macromedian nykyinen toimitusjohtaja Rob Burgess. Yrityksen tuotteisiin
lukeutuvat mm. Macromedia Dreamweaver, Macromedia Flash, Allaire ColdFusion ja
Allaire JRun. Lue juttu.</fo:block>
</fo:block>

<!-- Italian example sent in by Stéphane Bline-->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
Italian
</fo:block>

<fo:block language="it"
hyphenate="true">
<fo:block
space-before.optimum="0.6em" space-before.minimum="0.4em"
space-before.maximum="0.8em">Un'applicazione di servizio consiste nell'utilizzo
di applicazioni nell'ambito aziendale, senza procedere ad installazioni locali.
L'applicazione ha la particolaritàdi essere ospitata "in-house" tramite
Intranet o presso un fornitore esterno di applicazioni di servizi (ASP, acronimo
di Application Service Provider) e di transitare grazie al protocollo di
Internet. Intermediario eventuale tra l'editore di software e il cliente che
desidera utilizzarli, il provider permette agli utenti di accedere ai vari
programmi, previo contratto d'abbonamento.</fo:block> <fo:block
space-before.optimum="0.6em" space-before.minimum="0.4em"
space-before.maximum="0.8em">L'utilizzazione in linea rende automatica la
manutenzione e l'aggiornamento delle applicazioni. A partire da una semplice
interfaccia Web installata su un thin client, l'utente può accedere via
Internet o Intranet all'insieme delle applicazioni attraverso il proprio account
personale e dedicarsi all'utilizzazione approfondita delle applicazioni
professionali.</fo:block> <fo:block font-weight="bold"
space-after.optimum="6pt">Esempio 1.1. Esempio di applicazione di
servizio</fo:block> <fo:block space-before.optimum="0.6em"
space-before.minimum="0.4em" space-before.maximum="0.8em">Si prenda il caso di
una societàA che desidera ottimizzare la comunicazione interna e la
condivisione delle informazioni. Un fornitore di applicazioni di servizio
potràrispondere rapidamente a questa aspettativa. Inoltre, potràproporre
servizi complementari che permettono di proteggere i dati di A. Dopo aver
studiato l'offerta, un responsabile della società firma con il fornitore B un
contratto d'abbonamento a un'applicazione di servizio perfettamente adattata. Le
società e B scambiano informazioni relative all'utilizzo online di questa
applicazione, come il costo del servizio, le modalitàdi pagamento e la gestione
degli account utente come i profili.</fo:block> </fo:block>


<!-- this defines a title -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
Danish
</fo:block>
<fo:block language="da"
hyphenate="true">
Bekendtgørelsen har som udkast været
notificeret i overensstemmelse med Europa-parlamentets og Rådets direktiv
98/34/EF (Informationsproceduredirektivet), som senest ændret ved direktiv
98/48/EF. Bekendtgørelsen indeholder bestemmelser der gennemfører dele af
Rådets direktiv 89/677/EØF (EF-tidende L 398 s. 19).
</fo:block>

<fo:block language="da"
hyphenate="true">
Bekendtgørelsens regler hindrer
ikke import, salg og anvendelse af produkter, der på tidspunktet for
bekendtgørelsens ikrafttræden er reguleret i medfør af anden lovgivning,
der implementerer EU-direktiver, samt anden lovgivning i øvrigt, herunder
bl.a. bekendtgørelse nr. 807 af 2. december 1986 om
begrænsning af motorbenzins indhold af blyforbindelser og benzen.
</fo:block>
<fo:block language="da"
hyphenate="true">
Import og salg af produkter, der
indeholder kemiske forbindelser af bly, er forbudt fra 1. marts 2001.
Uanset forbudet i stk.
1 er import og salg af produkter, der indeholder kemiske forbindelser af
bly, fortsat tilladt for de produktkategorier, som er nævnt i bilag
1 til denne bekendtgørelse, indtil de i bilaget anførte
tidspunkter.
</fo:block>


<!-- this defines a title -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="12pt"
background-color="blue"
color="white"
text-align="start">
Norwegian
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
language="no"
hyphenate="true">

<fo:block>
Av forståelige grunner har året 1814 vært av de mest omdiskuterte i norsk historieforskning.
Med denne bibliografien vil man for første gang få en samlet oversikt over den viktigste
historiske litteraturen omkring dette året og dets mangslungne begivenheter. Likevel har det
vært en tilnærmet umulig oppgave å få med absolutt alt som er skrevet om Riksforsamlingen og
Grunnloven i monografier, erindringsverker, bygdebøker, brevsamlinger, tidsskrifter og
aviser helt fra 1814 og til i dag. Bibliografien er et forsøk på å samle de viktigste
arbeider om 1814 som kan være av interesse både for forskere og for et bredt
historieinteressert publikum. I denne korte historiografien vil det bli gjort rede for
hvordan dette spennende året er blitt forstått og fortolket av norske og nordiske
historikere gjennom fem ulike tidsepoker.
</fo:block>
<fo:block>
Litteraturen om 1814 kan klassifiseres på flere måter. Grovt sett går det et skille mellom
tre genrer: historiske oversiktsverker, historiske spesialstudier, erindringer og dagbøker
og kilde- og dokumentutgivelser. Av oversiktsverker peker de store Norgeshistoriene seg ut
med sin relativt omfattende behandling av 1814: Nevnes kan
<fo:inline font-style="italic">Norges historie fremstillet for
det norske folk</fo:inline>, bd. VI.1 (1913),
<fo:inline font-style="italic">Det norske folks liv og historie</fo:inline> bd. VII (1933),
<fo:inline font-style="italic">Vårt folks historie</fo:inline> bd. 6 (1964),
<fo:inline font-style="italic">Cappelens Norges historie</fo:inline> bd. 9 (1978) og
<fo:inline font-style="italic">Aschehougs Norgeshistorie</fo:inline> bd. 7 (1996). Disse oversiktene er i vesentlig grad bygd på den omfattende
spesiallitteraturen i bok- eller artikkelform som har et meget vidt spenn, fra biografier
over lokale Eidsvollsmenn til krigshistoriske analyser av felttoget. Mye tidligere skjult
kunnskap er dessuten blitt hentet ut fra dagbøkene til sentrale aktører. Endelig har den
lange rekken av kildeutgivelser hatt stor betydning for forskningen omkring 1814 og bidratt
til å endre forskningsbildet flere ganger.
</fo:block>
<fo:block font-weight="bold">
1814-1864
</fo:block>
<fo:block>
Det norske samfunnet etter 1814 ble rekonstruert på den nye Grunnlovens grunn, og vernet om
den stod sentralt i den politiske kampen de neste 25 årene. Til tross for dette må man kunne
si at dokumentasjonen av hva som egentlig hadde skjedd i 1814 i mange år forble temmelig
beskjeden. Historiene levde, men da helst muntlig eller gjennom private brev og dagbøker.
Dette var kanskje en uunngåelig konsekvens av omstendighetene. Landet var fattig på kultur,
forleggere og historikere, og de politiske og økonomiske realiteter kalte mer på praktisk
fornuft enn på idealistisk pasjon. Det forekom å være en lang vei fra den nasjonale raptus
under de lyse vårukene på et grønnende Eidsvoll til den mer prosaiske og realpolitiske
aksept av union og svenskekonge i et høstlig og tåketungt Christiania. Det var den nye
Grunnloven av 4. november 1814 som gjaldt og regulerte det norske samfunnet, supplert av
Riksakten av 1815.
</fo:block>
<fo:block>
Riksforsamlingens forhandlinger i 1814 ble utgitt i 6 hefter allerede samme år av de valgte
redaktører, professor Georg Sverdrup, professor Ludvig Stoud Platou og tollprokurør
Christopher Omsen. At de ikke ble reprodusert i de følgende år, hadde sammenheng med den
svenske holdningen. Forhandlingene på det ekstraordinære Storting ble utgitt både i 1815 og
igjen i 1835, men Carl Johan oppfattet lenge interessen for Riksforsamlingen og 17. mai-
Grunnloven som en indirekte underkjenning av unionsverket og kongens politiske autoritet.
Etter påtrykk fra ham prøvde norske myndigheter å sette en stopper for offentlig feiring av
17. mai helt frem til midten av 1830-årene.
</fo:block>
<fo:block>
Rimeligvis ble da forholdet til Danmark snarere enn forholdet til Sverige ett av de første
alvorlige stridsspørsmål i perioden. Presten og Eidsvollsmannen Nicolai Wergeland ble
beryktet for den danskfiendtlige og unionsvennlige posisjon han inntok i boken
<fo:inline font-style="italic">En sandfærdig Beretning om Danmarks politiske Forbrydelser imod Kongeriget Norge
</fo:inline> (anonymt, 1816) som
fulgte nasjonalhistorien helt opp til Kielfreden. Skriftet vakte debatt og kraftige
reaksjoner ikke minst blant det gamle selvstendighetsparti. Blant annet publiserte Christian
Magnus Falsen to motskrifter i 1817. Falsen prøvde også å popularisere Grunnlovens innhold
for den mindre "oplyste" borgerklasse og allmue gjennom skriftet
<fo:inline font-style="italic">Norges Grundlov gjennemgaaet i Spørgs-maal og Svar
</fo:inline> (1818, forkortet versjon 1825). Men det må kunne påstås
at den mer detaljerte historien om grunnlovsverkets tilblivelse og første fase lenge ble
stående i noe av et halvmørke både for det alminnelige folk og for de nye generasjoner, og
at dette skyldtes den politiske situasjonen. Det var Nicolai Wergeland som leverte selve
pionerarbeidet blant de personlige kildesamlingene,
<fo:inline font-style="italic">Fortrolige Breve til en Ven, Skrevne fra
Eidsvold i Aaret 1814</fo:inline> (anonymt, 1830). Men det var først da det unionspolitiske klimaet
mildnet etter 1837 at det ble åpnet for en grundigere historisk analyse av Grunnlovens
forhistorie og tilblivelse.
</fo:block>
</fo:block>
</fo:flow> <!-- closes the flow element-->
</fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>

+ 168
- 0
examples/fo/basic/images.fo View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root font-family="Times Roman" font-size="12pt" text-align="center"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xml.apache.org/fop/extensions">

<fo:layout-master-set>
<fo:simple-page-master master-name="right"
margin-top="75pt"
margin-bottom="25pt"
margin-left="100pt"
margin-right="50pt">
<fo:region-body margin-bottom="50pt"/>
<fo:region-after extent="25pt"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="left"
margin-top="75pt"
margin-bottom="25pt"
margin-left="50pt"
margin-right="100pt">
<fo:region-body margin-bottom="50pt"/>
<fo:region-after extent="25pt"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="psmOddEven" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="right"
page-position="first" />
<fo:conditional-page-master-reference master-reference="left"
odd-or-even="even" />
<fo:conditional-page-master-reference master-reference="right"
odd-or-even="odd" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>

<fo:page-sequence id="N2528" master-reference="psmOddEven">

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align-last="center" font-size="10pt">
<fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block font-size="18pt" font-weight="bold">1. FOP test for images</fo:block>
<fo:block id="N2531">

<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A GIF image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/xml_feather.gif"/>
</fo:block>
</fo:block>
<fo:block id="N2535">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A transparent GIF image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/xml_feather_transparent.gif"/>
</fo:block>
</fo:block>
<fo:block id="N2545">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A JPEG image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/fop.jpg"/>
</fo:block>
</fo:block>
<fo:block id="N2550">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A BMP image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/linux.bmp"/>
</fo:block>
</fo:block>
<fo:block id="N2555">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A PNG image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/asf-logo.png"/>
</fo:block>
</fo:block>
<fo:block id="N2556">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em">A TIFF image in FOP</fo:block>
<fo:block>
<fo:external-graphic src="../graphics/asf-logo.tif"/>
</fo:block>
</fo:block>
<fo:block id="N2559">
<fo:block font-size="16pt" font-weight="bold" space-before.minimum="1em" space-before.optimum="1.5em" space-before.maximum="2em"/>
This section is only required to show that the layout still works.
</fo:block>
</fo:flow>

</fo:page-sequence>

<fo:page-sequence id="N2561" master-reference="psmOddEven">

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align-last="center" font-size="10pt">
<fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body" text-align="start" font-size="10pt">
<fo:block id="e-g-use" font-size="18pt" font-weight="bold">A. The usage of fo:external-graphic</fo:block>
<fo:block>
<fo:block>The image used in these examples has the following properties:</fo:block>
<fo:block start-indent="1cm">
<fo:block>169 x 51 px, 96 dpi, results in an intrinsic size of 44.715 x 13.494 mm</fo:block>
</fo:block>
<fo:block>
All the examples here will have a border="solid 0.1pt" to show the size of the viewport generated by the
external-graphic element and a background-color="yellow" to show what parts of the viewport are painted
upon by the image in the reference area. The image used is the non-transparent version of asf-logo.png:
file:../graphics/asf-logo-nt.png (nt=non-transparent)
</fo:block>
<fo:block keep-with-next.within-column="always">Properties: [none]</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: width="60mm" height="20mm"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="60mm" height="20mm" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: inline-progression-dimension="60mm" block-progression-dimension="20mm"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" inline-progression-dimension="60mm" block-progression-dimension="20mm" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: width="30mm" height="20mm"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="30mm" height="20mm" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: width="30mm" height="20mm" overflow="hidden"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="30mm" height="20mm" overflow="hidden" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: width="60mm" height="20mm" text-align="center" display-align="center"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="60mm" height="20mm" text-align="center" display-align="center" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: content-height="20mm"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" content-height="20mm" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block keep-with-next.within-column="always">Properties: content-width="60mm" content-height="40mm"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" content-width="60mm" content-height="40mm" border="solid 0.1pt" background-color="yellow"/></fo:block>

<fo:block keep-with-next.within-column="always">Properties: content-width="60mm" content-height="40mm" scaling="non-uniform"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" content-width="60mm" content-height="40mm" scaling="non-uniform" border="solid 0.1pt" background-color="yellow"/></fo:block>

<fo:block keep-with-next.within-column="always">Properties: width="60mm" height="20mm" content-width="scale-to-fit"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="60mm" height="20mm" content-width="scale-to-fit" border="solid 0.1pt" background-color="yellow"/></fo:block>

<fo:block keep-with-next.within-column="always">Properties: width="60mm" content-width="scale-to-fit"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="60mm" content-width="scale-to-fit" border="solid 0.1pt" background-color="yellow"/></fo:block>

<fo:block break-before="page"/>
<fo:block keep-with-next.within-column="always">Properties: width="100%" content-width="scale-to-fit"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="100%" content-width="scale-to-fit" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block space-before="0.5em">
The following example shows how to fit an oversized image into the
available width, but not scale smaller images up. This is a work-around
until "scale-down-to-fit" is supported. The second feather below is in
a block-container with a width of 40mm to simulate an oversized image.
</fo:block>
<fo:block keep-with-next.within-column="always">Properties: width="100%" content-width="scale-to-fit" content-height="100%"</fo:block>
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="100%" content-width="scale-to-fit" content-height="100%" border="solid 0.1pt" background-color="yellow"/></fo:block>
<fo:block-container width="40mm" background-color="lightgray">
<fo:block><fo:external-graphic src="../graphics/asf-logo-nt.png" width="100%" content-width="scale-to-fit" content-height="100%" border="solid 0.1pt" background-color="yellow"/></fo:block>
</fo:block-container>
</fo:block>
</fo:flow>

</fo:page-sequence>

</fo:root>


+ 166
- 0
examples/fo/basic/inhprop.fo View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="utf-8"?>


<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.0cm + 0.5cm"
margin-right="(5cm * 1cm) div 2cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="abs(-30cm + .3cm)"
page-width="(10cm * 2) + 1cm"
margin-top="round(.5) * 1cm"
margin-bottom="round(2.4) * 1cm"
margin-left="2.5 * 1cm"
margin-right="5.5cm - 3cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="1em + 4pt" >
Property Function Tests - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="min(18pt,20pt)"
font-family="sans-serif"
line-height="max(24pt,18pt)"
space-after.optimum="5 mod 3 * 7.5pt"
background-color="rgb(0,0,255)"
color="rgb(255,255,255)"
text-align="center"
padding-top="3pt">
Property Function Tests
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="floor(16.3) * 1pt"
font-family="sans-serif"
line-height="2pt * ceiling(9.3)"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
keep-with-next.within-page="always"
keep-together.within-page="always"
padding-top="3pt">
Function: object from-parent( <fo:inline font-weight='bold'>NCName</fo:inline>)
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after="3pt"
keep-together="auto"
text-align="start">
The from-parent function returns a computed value of the property
whose name matches the argument specified. The value returned is that
for the parent of the formatting object for which the expression is
evaluated. If there is no parent, the value returned is the initial
value. If the argument specifies a shorthand property and if the
expression only consists of the from-parent function with an argument
matching the property being computed, it is interpreted as an
expansion of the shorthand with each property into which the shorthand
expands, each having a value of from-parent with an argument matching
the property. It is an error if arguments matching a shorthand
property are used in any other way.
<fo:block font-size="from-parent(font-size) - 2pt"
font-family="sans-serif"
space-before="from-parent(space-after)"
text-align="center">
Here is a nested block with font-size =
from-parent(font-size) - 2pt.
Since its parent has font-size=12pt, that should mean 10pt. It should
keep the line height of 1.25em, which means 12.5pt leading. It's
space-before value is set to the space-after value from its
parent. Note that neither of these are inheritable. Does it look right?
</fo:block>
<fo:block font-size="from-parent(font-size) + 2pt"
space-before="2pt"
space-after="from-parent(space-after)"
font-family="sans-serif"
start-indent="from-parent(start-indent) + 1cm"
end-indent="from-parent(end-indent) + 1cm"
text-align="end"
background-color="black" color="rgb(50%,50%,50%)">
Here is a nested block with text 2pt larger than its parent (that
should be 14pt). This parent is indented 1cm on both start and end
directions with respect to the values from its parent (which aren't
specified, so they default to 0.0). The color is set to 50% (using the
rgb function with % arguements, and the background color for this
block is black (specified as a keyword). In this block, we'll put an
<fo:inline color='inherited-property-value(background-color)'
background-color='inherited-property-value(color)'>inline object</fo:inline>
whose background and foreground colors invert those of its containing
block. This uses the <fo:inline
font-style='oblique'>inherited-property-value</fo:inline>
function. Here's an <fo:inline color='black' background-color='white'>inline
object</fo:inline> with fixed colors (black on white). That doesn't
work either. Guess it's not my problem ... So let's try it with font
sizes. In this block, we'll put an
<fo:inline font-size='inherited-property-value(font-size)+2pt'>inline
object whose font-size is 2 pt bigger than its parent's font-size.</fo:inline></fo:block>
</fo:block>
<fo:block font-size="12pt"
space-before="6pt"
line-height="1em + 2pt"
font-family="sans-serif"
text-align="start"
background-color="rgb(50%,50%,50%)">
An outer block with 12 pt text on 14 pt leading, default color
and 50% grey background color. Test inherited color changes with
nested blocks.
<fo:block color='from-parent(background-color)'
background-color='from-parent(color)'>
Interchange color and background color using from-parent function.
</fo:block>
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 114
- 0
examples/fo/basic/instream.fo View File

@@ -0,0 +1,114 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
<fo:layout-master-set>
<fo:simple-page-master master-name="one">
<fo:region-body margin-top="25pt" margin-bottom="25pt" margin-left="50pt" margin-right="50pt" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">
<fo:block>This is used to show how foreign objects are placed in a line area.</fo:block>
<fo:block>
Some block text to separate instream objects.
</fo:block>
<fo:block>
Some text before
<fo:instream-foreign-object>
<svg:svg width="20" height="20">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
</svg:svg>
</fo:instream-foreign-object>
and some after the svg element.
</fo:block>
<fo:block>
A text line below the instream object.
</fo:block>
<fo:block>
<fo:instream-foreign-object>
<svg:svg width="250" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:text style="font-family:Helvetica;fill:blue" x="10" y="30">SVG placed in a block</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
<fo:block>
A text line below the block.
</fo:block>
<fo:block>
A text line with an instream foreign object that is before the line break.
<fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
</svg:svg>
</fo:instream-foreign-object>
With some text on the next line. With a bit more text to go over the to the next line.
</fo:block>
<fo:block>
A text line with an instream foreign object that is after the line break.
With some text on the next line. With a bit
<fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
</svg:svg>
</fo:instream-foreign-object>
more text to go over the to the next line.
</fo:block>
<fo:block>
A text line with an instream foreign object that is over the line break.
With some text
<fo:instream-foreign-object>
<svg:svg width="50" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="49" height="49"/>
</svg:svg>
</fo:instream-foreign-object>
on the next line. With a bit more text to go over the to the next line to
see it handles it properly.
</fo:block>
<fo:block>
The next block has an instream object wider than the area.
</fo:block>
<fo:block>
<fo:instream-foreign-object>
<svg:svg width="550" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="549" height="49"/>
<svg:text x="10" y="30">SVG placed in a really wide block</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
<fo:block>
This block has an instream object wider than the area after this text
<fo:instream-foreign-object>
<svg:svg width="550" height="50">
<svg:g style="fill:red; stroke:#000000">
<svg:rect x="0" y="0" width="15" height="15"/>
<svg:rect x="5" y="5" width="15" height="15"/>
</svg:g>
<svg:rect style="fill:none;stroke:black" x="0" y="0" width="549" height="49"/>
<svg:text style="font-family:Helvetica" x="10" y="30">SVG placed in a really wide block</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 781
- 0
examples/fo/basic/leader.fo View File

@@ -0,0 +1,781 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- examples for the use of the fo leader -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="sans-serif">

<fo:layout-master-set>

<!-- page layout -->
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="2.5cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body/>
</fo:simple-page-master>



</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="first">


<fo:flow flow-name="xsl-region-body">

<!-- Normal text -->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start"
background-color="blue"
color="white"
>
Leader examples
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
fo:leader is mainly used a) in table-of-contents to generate sequences of "." glyphs that separate titles from page numbers
b) to create entry fields in fill-in-the-blank forms c) to create horizontal rules for use as separators. You
define the look and use of fo:leader with the property "leader-pattern". It can have the following values: a) space. This
just creates an space. b) dots. This creates a sequence of "." c) rule. This creates a line. d) use-content. This creates a
repeating pattern of the content of fo:leader.
</fo:block>


<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
The dimensions of fo:leader are determined by the compound property leader-length. It consists of the
3 sub values: leader-length.minimum (default = 0), leader-length.optimum (default = 12pt), leader-length.maximum
(default = 100%). If you want to make sure, that leader-length has a fixed size, you should use the compound
property (p.e. leader-length="5cm"). If you want to fill the rest of the remaining space with dots in a table of
content, you can use the default values.
</fo:block>

<fo:block font-size="14pt"
font-family="sans-serif"
line-height="17pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start"
background-color="blue"
color="white">
leader with leader-pattern="space"
</fo:block>

<!-- Inserts a leader (space) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="space"
leader-length="6cm"/>p. 12
</fo:block>

<!-- Inserts a leader (space) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="space"
leader-length="6cm"/>p. 24
</fo:block>

<!-- Inserts a leader (space) -->
<fo:block text-align="start">Left side
<fo:leader leader-pattern="space"
leader-length="5.5cm"/>middle
<fo:leader leader-pattern="space"
leader-length="5.5cm"/>right side
</fo:block>


<fo:block font-size="14pt"
font-family="sans-serif"
line-height="17pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start"
background-color="blue"
color="white"
>
Using fo:leader with leader-pattern="dots"
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
There are two properties which allow you to specify the looks of the dotted line. First
"leader-pattern-width". It specifies the length of one dot and the space up to the next dot.
Second leader-alignment. It can be used to make sure, the dots in different lines are parallel (only value "reference-area"
is supported).
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="dots"
leader-length="6cm"/>p. 12
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-length="6cm"/>p. 24
</fo:block>


<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Using fo:leader with leader-pattern="dots" and leader-pattern-width="5pt" and "8pt"
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-length="6cm"/>p. 12
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-length="6cm"/>p. 24
</fo:block>


<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"/>p. 12
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"/>p. 24
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Using fo:leader with leader-pattern="dots" in a list
</fo:block>

<fo:block text-align="start"
space-before.optimum="12pt"
space-after.optimum="12pt">
Using fo:leader with leader-pattern="dots", leader-pattern-width="5pt" and "8pt", leader-alignment="reference-area"
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-alignment="reference-area"
leader-length="6cm"/>p. 12
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-alignment="reference-area"
leader-length="6cm"/>p. 24
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 3 is longer
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-alignment="reference-area"
leader-length="6cm"/>p. 36
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 4 is even longer
<fo:leader leader-pattern="dots"
leader-alignment="reference-area"
leader-pattern-width="5pt"
leader-length="6cm"/>p. 48
</fo:block>


<!-- Inserts a leader (dots) -->
<fo:block text-align="start">1
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"
leader-alignment="reference-area"/>p. 12
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"
leader-alignment="reference-area"/>p. 24
</fo:block>


<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 3 is longer
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"
leader-alignment="reference-area"/>p. 36
</fo:block>

<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 4 is even longer
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"
leader-alignment="reference-area"/>p. 48
</fo:block>




<!-- list start -->
<!-- use provisional-distance-between-starts to define
the distance between the start of the label and the item text

use provisional-label-separation to define the distance between
the end of the item label and the start of item text
-->
<fo:list-block provisional-distance-between-starts="0.3cm"
provisional-label-separation="0.15cm">

<!-- list item -->
<fo:list-item>
<!-- insert a bullet -->
<fo:list-item-label end-indent="label-end()">
<fo:block><fo:inline font-size="10pt">&#183;</fo:inline></fo:block>
</fo:list-item-label>
<!-- list text -->
<fo:list-item-body start-indent="body-start()">
<fo:block>
<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 1
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-length="6cm"/>p. 12
</fo:block>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<!-- list item -->
<fo:list-item>
<!-- insert a bullet -->
<fo:list-item-label end-indent="label-end()">
<fo:block><fo:inline font-size="10pt">&#183;</fo:inline></fo:block>
</fo:list-item-label>
<!-- list text -->
<fo:list-item-body start-indent="body-start()">
<fo:block>
<!-- Inserts a leader (dots) -->
<fo:block text-align="start">Entry 2
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-length="6cm"/>p. 24
</fo:block>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<!-- list end -->

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Using fo:leader with leader-pattern="dots" in a table
</fo:block>


<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="60mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>Entry 1</fo:block></fo:table-cell>
<fo:table-cell >
<fo:block text-align="start">
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"/>
</fo:block>
</fo:table-cell>
<fo:table-cell ><fo:block>p. 12</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>Entry 2 </fo:block></fo:table-cell>
<fo:table-cell >
<fo:block text-align="start">
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"/>
</fo:block>
</fo:table-cell>
<fo:table-cell ><fo:block>p. 24</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>Entry 3 </fo:block></fo:table-cell>
<fo:table-cell >
<fo:block text-align="start">
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="6cm"/>
</fo:block>
</fo:table-cell>
<fo:table-cell ><fo:block>p. 36</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->



<fo:block text-align="center"
font-size="15pt"
space-before.optimum="16pt"
space-after.optimum="12pt">
Table of Content
</fo:block>

<fo:block text-align="start"
font-size="10pt"
space-after.optimum="12pt">
shows the use of leader properties in combination to build a table of content.
Following values are used for the leader:
leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
no leader-length is specified, so the default values are used (min: 0, opt: 12pt, max: 100%)
</fo:block>


<!-- Here starts the table -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="14.2cm"/>
<fo:table-column column-width="0.3cm"/>
<fo:table-body font-size="12pt" font-family="sans-serif">

<fo:table-row line-height="12pt">
<fo:table-cell><fo:block text-align="end">A) </fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="start" text-align-last="justify">This is some longer sample text<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
/></fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="end">1</fo:block></fo:table-cell>
</fo:table-row>


<fo:table-row line-height="12pt">
<fo:table-cell><fo:block text-align="end">B) </fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="start" text-align-last="justify">Some text<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
/></fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="end">2</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row line-height="12pt">
<fo:table-cell><fo:block text-align="end" >C) </fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="start" text-align-last="justify">Text<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
/></fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="end">3</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row line-height="12pt">
<fo:table-cell><fo:block text-align="end">D) </fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="start" text-align-last="justify">This text is even longer than the first entry <fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
/></fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="end">4</fo:block></fo:table-cell>
</fo:table-row>

<fo:table-row line-height="12pt">
<fo:table-cell><fo:block text-align="end">E) </fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="start" text-align-last="justify">Shorter text example<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-alignment="reference-area"
/></fo:block></fo:table-cell>
<fo:table-cell><fo:block text-align="end">5</fo:block></fo:table-cell>
</fo:table-row>

</fo:table-body>
</fo:table>

<fo:block font-size="14pt"
font-family="sans-serif"
line-height="17pt"
space-before.optimum="15pt"
space-after.optimum="3pt"
text-align="start"
background-color="blue"
color="white"
>
Leader with leader-pattern="rule"
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="start">text before the rule (start)
<fo:leader leader-pattern="rule"
rule-thickness="3.0pt"
leader-length="6cm"
space-before.optimum="12pt"
space-after.optimum="12pt"
start-indent="1.5cm"
end-indent="2cm"
background-color="blue"
color="yellow"/>
text after the rule
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center">text before the rule (center)
<fo:leader leader-pattern="rule"
rule-thickness="3.0pt"
leader-length="6cm"
space-before.optimum="12pt"
space-after.optimum="12pt"
start-indent="1.5cm"
end-indent="2cm"
background-color="blue"
color="yellow"/>
text after the rule
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="end">text before the rule (end)
<fo:leader leader-pattern="rule"
rule-thickness="3.0pt"
leader-length="6cm"
space-before.optimum="12pt"
space-after.optimum="12pt"
start-indent="1.5cm"
end-indent="2cm"
background-color="blue"
color="yellow"/>
text after the rule
</fo:block>

<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Here are some fo:leader with the property rule and different rule styles
(solid, dashed, dotted, double, groove, ridge the last one with colored backgrounds
to the effect)
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="1pt"
leader-length="6cm"/>
</fo:block>

<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">

<fo:leader leader-pattern="rule"
leader-length="6cm"
rule-thickness="1pt"
rule-style="dashed"/>
</fo:block>


<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
leader-length="6cm"
rule-style="dotted"
rule-thickness="1pt"/>
</fo:block>

<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
leader-length="6cm"
rule-thickness="2pt"
rule-style="double"/>
</fo:block>

<fo:block text-align="center" background-color="silver"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
leader-length="6cm"
rule-thickness="1pt"
rule-style="groove"
color="black" />
</fo:block>

<fo:block text-align="center" background-color="silver"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
leader-length="6cm"
rule-thickness="1pt"
rule-style="ridge"
color="black" />
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Here are 4 fo:leader with increasing rule-thickness (1pt, 2pt, 3pt, 4pt)
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="1.0pt"
leader-length="6cm"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="6cm"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="3.0pt"
leader-length="6cm"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="4.0pt"
leader-length="6cm"/>
</fo:block>


<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-before.optimum="5pt"
space-after.optimum="3pt"
text-align="start">
Here are 4 fo:leader with increasing rule-thickness (1pt, 2pt, 3pt, 4pt) and leader-length: 25%, 50%, 75%, 100%
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="1.0pt"
leader-length="25%"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="50%"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="3.0pt"
leader-length="75%"/>
</fo:block>

<!-- Inserts a leader (rule). Because leader is an inline fo you have
to wrap it into a block element -->
<fo:block text-align="center"
space-before.optimum="12pt"
space-after.optimum="12pt">
<fo:leader leader-pattern="rule"
rule-thickness="4.0pt"
leader-length="100%"/>
</fo:block>


<fo:block text-align="center"
font-size="15pt"
space-before.optimum="16pt"
space-after.optimum="12pt">
Using leader in combination with justified text
</fo:block>


<fo:block text-align="justify">Here is some longer text. Here is some longer text.
Here is some longer text. Here comes the leader (dots width 8pt):
<fo:leader leader-pattern="dots"
leader-pattern-width="8pt"
leader-length="5cm"/>Here is some longer text. Here is some longer text.
Here is some longer text. Here is some longer text. Here is some longer text.
</fo:block>

<fo:block text-align="justify">Here is some longer text. Here is some longer text.
Here is some longer text. Here comes the leader (dots width 5pt):
<fo:leader leader-pattern="dots"
leader-pattern-width="5pt"
leader-length="5cm"/>Here is some longer text. Here is some longer text.
Here is some longer text. Here is some longer text. Here is some longer text.
</fo:block>

<fo:block text-align="justify">Here is some longer text. Here is some longer text.
Here is some longer text. Here comes the leader (dots):
<fo:leader leader-pattern="dots"
leader-length="5cm"/>Here is some longer text. Here is some longer text.
Here is some longer text. Here is some longer text. Here is some longer text.
</fo:block>


<fo:block text-align="justify">Here is some longer text. Here is some longer text.
Here is some longer text. Here comes the leader (rule):
<fo:leader leader-pattern="rule"
leader-length="5cm"/>Here is some longer text. Here is some longer text.
Here is some longer text. Here is some longer text. Here is some longer text.
</fo:block>

<fo:block text-align="justify">Here is some longer text. Here is some longer text.
Here is some longer text. Here comes the leader (space):
<fo:leader leader-pattern="space"
leader-length="5cm"/>Here is some longer text. Here is some longer text.
Here is some longer text. Here is some longer text. Here is some longer text.
</fo:block>

<fo:block space-before.optimum="15pt" font-weight="bold" font-size="14pt">
Use-Content
</fo:block>

<fo:block space-before.optimum="8pt" font-size="12pt">
The following examples show Leader with "use-content".
The inline areas from the context of the leader are
repeated until the length of the leader. The
"leader-pattern-width" can be used to set the width
of each repeated pattern element. <fo:inline font-style="italic">
If this width is less than the inline areas then the width
of the inline areas is used.</fo:inline>
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">Characters:
<fo:leader leader-pattern="use-content">abcd</fo:leader>End
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">Set width:
<fo:leader leader-pattern="use-content"
leader-pattern-width="50pt">abcd</fo:leader>End
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">Small Width:
<fo:leader leader-pattern="use-content"
leader-pattern-width="2pt">abcd</fo:leader>End
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">SVG:
<fo:leader leader-pattern="use-content">
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">
<rect x="0" y="0" width="5" height="5" style="fill:red"/>
<rect x="5" y="5" width="5" height="5" style="fill:black"/>
</svg>
</fo:instream-foreign-object>
</fo:leader>End
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">Mixed:
<fo:leader leader-pattern="use-content">
abc
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">
<rect x="0" y="0" width="5" height="5" style="fill:red"/>
<rect x="5" y="5" width="5" height="5" style="fill:black"/>
</svg>
</fo:instream-foreign-object>
</fo:leader>End
</fo:block>

<fo:block space-before.optimum="5pt" text-align="start">Mixed:
<fo:leader leader-pattern="use-content">
abc
<fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">
<rect x="0" y="0" width="5" height="5" style="fill:red"/>
<rect x="5" y="5" width="5" height="5" style="fill:black"/>
</svg>
</fo:instream-foreign-object>
def
</fo:leader>End
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 146
- 0
examples/fo/basic/link.fo View File

@@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines page layout -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="first">

<!-- text body -->
<fo:flow flow-name="xsl-region-body">

<!-- Normal text -->
<fo:block text-align="center">0. Normal text without link
</fo:block>


<!-- Normal text -->
<fo:block text-align="center"
font-family="serif">1. <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="center">
2. A one line example (text-align='start'): <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="start">
3. A multiline text (text-align='start'). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="center">
4. A multiline text (text-align='centered'). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="end">
5. A multiline text (text-align='end'). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="justify">
6. A multiline text (text-align='justify'). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="center">---</fo:block>

<!-- Normal text -->
<fo:block text-align="start"
space-before.optimum="6pt"
line-height="24pt"
font-family="serif"
padding-top="3pt"
>
7. A multiline text (text-align='start', space-before.optimum=6pt, font-family=serif padding-top="3pt"). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable <fo:basic-link external-destination="normal.pdf">generic</fo:basic-link> SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="start"
space-before.optimum="6pt"
line-height="24pt"
font-family="serif"
padding-top="3pt"
>
8. A multiline text (text-align='start', space-before.optimum=6pt, font-family=serif, padding-top="3pt"). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable <fo:basic-link external-destination="normal.pdf">generic</fo:basic-link> SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block text-align="start"
space-before.optimum="6pt"
line-height="24pt"
font-family="serif"
padding-top="3pt"
>
9. Linking to a specific page of an external:
<fo:basic-link external-destination="extensive.pdf#page=1">extensive.pdf, Page 2</fo:basic-link>.
</fo:block>

<!-- Normal text -->
<!-- <fo:block text-align="start"
space-before.optimum="6pt"
line-height="24pt"
font-family="serif"
padding-top="3pt"
>
8. A multiline text (text-align='start', space-before.optimum=6pt, font-family=serif, padding-top="3pt"). The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable <fo:basic-link external-destination="normal.pdf">generic</fo:basic-link> SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>
-->


</fo:flow>
</fo:page-sequence>
</fo:root>

+ 2690
- 0
examples/fo/basic/list.fo
File diff suppressed because it is too large
View File


+ 148
- 0
examples/fo/basic/newlinktest.fo View File

@@ -0,0 +1,148 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
margin-top="1in"
margin-bottom="1in"
margin-left="1in"
margin-right="1in">
<fo:region-body margin-top="2.5cm" margin-bottom="1.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>


</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="first">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="8pt"
font-family="serif"
line-height="14pt" >
<fo:basic-link external-destination="http://xmlgraphics.apache.org/fop"
color="rgb(150,150,150)" font-style="italic">
http://xmlgraphics.apache.org/fop
</fo:basic-link>
</fo:block>
</fo:static-content>


<fo:flow flow-name="xsl-region-body">

<fo:block space-after.optimum="3pt" font-family="serif" id="block1">
FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a formatting object
tree and then turns it into a PDF document. The formatting object
tree, can be in the form of an XML document (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif">FOP is part of Apache's XML project. The homepage of FOP is
<fo:inline font-style="italic" font-family="serif"><fo:basic-link color="blue" external-destination="http://xmlgraphics.apache.org/fop">http://xmlgraphics.apache.org/fop</fo:basic-link></fo:inline>
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="start"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="start">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="center"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="center">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="justify"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="justify">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">ugly</fo:basic-link></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">dice</fo:basic-link></fo:block></fo:table-cell>
<fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">art</fo:basic-link></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">java</fo:basic-link></fo:block></fo:table-cell>
<fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<fo:block break-before="page" space-after.optimum="12pt" font-family="serif" text-align="start" font-weight="bold">
Links in different orientations
</fo:block>

<fo:block>
This block container has a different reference orientation.
<fo:block-container reference-orientation="90" inline-progression-dimension="150pt">
<fo:block>
A link applies to the inline parent area that is created
by the basic-link. This inline area has a trait specifying
the link.
</fo:block>
<fo:block>
<fo:basic-link external-destination="http://xmlgraphics.apache.org/fop"
color="blue" text-decoration="underline">
http://xmlgraphics.apache.org/fop
</fo:basic-link>
</fo:block>
</fo:block-container>
</fo:block>


</fo:flow>

</fo:page-sequence>
</fo:root>

+ 140
- 0
examples/fo/basic/normal.fo View File

@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>


<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="21cm"
page-width="29.7cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt" >
XML Recommendation - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt"
font-variant="small-caps">
Extensible Markup Language (XML) 1.0
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="3pt">
Abstract
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
The <fo:inline font-variant="small-caps">Extensible Markup Language (XML)</fo:inline> is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML.
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="3pt">
Status of this document
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document specifies a syntax created by subsetting an existing, widely used international text processing standard
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It
is a product of the W3C XML Activity, details of which can be found at http://www.w3.org/XML. A list of current W3C
Recommendations and other technical documents can be found at http://www.w3.org/TR.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 140
- 0
examples/fo/basic/normalex.fo View File

@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>


<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations,
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="21cm"
page-width="29.7cm"
margin-top="6.3cm - 3.8cm - 1.5cm"
margin-bottom="3cm - (.25cm * 4)"
margin-left="2.0cm + 0.5cm"
margin-right="(5cm * 1cm) div 2cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="1cm + 3cm - 1cm"/>
<fo:region-after extent="2 * .5cm + .5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="abs(-30cm + .3cm)"
page-width="(10cm * 2) + 1cm"
margin-top="round(.5) * 1cm"
margin-bottom="round(2.4) * 1cm"
margin-left="2.5 * 1cm"
margin-right="5.5cm - 3cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="1em + 4pt" >
XML Recommendation - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="min(18pt,20pt)"
font-family="sans-serif"
line-height="max(24pt,18pt)"
space-after.optimum="5 mod 3 * 7.5pt"
background-color="rgb(0,0,255)"
color="rgb(100%,100%,100%)"
text-align="center"
padding-top="3pt">
Extensible Markup Language (XML) 1.0
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="floor(16.3) * 1pt"
font-family="sans-serif"
line-height="2pt * ceiling(9.3)"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="3pt">
Abstract
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="2 * (.5em + 1.5pt)"
space-after.optimum=".25 * 1em"
text-align="start">
The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML.
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="1.25"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="3pt">
Status of this document
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web.
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="1.25em"
space-after.optimum="1pc div 4"
text-align="start">
This document specifies a syntax created by subsetting an existing, widely used international text processing standard
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It
is a product of the W3C XML Activity, details of which can be found at http://www.w3.org/XML. A list of current W3C
Recommendations and other technical documents can be found at http://www.w3.org/TR.
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 1402
- 0
examples/fo/basic/pdfoutline.fo
File diff suppressed because it is too large
View File


+ 1341
- 0
examples/fo/basic/readme.fo
File diff suppressed because it is too large
View File


+ 99
- 0
examples/fo/basic/simple.fo View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- example for a simple fo file. At the beginning the page layout is set.
Below fo:root there is always
- a single fo:layout-master-set which defines one or more page layouts
- an optional fo:declarations
- and a sequence of one or more fo:page-sequences containing the text and formatting instructions
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
<!-- fo:layout-master-set defines in its children the page layout:
the pagination and layout specifications
- page-masters: have the role of describing the intended subdivisions
of a page and the geometry of these subdivisions
In this case there is only a simple-page-master which defines the
layout for all pages of the text
-->
<!-- layout information -->
<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<!-- end: defines page layout -->


<!-- start page-sequence
here comes the text (contained in flow objects)
the page-sequence can contain different fo:flows
the attribute value of master-name refers to the page layout
which is to be used to layout the text contained in this
page-sequence-->
<fo:page-sequence master-reference="simple">

<!-- start fo:flow
each flow is targeted
at one (and only one) of the following:
xsl-region-body (usually: normal text)
xsl-region-before (usually: header)
xsl-region-after (usually: footer)
xsl-region-start (usually: left margin)
xsl-region-end (usually: right margin)
['usually' applies here to languages with left-right and top-down
writing direction like English]
in this case there is only one target: xsl-region-body
-->
<fo:flow flow-name="xsl-region-body">

<!-- each paragraph is encapsulated in a block element
the attributes of the block define
font-family and size, line-heigth etc. -->

<!-- this defines a title -->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
Extensible Markup Language (XML) 1.0
</fo:block>


<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="justify">
The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML.
</fo:block>

<!-- this defines normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="justify">
The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML.
</fo:block>

</fo:flow> <!-- closes the flow element-->
</fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>

+ 504
- 0
examples/fo/basic/table.fo View File

@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">


<!-- defines the layout master -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<!-- starts actual layout -->
<fo:page-sequence master-reference="first">

<fo:flow flow-name="xsl-region-body">

<!-- this defines a title level 1-->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">
How to use table elements
</fo:block>

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center">
A simple table, 3 columns, 4 rows
</fo:block>

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>

<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>

<!-- **************************** NEW PAGE ************************************* -->

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center"
break-before="page">
A table with borders
</fo:block>


<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- table start -->
<fo:table border-width="0.5mm" border-style="solid" background-color="yellow" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- **************************** NEW PAGE ************************************* -->

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center"
break-before="page">
A table with thick borders
</fo:block>


<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- table start -->
<fo:table border-width="3mm" border-style="solid" background-color="yellow" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start" start-indent="-3mm">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- **************************** NEW PAGE ************************************* -->

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center"
break-before="page">
A table with borders around the cells
</fo:block>


<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell border-width="0.5mm" border-style="solid" background-color="yellow"><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>

<!-- **************************** NEW PAGE ************************************* -->

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center"
break-before="page">
2 tables with thick borders around the cells
</fo:block>


<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>

<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>ugly</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>dice</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>art</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>java</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell border-width="2mm" border-style="solid" background-color="yellow"><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>

<!-- **************************** NEW PAGE ************************************* -->

<!-- this defines a title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
space-after.optimum="15pt"
text-align="center"
break-before="page">
5 tables with borders
</fo:block>


<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<fo:table border-width="1.5mm" border-style="solid" background-color="rgb(100,210,250)" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="150mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell><fo:block>bad</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>


<fo:table border-width="1.5mm" border-style="solid" background-color="rgb(100,210,250)" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="150mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell><fo:block>bad</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>


<fo:table border-width="1.5mm" border-style="solid" background-color="rgb(100,210,250)" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="150mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell><fo:block>bad</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:table border-width="1.5mm" border-style="solid" background-color="rgb(100,210,250)" table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="150mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell><fo:block>bad</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<!-- normal text -->
<fo:block text-align="start">this is normal text. this is normal text. this is normal text.
this is normal text. this is normal text. this is normal text.
</fo:block>


<!-- **************************** NEW PAGE ************************************* -->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-after.optimum="3pt"
break-before="page"
text-align="justify">
A Contents table
</fo:block>

<!-- Here starts the table -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="15cm"/>
<fo:table-body font-size="10pt" font-family="sans-serif">
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">A) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">What is FOP?</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">B) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Downloading FOP</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">C) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Running FOP</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">D) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Embedding FOP </fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">E) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">What's Implemented?</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">F) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Limitations</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">G) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Bugs</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">H) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Compiling FOP</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">I) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Getting involved</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">J) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">FOP Relevant Specifications</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end">K) </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start">Licence</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 220
- 0
examples/fo/basic/tableunits.fo View File

@@ -0,0 +1,220 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">


<!-- defines the layout master -->
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm" margin-bottom="1.5cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<!-- starts actual layout -->
<fo:page-sequence master-reference="first">

<fo:flow flow-name="xsl-region-body">

<fo:block space-after="1cm" text-align="start" padding="0.4in" border="thick solid red">Table unit tests</fo:block>

<fo:table border-collapse="separate" table-layout="fixed" width="6in">
<fo:table-column column-width="(4.5in - 2cm) div 3 +1in" background-color="yellow"/>
<fo:table-column column-width="(4.5in - 2cm) div 3 + 0.5in" background-color="blue"/>
<fo:table-column column-width="(4.5in - 2cm) div 3 + 2.0cm" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>fixed width columns</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:table border-collapse="separate" table-layout="fixed" width="6in">
<fo:table-column column-width="1in + proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="2 * (proportional-column-width(1) + .5in) div 2" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1) + 2.0cm" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell background-color="blue"><fo:block>default alignment
</fo:block></fo:table-cell>
<fo:table-cell height="3cm" background-color="green" display-align="center"><fo:block>Centered with height=3cm</fo:block></fo:table-cell>
<fo:table-cell background-color="yellow" display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row height="3cm">
<fo:table-cell><fo:block>default alignment but with a height
of 3cm on the row </fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">The next table has width=100% on the table no column widths specified on the table-column element.</fo:block>
<!-- table start -->
<fo:table border-collapse="separate" table-layout="fixed" width="100%">
<fo:table-column column-width="proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">The next table has fixed column widths=13cm, ipd.optimum=12cm and ipd.max = 100%.</fo:block>
<!-- table start -->
<fo:table border-collapse="separate"
table-layout="fixed" width="100%"
inline-progression-dimension="12cm"
inline-progression-dimension.maximum="100%"
>
<fo:table-column column-width="8cm" background-color="yellow"/>
<fo:table-column column-width="proportional-column-width(2)" background-color="blue"/>
<fo:table-column column-width="5cm" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">The next table has fixed column widths=16.5cm, ipd.optimum=14cm and ipd.max = 100% (16cm).</fo:block>
<!-- table start -->
<fo:table border-collapse="separate" table-layout="fixed"
inline-progression-dimension="14cm"
inline-progression-dimension.maximum="100%">
<fo:table-column column-width="8.5cm" background-color="yellow"/>
<fo:table-column column-width="proportional-column-width(2)" background-color="blue"/>
<fo:table-column column-width="8cm" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">The next table has width="70% + 1cm" and fixed lengths and the first table-column has column-width="from-parent('width') div 3".</fo:block>
<!-- table start -->
<fo:table border-collapse="separate" table-layout="fixed" width="70% + 1cm">
<fo:table-column column-width="from-parent('width') div 3" background-color="yellow"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">
The next table specifies inline-progression-dimension="15cm" instead of width. The
middle column has a fixed width; the other two have default width.
</fo:block>
<!-- table start -->
<fo:table border-collapse="separate"
table-layout="fixed" width="100%"
inline-progression-dimension="15cm">
<fo:table-column column-width="proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="3cm" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">
The next table specifies neither width nor inline-progression-dimension.
</fo:block>
<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="3cm" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">
The next table specifies inline-progression-dimension.minimum="10cm" and
specifies a column width of 5cm on the middle column only.
</fo:block>
<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate"
inline-progression-dimension.minimum="10cm">
<fo:table-column column-width="proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="5cm" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

<fo:block space-before="12pt" space-after="6pt">
The next table specifies inline-progression-dimension.minimum=&quot;10cm&quot;,
inline-progression-dimension.maximum=&quot;17cm and
specifies a column width of 5cm on the middle column only.
</fo:block>
<!-- table start -->
<fo:table table-layout="fixed" width="100%" border-collapse="separate"
inline-progression-dimension.minimum="10cm"
inline-progression-dimension.maximum="17cm">
<fo:table-column column-width="proportional-column-width(1)" background-color="yellow"/>
<fo:table-column column-width="5cm" background-color="blue"/>
<fo:table-column column-width="proportional-column-width(1)" background-color="green"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="before"><fo:block>Some text to make this cell
deeper than the others to check out the alignment properties.</fo:block></fo:table-cell>
<fo:table-cell display-align="center"><fo:block>Centered</fo:block></fo:table-cell>
<fo:table-cell display-align="after"><fo:block>Bottom aligned</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 254
- 0
examples/fo/basic/textdeko.fo View File

@@ -0,0 +1,254 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- simple example for text-decoration -->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<!-- layout for the other pages -->
<fo:simple-page-master master-name="rest"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="2.5cm"/>
<fo:region-before extent="2.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="basicPSM" >
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first"
page-position="first" />
<fo:conditional-page-master-reference master-reference="rest"
page-position="rest" />
<!-- recommended fallback procedure -->
<fo:conditional-page-master-reference master-reference="rest" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="basicPSM">

<fo:flow flow-name="xsl-region-body">

<fo:block font-size="18pt" font-family="sans-serif" line-height="24pt" space-after.optimum="15pt"
background-color="blue" color="white" text-align="center" padding-top="3pt">
Simple example for text-decoration
</fo:block>

<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" text-align="justify" space-after.optimum="10pt">
The "text-decoration"-property describes decorations that are added to the text of an element.
If the property is specified for a block-level element, it should affect all inline-level descendants
of the element .
If it is specified for (or affects) an inline-level
element, it affects all boxes generated by the element.
</fo:block>

<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="13pt">
Example: <fo:inline text-decoration="underline">underline</fo:inline>
</fo:block>

<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="13pt" text-decoration="underline">
Block level example: underline
</fo:block>

<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" space-after.optimum="10pt">
<fo:inline font-family="monospace"><![CDATA[<fo:inline text-decoration="underline">underline</fo:inline>]]></fo:inline>
</fo:block>

<fo:block font-size="12pt"
font-family="serif"
line-height="15pt"
space-after.optimum="10pt"
text-align="start">
This is simple test of the text-decoration <fo:inline text-decoration="underline">underline</fo:inline>.
</fo:block>
<fo:block font-size="22pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="10pt"
text-align="start">
This is simple test with a <fo:inline text-decoration="underline">bigger</fo:inline> font-size.
</fo:block>
<fo:block font-size="12pt"
font-family="monospace"
line-height="15pt"
space-after.optimum="20pt"
text-align="start">
This is simple test with a <fo:inline text-decoration="underline">monospaced</fo:inline> font.

</fo:block>

<fo:block font-size="12pt" font-family="sans-serif" line-height="15pt" text-align="justify" space-after.optimum="3pt">
The following text decorations are defined in the CR:
</fo:block>

<fo:list-block space-after.optimum="13pt">

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="none">none</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="underline">underline</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="overline">overline</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="line-through">line-through</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="blink">blink</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="no-underline">no-underline</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="no-overline">no-overline</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="no-line-through">no-line-through</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>&#x2022;</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<fo:inline text-decoration="no-blink">no-blink</fo:inline>
</fo:block>
</fo:list-item-body>
</fo:list-item>

</fo:list-block>

<fo:block font-size="12pt" space-after.optimum="3pt">
<fo:inline text-decoration="underline overline">Combination</fo:inline> of property
values should also be possible.
</fo:block>

<fo:block font-size="12pt" space-after.optimum="13pt">
<fo:inline font-family="monospace"><![CDATA[<fo:inline text-decoration="underline overline">
Combination</fo:inline>]]></fo:inline>
</fo:block>


<fo:block space-after.optimum="13pt">
And now <fo:inline text-decoration="underline">more than a word ...</fo:inline>
</fo:block>

<fo:block space-after.optimum="13pt" font-size="14pt" text-decoration="underline">
This is a whole block with the property text-decoration="underline".
Some more Text to get at least two lines.
</fo:block>

<fo:block
font-family="sans-serif"
space-after.optimum="10pt"
text-align="start"
text-decoration="underline">
This is a whole block with the property text-decoration="underline" and an inline with text-decoration="overline" <fo:inline font-size="22pt" text-decoration="overline">bigger font-size</fo:inline>.
</fo:block>
<fo:block font-size="15pt"
font-family="monospace"
line-height="15pt"
space-after.optimum="10pt"
text-align="start">
This is simple test with a <fo:inline text-decoration="line-through">monospaced font</fo:inline>.
</fo:block>

<fo:block font-size="15pt"
line-height="15pt"
space-after.optimum="10pt"
text-align="start">
What about underlining of whitespace only<fo:inline text-decoration="underline"> </fo:inline>?
</fo:block>


</fo:flow>
</fo:page-sequence>
</fo:root>

+ 164
- 0
examples/fo/build.xml View File

@@ -0,0 +1,164 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- =========================================================================== -->
<project default="newPDF" basedir=".">
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<target name="init">
<tstamp/>
<mkdir dir="tests"/>
<property name="referenceDir" value="reference"/>
<property name="testDir" value="tests"/>
<property name="foDir" value="fo"/>
<path id="run-classpath">
<fileset dir="../../lib">
<include name="*.jar"/>
</fileset>
<pathelement location="../../build/fop.jar"/>
</path>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop" classpathref="run-classpath"/>
<taskdef name="compare" classname="org.apache.fop.tools.anttasks.FileCompare" classpathref="run-classpath"/>
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage">
<echo message="Use '-projecthelp' instead"/>
</target>
<!-- =================================================================== -->
<!-- Produces new test files (function) -->
<!-- =================================================================== -->
<target name="newTestFiles">
<fop format="${mimetype}" outdir="${outDir}" messagelevel="${msglevel}" relativebase="true" throwexceptions="false">
<fileset dir="basic">
<include name="**/*.fo"/>
</fileset>
<fileset dir="footnotes">
<include name="**/*.fo"/>
</fileset>
<fileset dir="pagination">
<include name="**/*.fo"/>
</fileset>
<fileset dir="keeps_and_breaks">
<include name="**/*.fo"/>
</fileset>
<fileset dir="markers">
<include name="**/*.fo"/>
</fileset>
<fileset dir="region_body">
<include name="**/*.fo"/>
</fileset>
<fileset dir="tables">
<include name="**/*.fo"/>
</fileset>
<fileset dir="svg">
<include name="**/*.fo"/>
</fileset>
<fileset dir="advanced">
<include name="**/giro.fo"/>
</fileset>
</fop>
</target>
<!-- =================================================================== -->
<!-- Produces new test PDF files -->
<!-- =================================================================== -->
<target name="newPDF" depends="init" description="Creates a new set of PDF test files">
<antcall target="newTestFiles">
<param name="mimetype" value="application/pdf"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${testDir}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Produces new test RTF files -->
<!-- =================================================================== -->
<target name="newRTF" depends="init" description="Creates a new set of RTF test files">
<antcall target="newTestFiles">
<param name="mimetype" value="application/rtf"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${testDir}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Produces new test PS files -->
<!-- =================================================================== -->
<target name="newPS" depends="init" description="Creates a new set of PostScript test files">
<antcall target="newTestFiles">
<param name="mimetype" value="application/postscript"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${testDir}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Produces new test AFP files -->
<!-- =================================================================== -->
<target name="newAFP" depends="init" description="Creates a new set of AFP test files">
<antcall target="newTestFiles">
<param name="mimetype" value="application/x-afp"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${testDir}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Produces new test areatree files -->
<!-- =================================================================== -->
<target name="newAT" depends="init" description="Creates a new set of AreaTree XML test files">
<antcall target="newTestFiles">
<param name="mimetype" value="text/xml"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${testDir}"/>
</antcall>
</target>
<!-- =================================================================== -->
<!-- Compares new test pdf files to reference pdf files -->
<!-- N.B. All comparisons fail due to differences in /CreationDate -->
<!-- =================================================================== -->
<target name="comparePDF" depends="newPDF">
<compare referenceDirectory="${referenceDir}" testDirectory="${testDir}" filenames="normal.pdf,table.pdf,list.pdf,link.pdf,border.pdf,images.pdf,extensive.pdf,readme.pdf,fonts.pdf,bordershorthand.pdf,character.pdf,corresprop.pdf,hyphen.pdf,inhprop.pdf,instream.pdf,leader.pdf,newlinktest.pdf,normalex.pdf,pdfoutline.pdf,simple.pdf,textdeko.pdf,tableunits.pdf"/>
</target>
<!-- =================================================================== -->
<!-- Produces new reference pdf files -->
<!-- =================================================================== -->
<target name="referencePDF" depends="init">
<antcall target="newTestFiles">
<param name="mimetype" value="application/pdf"/>
<param name="msglevel" value="warn"/>
<param name="outDir" value="${referenceDir}"/>
</antcall>
</target>

<!-- =================================================================== -->
<!-- Starts the test -->
<!-- N.B. All tests fail due to differences in /CreationDate -->
<!-- =================================================================== -->
<target name="runtest" depends="comparePDF">
<echo message="Running Fop tests"/>
</target>
<!-- =================================================================== -->
<!-- Clean targets -->
<!-- =================================================================== -->
<target name="clean" depends="init">
<delete dir="${testDir}"/>
</target>
<target name="cleantest" depends="init">
<delete dir="${referenceDir}"/>
</target>

</project>
<!-- End of file -->

+ 217
- 0
examples/fo/fo-reference/xml2pdf.xsl View File

@@ -0,0 +1,217 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match ="root">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines page layout -->
<fo:layout-master-set>

<fo:simple-page-master master-name="simple"
page-height="29.7cm"
page-width="21cm"
margin-top="1.5cm"
margin-bottom="1.5cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="1.5cm"/>
<fo:region-before extent="1.5cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="simple">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt" >
xsl:fo short reference - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">


<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center">
xsl:fo short reference
</fo:block>

<!-- generates table of contents and puts it into a table -->

<fo:block font-size="10pt"
font-family="sans-serif"
line-height="10pt"
space-after.optimum="3pt"
font-weight="bold"
start-indent="15pt">
Content
</fo:block>

<fo:table space-after.optimum="15pt">
<fo:table-column column-width="1cm"/>
<fo:table-column column-width="15cm"/>
<fo:table-body font-size="10pt"
font-family="sans-serif">

<xsl:for-each select="div0/head">
<fo:table-row line-height="12pt">
<fo:table-cell>
<fo:block text-align="end" >
<xsl:number value="position()" format="1"/>)
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="start" >
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>

<xsl:apply-templates/>
<fo:block font-size="10pt"
font-family="sans-serif"
line-height="11pt"
space-before.optimum="2cm">
The explanation of the flow objects is based (mostly verbatim) on the section
6.2 of the XSL W3C Candidate Recommendation 21 November 2000. More info at the beginning
of the file xslfoRef.xml.
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>


<xsl:template match ="div">
<fo:block font-size="14pt"
font-family="sans-serif"
space-before.optimum="3pt"
space-after.optimum="3pt"
text-align="center"
padding-top="3pt"
>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match ="div0/head">
<fo:block font-size="16pt"
line-height="18pt"
text-align="center"
padding-top="3pt"
start-indent="2cm"
end-indent="2cm"
background-color="blue"
color="white"
space-before.optimum="5pt"
space-after.optimum="5pt"
>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>


<xsl:template match ="div/fo">
<fo:block font-size="13pt"
line-height="14pt"
text-align="start"
>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>

<xsl:template match ="explanation">
<fo:block font-size="11pt"
font-family="sans-serif"
line-height="12pt"
text-align="start"
start-indent="0.5cm"
>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match ="div/content">
<fo:block font-size="10pt"
font-family="Courier"
start-indent="0.5cm"
line-height="11pt"
text-align="start"
wrap-option="wrap">
Content: <xsl:value-of select="."/>
</fo:block>
</xsl:template>

<xsl:template match ="div/properties">
<fo:block font-size="10pt"
font-family="Courier"
line-height="11pt"
text-align="start"
start-indent="0.5cm">
Properties:
</fo:block>
<fo:block space-after.optimum="3pt">
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match ="properties/property">
<fo:block font-size="9pt"
font-family="sans-serif"
line-height="10pt"
text-align="start"
start-indent="1cm">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>


<xsl:template match ="div/property-def">
<fo:block font-size="13pt"
line-height="14pt"
text-align="start"
>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>


<xsl:template match ="div/values">
<fo:block font-size="11pt"
text-align="start"
line-height="12pt">Values: <xsl:value-of select="."/>
</fo:block>
</xsl:template>



</xsl:stylesheet>

+ 1809
- 0
examples/fo/fo-reference/xslfoRef.xml
File diff suppressed because it is too large
View File


+ 249
- 0
examples/fo/footnotes/columns.fo View File

@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines page layout -->
<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
page-height="11in"
page-width="8.5in"
margin-top="1in"
margin-bottom="1in"
margin-left="0.75in"
margin-right="0.75in">
<fo:region-body
margin-top="1in" margin-bottom="1in"
column-count="2" column-gap="0.25in"/>
<fo:region-before extent="1in"/>
<fo:region-after extent="1in"/>
</fo:simple-page-master>

<fo:simple-page-master master-name="next"
page-height="11in"
page-width="8.5in"
margin-top="1in"
margin-bottom="1in"
margin-left="0.75in"
margin-right="0.75in">
<fo:region-body
margin-top="1in" margin-bottom="1in"
column-count="4" column-gap="0.25in"/>
<fo:region-before extent="1in"/>
<fo:region-after extent="1in"/>
</fo:simple-page-master>

</fo:layout-master-set>

<!-- actual layout -->
<fo:page-sequence master-reference="first">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="normal"
text-align="start"
color="blue">Footnotes in Columns</fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt"
font-family="sans-serif"
line-height="12pt"
space-before.optimum="6pt"
text-align="end"
color="blue">Page #</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block color="grey">
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
</fo:block>
<fo:block color="red">
The <fo:footnote>
<fo:inline font-weight="bold">footnote<fo:inline font-size="6pt" vertical-align="super">1</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="maroon">
1. A footnote is text placed at the bottom of the current page.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page.
</fo:block>
<fo:block color="grey">
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
</fo:block>
<fo:block color="green">
The <fo:footnote>
<fo:inline font-weight="bold">second footnote<fo:inline font-size="6pt" vertical-align="super">2</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="darkgreen">
2. Another footnote with a bit more text.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page after the other footnote.
</fo:block>

</fo:flow>
</fo:page-sequence>

<fo:page-sequence master-reference="next">
<fo:static-content flow-name="xsl-region-before">
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="normal"
text-align="start"
color="blue">Footnotes in Columns</fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt"
font-family="sans-serif"
line-height="12pt"
space-before.optimum="6pt"
text-align="end"
color="blue">Page #</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block color="grey">
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
</fo:block>
<fo:block color="red">
The <fo:footnote>
<fo:inline font-weight="bold">footnote<fo:inline font-size="6pt" vertical-align="super">1</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="maroon">
1. A footnote is text placed at the bottom of the current page.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page.
</fo:block>
<fo:block color="grey">
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
What shall we use to fill the empty spaces,
Where we used to talk?
How shall I fill the final places?
How shall I complete the wall?
</fo:block>
<fo:block color="green">
The <fo:footnote>
<fo:inline font-weight="bold">second footnote<fo:inline font-size="6pt" vertical-align="super">2</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="darkgreen">
2. Another footnote with a bit more text.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page after the other footnote.
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>

+ 122
- 0
examples/fo/footnotes/simple.fo View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="one"
margin-right="0.5cm"
margin-left="1.5cm"
margin-bottom="2cm"
margin-top="0cm"
page-width="21cm"
page-height="20cm">
<fo:region-body margin-bottom="2cm" margin-top="2cm"/>
<fo:region-before extent="0.5cm"/>
<fo:region-after extent="0.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="one">
<fo:flow flow-name="xsl-region-body">

<fo:block space-after.optimum="10pt" font-weight="bold" font-size="16pt" text-align="center">
Footnotes
</fo:block>

<fo:block color="red">
The <fo:footnote>
<fo:inline font-weight="bold">footnote<fo:inline font-size="6pt" vertical-align="super">1</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="maroon">
1. A footnote is text placed at the bottom of the current or the next page.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page.
</fo:block>
<fo:block color="green">
The <fo:footnote>
<fo:inline font-weight="bold">second footnote<fo:inline font-size="6pt" vertical-align="super">2</fo:inline></fo:inline>
<fo:footnote-body>
<fo:block color="darkgreen">
2. Another footnote with a bit more text.
</fo:block>
</fo:footnote-body>
</fo:footnote>
at the bottom of the page after the other footnote.
</fo:block>
<fo:block space-before.optimum="200pt" color="grey">
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
This text is used to show the body region area.
</fo:block>

<fo:block break-before="page">
This is for testing if a footnote cannot fit with the footnote
reference text.
</fo:block>
<fo:block color="grey" space-before.optimum="300pt">
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
Some filler text with no other purpose.
</fo:block>
<fo:block color="blue">
This <fo:footnote>
<fo:inline font-weight="bold">footnote</fo:inline>
<fo:footnote-body>
<fo:block color="darkblue">
A footnote with too much text to fit on the same page as the reference. Also the
reference is in the same place as the conditional footnote reference text.
</fo:block>
</fo:footnote-body>
</fo:footnote>
is at the bottom of the page where the conditional footnote reference area is.

</fo:block>

<fo:block break-before="page">
This page also has a footnote and should have the footnote from the last page.
</fo:block>
<fo:block color="grey" space-before.optimum="150pt">
More boring filler text.
More boring filler text.
More boring filler text.
</fo:block>
<fo:block color="fuchsia">
This <fo:footnote>
<fo:inline font-weight="bold">footnote</fo:inline>
<fo:footnote-body>
<fo:block color="purple">
Another footnote.
</fo:block>
</fo:footnote-body>
</fo:footnote>
is at the bottom of the page after the footnote from the previous page.

</fo:block>


</fo:flow>
</fo:page-sequence>
</fo:root>

BIN
examples/fo/graphics/asf-logo-nt.png View File


BIN
examples/fo/graphics/asf-logo.png View File


BIN
examples/fo/graphics/asf-logo.tif View File


BIN
examples/fo/graphics/fop.jpg View File


BIN
examples/fo/graphics/linux.bmp View File


BIN
examples/fo/graphics/listgeometry.gif View File


BIN
examples/fo/graphics/page.gif View File


BIN
examples/fo/graphics/xml_fax.tif View File


BIN
examples/fo/graphics/xml_feather.gif View File


BIN
examples/fo/graphics/xml_feather_transparent.gif View File


+ 289
- 0
examples/fo/keeps_and_breaks/columnlevel1.fo View File

@@ -0,0 +1,289 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file addresses breaks in column context.
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="all"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
margin-top="3cm" margin-bottom="2cm"
column-count="2" column-gap="0.25in"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt" text-align="start"
border-style="solid" border-color="blue" border-width="0.5pt"
space-before.optimum="6pt">
Text excerpt from XSL Candidate Recommendation, 21 Nov 2000.
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="column">
This is a block with a <fo:inline font-style="italic">break-before="column"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in a column context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="column">
This is a block with a <fo:inline font-style="italic">break-before="column"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in a column context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

<fo:block span="all">
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="14cm"
space-before.optimum="0pt"
space-after.optimum="12pt"
start-indent="1cm"
end-indent="1cm"
background-color="blue"
color="yellow"/>
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="column">
This is a block with a <fo:inline font-style="italic">break-after="column"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in a column
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="column">
This is a block with a <fo:inline font-style="italic">break-after="column"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in a column context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 137
- 0
examples/fo/keeps_and_breaks/pagelevel1.fo View File

@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file addresses breaks in page context.
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="all"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm" margin-bottom="2cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt" text-align="start"
border-style="solid" border-color="blue" border-width="0.5pt">
Text excerpt from XSL Candidate Recommendation, 21 Nov 2000.
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
break-after="page">
<fo:inline color="red">break-after="page"</fo:inline>
Break conditions are either break-before or break-after conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-after condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-after
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-after trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
break-before="page">
<fo:inline color="red">break-before="page"</fo:inline>
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 292
- 0
examples/fo/keeps_and_breaks/pagelevel2.fo View File

@@ -0,0 +1,292 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file addresses break-after's in page context.
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="all"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm" margin-bottom="2cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt" text-align="start"
border-style="solid" border-color="blue" border-width="0.5pt"
space-before.optimum="6pt">
Text excerpt from XSL Candidate Recommendation, 21 Nov 2000.
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-after conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-after condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="even-page">
This is a block with a <fo:inline font-style="italic">break-after="even-page"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-after
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-after trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="even-page">
This is a block with a <fo:inline font-style="italic">break-after="even-page"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

<fo:block>
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="14cm"
space-before.optimum="0pt"
space-after.optimum="12pt"
start-indent="1cm"
end-indent="1cm"
background-color="blue"
color="yellow"/>
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="odd-page">
This is a block with a <fo:inline font-style="italic">break-after="odd-page"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-after conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-after condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-after
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-after trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-after="odd-page">
This is a block with a <fo:inline font-style="italic">break-after="odd-page"
</fo:inline> break condition. This condition is satisfied if there is
no next formatting object, <fo:inline font-weight="bold">or</fo:inline> the
first normal area generated by the next FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 288
- 0
examples/fo/keeps_and_breaks/pagelevel3.fo View File

@@ -0,0 +1,288 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file addresses break-before's in page context.
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="all"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm" margin-bottom="2cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt" text-align="start"
border-style="solid" border-color="blue" border-width="0.5pt"
space-before.optimum="6pt">
Text excerpt from XSL Candidate Recommendation, 21 Nov 2000.
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="even-page">
This is a block with a <fo:inline font-style="italic">break-before="even-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="even-page">
This is a block with a <fo:inline font-style="italic">break-before="even-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

<fo:block>
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="14cm"
space-before.optimum="0pt"
space-after.optimum="12pt"
start-indent="1cm"
end-indent="1cm"
background-color="blue"
color="yellow"/>
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="odd-page">
This is a block with a <fo:inline font-style="italic">break-before="odd-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="odd-page">
This is a block with a <fo:inline font-style="italic">break-before="odd-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 291
- 0
examples/fo/keeps_and_breaks/pagelevel4.fo View File

@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
This file addresses breaks in page context, with a
2-column layout.
-->

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="all"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
margin-top="3cm" margin-bottom="2cm"
column-count="2" column-gap="0.25in"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="all">
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="10pt" text-align="start"
border-style="solid" border-color="blue" border-width="0.5pt"
space-before.optimum="6pt">
Text excerpt from XSL Candidate Recommendation, 21 Nov 2000.
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="even-page">
This is a block with a <fo:inline font-style="italic">break-before="even-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="even-page">
This is a block with a <fo:inline font-style="italic">break-before="even-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an even-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

<fo:block span="all">
<fo:leader leader-pattern="rule"
rule-thickness="2.0pt"
leader-length="14cm"
space-before.optimum="0pt"
space-after.optimum="12pt"
start-indent="1cm"
end-indent="1cm"
background-color="blue"
color="yellow"/>
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep and break conditions apply to a class of areas, which are typically
page-reference-areas, column-areas, and line-areas. The appropriate class
for a given condition is referred to as a context and an area in this
class is a context-area. As defined in Section 6.4.1, page-reference-areas
are areas generated by an fo:page-sequence using the specifications in a
fo:page-master, and column-areas are normal-flow-reference-areas generated
from a region-body, or region-reference-areas generated from other types
of region-master.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
A keep or break condition is an open statement about a formatting object
and the tree relationships of the areas it generates with the relevant
context-areas. These tree relationships are defined mainly in terms of
leading or trailing areas. If A is a descendant of P, then A is defined
to be leading in P if A has no preceding sibling which is a normal area,
nor does any of its ancestor areas up to but not including P. Similarly,
A is defined to be trailing in P if A has no following sibling which is
a normal area, nor does any of its ancestor areas up to but not including P.
For any given formatting object, the next formatting object in the flow is
the first formatting object following (in the pre-order traversal order)
which generates and returns normal areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="odd-page">
This is a block with a <fo:inline font-style="italic">break-before="odd-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are either break-before or break-before conditions.
A break-before condition is satisfied if the first area generated and
returned by the formatting object is leading within a context-area. A
break-before condition depends on the next formatting object in the flow;
it is satisfied if either there is no such next formatting object, or
if the first normal area generated and returned by that formatting
object is leading in a context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Break conditions are imposed by the break-before and break-before
properties. A refined value of page for these traits imposes a break
condition with a context consisting of the page-reference-areas; a
value of even-page or odd-page imposes a break condition with a
context of even-numbered page-reference-areas or odd-numbered page
reference-areas, respectively; a value of column imposes a break
condition with a context of column-areas. A value of auto in a
break-before or break-before trait imposes no break condition.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are either keep-with-previous, keep-with-next, or
keep-together conditions. A keep-with-previous condition on an
object is satisfied if the first area generated and returned by
the formatting object is not leading within a context-area, or
if there are no preceding areas in a post-order traversal of the
area tree. A keep-with-next condition is satisfied if the last
area generated and returned by the formatting object is not
trailing within a context-area, or if there are no following
areas in a pre-order traversal of the area tree. A keep-together
condition is satisfied if all areas generated and returned by
the formatting object are descendants of a single context-area.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
Keep conditions are imposed by the "within-page", "within-column",
and "within-line" components of the "keep-with-previous",
"keep-with-next", and "keep-together" properties. The refined value
of each component specifies the strength of the keep condition
imposed, with higher numbers being stronger than lower numbers and
the value always being stronger than all numeric values. A component
with value auto does not impose a keep condition. A "within-page"
component imposes a keep-condition with context consisting of the
page-reference-areas; "within-column", with context consisting of
the column-areas; and "within-line" with context consisting of the
line-areas.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt"
color="blue"
break-before="odd-page">
This is a block with a <fo:inline font-style="italic">break-before="odd-page"
</fo:inline> break condition. This condition is satisfied if the
first normal area generated by this FO is leading in an odd-page
context.
</fo:block>

<fo:block
font-size="14pt" font-family="sans-serif"
line-height="18pt" space-after.optimum="15pt">
The area tree is constrained to satisfy all break conditions imposed.
Each keep condition must also be satisfied, except when this would
cause a break condition or a stronger keep condition to fail to be
satisfied. If not all of a set of keep conditions of equal strength
can be satisfied, then some maximal satisfiable subset of conditions
of that strength must be satisfied (together with all break conditions
and maximal subsets of stronger keep conditions, if any).
</fo:block>

</fo:flow>
</fo:page-sequence>
</fo:root>


+ 314
- 0
examples/fo/markers/glossary.xml View File

@@ -0,0 +1,314 @@
<?xml version="1.0"?>
<glossary>
<term-entry>
<term>basic-link</term>
<definition>The fo:basic-link is used for representing the start resource
of a simple link.</definition>
</term-entry>
<term-entry>
<term>bidi-override</term>
<definition>The fo:bidi-override inline formatting object is used where
it is necessary to override the default Unicode-bidirectionality
algorithm direction for different (or nested) inline scripts in
mixed-language documents.</definition>
</term-entry>
<term-entry>
<term>block</term>
<definition>The fo:block formatting object is commonly used for formatting
paragraphs, titles, headlines, figure and table captions, etc.</definition>
</term-entry>
<term-entry>
<term>block-container</term>
<definition>The fo:block-container flow object is used to generate a
block-level reference-area.</definition>
</term-entry>
<term-entry>
<term>character</term>
<definition>The fo:character flow object represents a character that is
mapped to a glyph for presentation.</definition>
</term-entry>
<term-entry>
<term>color-profile</term>
<definition>Used to declare a color profile for a stylesheet.</definition>
</term-entry>
<term-entry>
<term>conditional-page-master-reference</term>
<definition>The fo:conditional-page-master-reference
is used to identify a page-master that is to be used when the conditions
on its use are satisfied.</definition>
</term-entry>
<term-entry>
<term>declarations</term>
<definition>Used to group global declarations for a stylesheet.</definition>
</term-entry>
<term-entry>
<term>external-graphic</term>
<definition>The fo:external-graphic flow object is used for a graphic
where the graphics data resides outside of the XML result tree in the
fo namespace.</definition>
</term-entry>
<term-entry>
<term>float</term>
<definition>The fo:float serves two purposes. It can be used so that during the
normal placement of content, some related content is formatted into a
separate area at beginning of the page (or of some following page) where
it is available to be read without immediately intruding on the reader.
Alternatively, it can be used when an area is intended to float to one
side, with normal content flowing alongside.</definition>
</term-entry>
<term-entry>
<term>flow</term>
<definition>The content of the fo:flow formatting object is a sequence
of flow objects that provides the flowing text content that is distributed
into pages.</definition>
</term-entry>
<term-entry>
<term>footnote</term>
<definition>The fo:footnote is used to produce a footnote citation and the
corresponding footnote.</definition>
</term-entry>
<term-entry>
<term>footnote-body</term>
<definition>The fo:footnote-body is used to generate the content of the
footnote.</definition>
</term-entry>
<term-entry>
<term>initial-property-set</term>
<definition>The fo:initial-property-set specifies formatting properties
for the first line of an fo:block.</definition>
</term-entry>
<term-entry>
<term>inline</term>
<definition>The fo:inline formatting object is commonly used for
formatting a portion of text with a background or enclosing it in a
border.</definition>
</term-entry>
<term-entry>
<term>inline-container</term>
<definition>The fo:inline-container flow object is used to generate an
inline reference-area.</definition>
</term-entry>
<term-entry>
<term>instream-foreign-object</term>
<definition>The fo:instream-foreign-object flow object is used for an
inline graphic or other "generic" object where the object data resides
as descendants of the fo:instream-foreign-object.</definition>
</term-entry>
<term-entry>
<term>layout-master-set</term>
<definition>The fo:layout-master-set is a wrapper around all masters used
in the document.</definition>
</term-entry>
<term-entry>
<term>leader</term>
<definition>The fo:leader formatting object is used to generate leaders
consisting either of a rule or of a row of a repeating character or
cyclically repeating pattern of characters that may be used for connecting
two text formatting objects.</definition>
</term-entry>
<term-entry>
<term>list-block</term>
<definition>The fo:list-block flow object is used to format a list.</definition>
</term-entry>
<term-entry>
<term>list-item</term>
<definition>The fo:list-item formatting object contains the label and the
body of an item in a list.</definition>
</term-entry>
<term-entry>
<term>list-item-body</term>
<definition>The fo:list-item-body formatting object contains the content
of the body of a list-item.</definition>
</term-entry>
<term-entry>
<term>list-item-label</term>
<definition>The fo:list-item-label formatting object contains the content
of the label of a list-item; typically used to either enumerate, identify,
or adorn the list-item's body.</definition>
</term-entry>
<term-entry>
<term>marker</term>
<definition>The fo:marker is used in conjunction with fo:retrieve-marker
to produce running headers or footers.</definition>
</term-entry>
<term-entry>
<term>multi-case</term>
<definition>The fo:multi-case is used to contain (within an fo:multi-switch)
each alternative sub-tree of formatting objects among which the parent
fo:multi-switch will choose one to show and will hide the rest.</definition>
</term-entry>
<term-entry>
<term>multi-properties</term>
<definition>The fo:multi-properties is used to switch between two or more
property sets that are associated with a given portion of content.</definition>
</term-entry>
<term-entry>
<term>multi-property-set</term>
<definition>The fo:multi-property-set is used to specify an alternative
set of formatting properties that, dependent on a User Agent state, are
applied to the content. </definition>
</term-entry>
<term-entry>
<term>multi-switch</term>
<definition>The fo:multi-switch wraps the specification of alternative
sub-trees of formatting objects (each sub-tree being within an
fo:multi-case), and controls the switching (activated via fo:multi-toggle)
from one alternative to another. </definition>
</term-entry>
<term-entry>
<term>multi-toggle</term>
<definition>The fo:multi-toggle is used within an fo:multi-case to switch
to another fo:multi-case.</definition>
</term-entry>
<term-entry>
<term>page-number</term>
<definition>The fo:page-number formatting object is used to represent the
current page-number.</definition>
</term-entry>
<term-entry>
<term>page-number-citation</term>
<definition>The fo:page-number-citation is used to reference the
page-number for the page containing the first normal area returned by the
cited formatting object.</definition>
</term-entry>
<term-entry>
<term>page-sequence</term>
<definition>The fo:page-sequence formatting object is used to specify how
to create a (sub-)sequence of pages within a document; for example, a
chapter of a report. The content of these pages comes from flow children
of the fo:page-sequence.</definition>
</term-entry>
<term-entry>
<term>page-sequence-master</term>
<definition>The fo:page-sequence-master specifies sequences of page-masters
that are used when generating a sequence of pages.</definition>
</term-entry>
<term-entry>
<term>region-after</term>
<definition>This region defines a viewport that is located on the "after"
side of fo:region-body region. </definition>
</term-entry>
<term-entry>
<term>region-before</term>
<definition>This region defines a viewport that is located on the "before"
side of fo:region-body region.</definition>
</term-entry>
<term-entry>
<term>region-body</term>
<definition>This region specifies a viewport/reference pair that is located
in the "center" of the fo:simple-page-master.</definition>
</term-entry>
<term-entry>
<term>region-end</term>
<definition>This region defines a viewport that is located on the "end"
side of fo:region-body region.</definition>
</term-entry>
<term-entry>
<term>region-start</term>
<definition>This region defines a viewport that is located on the "start"
side of fo:region-body region.</definition>
</term-entry>
<term-entry>
<term>repeatable-page-master-alternatives</term>
<definition>An fo:repeatable-page-master-alternatives specifies a
sub-sequence consisting of repeated instances of a set of alternative
page-masters. The number of repetitions may be bounded or potentially
unbounded.</definition>
</term-entry>
<term-entry>
<term>repeatable-page-master-reference</term>
<definition>An fo:repeatable-page-master-reference specifies a sub-sequence
consisting of repeated instances of a single page-master. The number of
repetitions may be bounded or potentially unbounded.</definition>
</term-entry>
<term-entry>
<term>retrieve-marker</term>
<definition>The fo:retrieve-marker is used in conjunction with fo:marker
to produce running headers or footers.</definition>
</term-entry>
<term-entry>
<term>root</term>
<definition>The fo:root node is the top node of an XSL result tree. This
tree is composed of formatting objects.</definition>
</term-entry>
<term-entry>
<term>simple-page-master</term>
<definition>The fo:simple-page-master is used in the generation of pages
and specifies the geometry of the page. The page may be subdivided into
up to five regions.</definition>
</term-entry>
<term-entry>
<term>single-page-master-reference</term>
<definition>An fo:single-page-master-reference specifies a sub-sequence
consisting of a single instance of a single page-master.</definition>
</term-entry>
<term-entry>
<term>static-content</term>
<definition>The fo:static-content formatting object holds a sequence or a
tree of formatting objects that is to be presented in a single region or
repeated in like-named regions on one or more pages in the page-sequence.
Its common use is for repeating or running headers and footers.</definition>
</term-entry>
<term-entry>
<term>table</term>
<definition>The fo:table flow object is used for formatting the tabular
material of a table.</definition>
</term-entry>
<term-entry>
<term>table-and-caption</term>
<definition>The fo:table-and-caption flow object is used for formatting a
table together with its caption.</definition>
</term-entry>
<term-entry>
<term>table-body</term>
<definition>The fo:table-body formatting object is used to contain the
content of the table body.</definition>
</term-entry>
<term-entry>
<term>table-caption</term>
<definition>The fo:table-caption formatting object is used to contain
block-level formatting objects containing the caption for the table only
when using the fo:table-and-caption.</definition>
</term-entry>
<term-entry>
<term>table-cell</term>
<definition>The fo:table-cell formatting object is used to group content to
be placed in a table cell.</definition>
</term-entry>
<term-entry>
<term>table-column</term>
<definition>The fo:table-column formatting object specifies characteristics
applicable to table cells that have the same column and span.</definition>
</term-entry>
<term-entry>
<term>table-footer</term>
<definition>The fo:table-footer formatting object is used to contain the
content of the table footer.</definition>
</term-entry>
<term-entry>
<term>table-header</term>
<definition>The fo:table-header formatting object is used to contain the
content of the table header.</definition>
</term-entry>
<term-entry>
<term>table-row</term>
<definition>The fo:table-row formatting object is used to group table-cells
into rows.</definition>
</term-entry>
<term-entry>
<term>title</term>
<definition>The fo:title formatting object is used to associate a title with
a given document. This title may be used by an interactive User Agent to
identify the document. For example, the content of the fo:title can be
formatted and displayed in a "title" window or in a "tool tip".</definition>
</term-entry>
<term-entry>
<term>wrapper </term>
<definition>The fo:wrapper formatting object is used to specify inherited
properties for a group of formatting objects. It has no additional
formatting semantics.</definition>
</term-entry>
</glossary>




+ 78
- 0
examples/fo/markers/glossary.xsl View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">

<xsl:template match="glossary">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

<fo:simple-page-master master-name="all"
page-height="11.5in"
page-width="8.5in"
margin-top="1in"
margin-bottom="1in"
margin-left="0.75in"
margin-right="0.75in">
<fo:region-body margin-top="1in" margin-bottom="0.75in"/>
<fo:region-before extent="0.75in"/>
<fo:region-after extent="0.5in"/>
</fo:simple-page-master>

</fo:layout-master-set>

<fo:page-sequence master-reference="all" format="i">

<!-- header with running glossary entries -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="start"
font-size="10pt" font-family="serif" line-height="1em + 2pt">
<fo:retrieve-marker retrieve-class-name="term"
retrieve-boundary="page"
retrieve-position="first-starting-within-page"/>
<fo:leader leader-alignment="reference-area" leader-pattern="dots"
leader-length="4in"/>
<fo:retrieve-marker retrieve-class-name="term"
retrieve-boundary="page"
retrieve-position="last-ending-within-page"/>
</fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="start"
font-size="10pt" font-family="serif" line-height="1em + 2pt">
Page (<fo:page-number/>)
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="term-entry"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

<xsl:template match="term-entry">
<fo:block text-align="start" font-size="12pt" font-family="sans-serif">
<xsl:apply-templates select="term"/>
<xsl:apply-templates select="definition"/>
</fo:block>
</xsl:template>

<xsl:template match="term">
<fo:block color="blue" space-before.optimum="3pt"><fo:marker
marker-class-name="term"><xsl:value-of select="."/></fo:marker>
<xsl:value-of select="."/>
</fo:block>
</xsl:template>

<xsl:template match="definition">
<fo:block text-align="start" start-indent="2em">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>

</xsl:stylesheet>


+ 131
- 0
examples/fo/markers/hide.fo View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
margin-right="1.5cm"
margin-left="1.5cm"
margin-bottom="2cm"
margin-top="1cm"
page-width="21cm"
page-height="29.7cm">
<fo:region-body margin-top="1cm"/>
<fo:region-before extent="1cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="first">
<fo:static-content flow-name="xsl-region-before">
<fo:block-container height="1cm" width="15cm" top="0cm" left="0cm" position="absolute">
<fo:block>
<fo:retrieve-marker retrieve-class-name="message"
retrieve-boundary="page"
retrieve-position="first-starting-within-page"/>
</fo:block>
</fo:block-container>
<fo:block-container height="1cm" width="15cm" top="0cm" left="0cm" position="absolute">
<fo:block>
<fo:retrieve-marker retrieve-class-name="term"
retrieve-boundary="page"
retrieve-position="last-ending-within-page"/>
</fo:block>
</fo:block-container>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="start"
font-size="10pt" font-family="serif" line-height="1em + 2pt">
Page (<fo:page-number/> / <fo:page-number-citation
ref-id="end-seq1"/>)
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block><fo:marker
marker-class-name="message"><fo:block>
WARNING: Page sequence contains: <fo:page-number-citation
ref-id="end-seq1"/> pages.
</fo:block></fo:marker>
</fo:block>

<fo:block text-align="start" font-size="12pt" font-family="sans-serif">
This example shows how it is possible to have a message that appears
only on the first page (in a page sequence) only if there is more
than one page.
</fo:block>

<fo:block text-align="start" font-size="12pt" font-family="sans-serif">
This page sequence only has one page so you will not see the message.
</fo:block>

<fo:block id="end-seq1"><fo:marker
marker-class-name="term"><fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" width="15cm" height="1cm" xml:space="preserve">
<rect style="fill:white;stroke:white" x="0" y="0" width="15cm" height="1cm"/>
</svg>
</fo:instream-foreign-object></fo:marker>
</fo:block>

</fo:flow>
</fo:page-sequence>

<fo:page-sequence master-reference="first" initial-page-number="1">
<fo:static-content flow-name="xsl-region-before">
<fo:block-container height="1cm" width="15cm" top="0cm" left="0cm" position="absolute"> <fo:block>
<fo:retrieve-marker retrieve-class-name="message"
retrieve-boundary="page"
retrieve-position="first-starting-within-page"/>
</fo:block>
</fo:block-container>
<fo:block-container height="1cm" width="15cm" top="0cm" left="0cm" position="absolute"> <fo:block>
<fo:retrieve-marker retrieve-class-name="term"
retrieve-boundary="page"
retrieve-position="last-ending-within-page"/>
</fo:block>
</fo:block-container>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="start"
font-size="10pt" font-family="serif" line-height="1em + 2pt">
Page (<fo:page-number/> / <fo:page-number-citation
ref-id="end-of-document"/>)
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block><fo:marker
marker-class-name="message"><fo:block>
WARNING: Page sequence contains: <fo:page-number-citation
ref-id="end-of-document"/> pages.
</fo:block></fo:marker>
</fo:block>

<fo:block text-align="start" font-size="12pt" font-family="sans-serif">
This page sequence has more than one page so you will see the message
only at the top of the first page.
</fo:block>

<fo:block break-before="page" text-align="start" font-size="12pt" font-family="sans-serif">
Some text.
</fo:block>

<fo:block break-before="page" text-align="start" font-size="12pt" font-family="sans-serif">
Some text.
</fo:block>
<fo:block break-before="page" text-align="start" font-size="12pt" font-family="sans-serif">
Some more text on last page.
</fo:block>

<fo:block id="end-of-document"><fo:marker
marker-class-name="term"><fo:instream-foreign-object>
<svg xmlns="http://www.w3.org/2000/svg" width="15cm" height="1cm" xml:space="preserve"> <rect style="fill:white;stroke:white" x="0" y="0" width="15cm" height="1cm"/>
</svg>
</fo:instream-foreign-object></fo:marker>
</fo:block>

</fo:flow>
</fo:page-sequence>

</fo:root>


+ 141
- 0
examples/fo/pagination/allregions.fo View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines page layout -->
<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="only"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body
margin-top="3cm" margin-bottom="1.5cm"
margin-left="2cm" margin-right="2cm"/>
<fo:region-before precedence="true" extent="3cm"/>
<fo:region-after precedence="true" extent="1.5cm"/>
<fo:region-start extent="1cm"/>
<fo:region-end extent="1cm"/>
</fo:simple-page-master>

</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-reference="only" initial-page-number="1">

<!-- usage of page layout -->
<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt" >
XML Recommendation - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="center"
font-size="10pt"
font-family="serif"
line-height="14pt" >
After
</fo:block>
</fo:static-content>

<fo:static-content flow-name="xsl-region-start">
<fo:block-container border-color="black" border-style="solid" border-width="1pt"
height="22.2cm" width="1cm" top="0cm" left="0cm" position="absolute">
<fo:block text-align="start" font-size="8pt"
font-family="serif" line-height="10pt">Start</fo:block>
</fo:block-container>
</fo:static-content>

<fo:static-content flow-name="xsl-region-end">
<fo:block-container border-color="black" border-style="solid" border-width="1pt"
height="22.2cm" width="1cm" top="0cm" left="0cm" position="absolute">
<fo:block text-align="start" font-size="8pt"
font-family="serif" line-height="10pt">End</fo:block>
</fo:block-container>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="0pt">
Extensible Markup Language (XML) 1.0
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="0pt">
Abstract
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="0pt">
Status of this document
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web. For further information go to
<fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document specifies a syntax created by subsetting an existing, widely used international text processing standard
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It
is a product of the W3C XML Activity, details of which can be found at http://www.w3.org/XML. A list of current W3C
Recommendations and other technical documents can be found at http://www.w3.org/TR.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 130
- 0
examples/fo/pagination/basic2.fo View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- This example shows the simplest use of an fo:page-sequence-master (PSM),
having only a single fo:simple-page-master-reference.
Note that because only a single fo:simple-page-master-reference is being
used, this PSM can actually be omitted. Instead, the fo:page-sequence's
master-reference can be set directly to the master-name attribute
("SPM_Name") of the fo:simple-page-master (SPM).
Also note that using a single fo:single-page-master-reference (as opposed
to a fo:repeatable-page-master-reference) within the PSM limits you
to one (1) page for the referencing fo:page-sequence. If the fo:page-sequence's
master-reference is set to the master-name of the SPM, however, the number
of pages that can be output using that SPM is unbounded.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- defines page layout -->
<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="SPM_Name"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>

<fo:page-sequence-master master-name="PSM_Name">
<fo:single-page-master-reference master-reference="SPM_Name"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout, note master-reference can alternatively be set to
SPM_Name as mentioned above -->
<fo:page-sequence master-reference="PSM_Name" initial-page-number="1">

<!-- usage of page layout -->
<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt">
XML Recommendation - p. <fo:page-number/>
</fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">

<!-- defines text title level 1-->
<fo:block font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="0pt">
Extensible Markup Language (XML) 1.0
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="0pt">
Abstract
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document. Its goal is to
enable generic SGML to be served, received, and processed on the Web in the way that is now possible with HTML. XML
has been designed for ease of implementation and for interoperability with both SGML and HTML. For further information
go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- defines text title level 2-->
<fo:block font-size="16pt"
font-family="sans-serif"
line-height="20pt"
space-before.optimum="10pt"
space-after.optimum="10pt"
text-align="start"
padding-top="0pt">
Status of this document
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a
W3C Recommendation. It is a stable document and may be used as reference material or cited as a normative reference from
another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web. For further information go to
<fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link>
</fo:block>

<!-- Normal text -->
<fo:block font-size="12pt"
font-family="sans-serif"
line-height="15pt"
space-after.optimum="3pt"
text-align="start">
This document specifies a syntax created by subsetting an existing, widely used international text processing standard
(Standard Generalized Markup Language, ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web. It
is a product of the W3C XML Activity, details of which can be found at http://www.w3.org/XML. A list of current W3C
Recommendations and other technical documents can be found at http://www.w3.org/TR.
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>

+ 1078
- 0
examples/fo/pagination/franklin_2pageseqs.fo
File diff suppressed because it is too large
View File


+ 0
- 0
examples/fo/pagination/franklin_alt.fo View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save