| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|---|
| 2 | <html>
|
|---|
| 3 | <head>
|
|---|
| 4 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|---|
| 5 | <title>XSL-FO Input</title>
|
|---|
| 6 | <link type="text/css" href="skin/page.css" rel="stylesheet">
|
|---|
| 7 | </head>
|
|---|
| 8 | <body text="#000000" bgcolor="#FFFFFF">
|
|---|
| 9 | <!--================= start Navigation Path ==================-->
|
|---|
| 10 | <table summary="navigation path" width="100%" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 11 | <tr>
|
|---|
| 12 | <td nowrap="nowrap" valign="middle" bgcolor="#CFDCED" height="20"><img height="1" width="5" alt="" border="0" src="skin/images/spacer.gif"><!--===== breadcrumb trail (javascript-generated) ====--><font size="2" face="Arial, Helvetica, Sans-serif"><script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script></font></td>
|
|---|
| 13 | </tr>
|
|---|
| 14 | <tr>
|
|---|
| 15 | <td bgcolor="#4C6C8F" height="2"><img height="2" width="2" alt="" border="0" src="skin/images/spacer.gif"></td>
|
|---|
| 16 | </tr>
|
|---|
| 17 | </table>
|
|---|
| 18 | <!--================= end Navigation Path ==================-->
|
|---|
| 19 | <!--================= start Banner ==================-->
|
|---|
| 20 | <table summary="header with logos" width="100%" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 21 | <tr>
|
|---|
| 22 | <!--================= start Group Logo ==================-->
|
|---|
| 23 | <td bgcolor="#294563"><a href="http://xml.apache.org/"><img border="0" class="logoImage" alt="Apache XML" src="images/group-logo.gif"></a></td>
|
|---|
| 24 | <!--================= end Group Logo ==================-->
|
|---|
| 25 | <!--================= start Project Logo ==================--><td width="100%" align="center" bgcolor="#294563"><a href="http://xml.apache.org/fop/"><img border="0" class="logoImage" alt="FOP" src="images/logo.jpg"></a></td>
|
|---|
| 26 | <!--================= end Project Logo ==================-->
|
|---|
| 27 | <!--================= start Search ==================--><td valign="top" rowspan="2" bgcolor="#294563">
|
|---|
| 28 | <form target="_blank" action="http://www.google.com/search" method="get">
|
|---|
| 29 | <table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
|
|---|
| 30 | <tr>
|
|---|
| 31 | <td colspan="3"><img height="10" width="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 32 | </tr>
|
|---|
| 33 | <tr>
|
|---|
| 34 | <td><img height="1" width="1" alt="" src="skin/images/spacer.gif"></td><td nowrap="nowrap"><input value="xml.apache.org" name="sitesearch" type="hidden"><input size="15" name="q" id="query" type="text"><img height="1" width="5" alt="" src="skin/images/spacer.gif"><input name="Search" value="Search" type="submit">
|
|---|
| 35 | <br>
|
|---|
| 36 | <font face="Arial, Helvetica, Sans-serif" size="2" color="white">
|
|---|
| 37 | the Apache XML site
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | </font></td><td><img height="1" width="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 41 | </tr>
|
|---|
| 42 | <tr>
|
|---|
| 43 | <td><img alt="" border="0" height="10" width="9" src="skin/images/search-left.gif"></td><td><img height="1" width="1" alt="" src="skin/images/spacer.gif"></td><td><img alt="" border="0" height="10" width="9" src="skin/images/search-right.gif"></td>
|
|---|
| 44 | </tr>
|
|---|
| 45 | </table>
|
|---|
| 46 | </form>
|
|---|
| 47 | </td>
|
|---|
| 48 | <!--================= start Search ==================--><td bgcolor="#294563"><img height="10" width="10" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 49 | </tr>
|
|---|
| 50 | <tr>
|
|---|
| 51 | <td valign="bottom" bgcolor="#294563" colspan="2">
|
|---|
| 52 | <!--================= start Tabs ==================-->
|
|---|
| 53 | <div class="tab">
|
|---|
| 54 | <table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 55 | <tr>
|
|---|
| 56 | <td width="8"><img alt="" height="8" width="8" src="skin/images/spacer.gif"></td><td valign="bottom">
|
|---|
| 57 | <table summary="selected tab" style="height: 1.7em" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 58 | <tr>
|
|---|
| 59 | <td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="skin/images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b><a href="index.html"><font color="#000000">Home</font></a></b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="skin/images/tabSel-right.gif"></td>
|
|---|
| 60 | </tr>
|
|---|
| 61 | </table>
|
|---|
| 62 | </td><td width="8"><img alt="" height="8" width="8" src="skin/images/spacer.gif"></td><td valign="bottom">
|
|---|
| 63 | <table summary="non selected tab" style="height: 1.6em" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 64 | <tr>
|
|---|
| 65 | <td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="skin/images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a href="dev/index.html"><font face="Arial, Helvetica, Sans-serif">Development</font></a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="skin/images/tab-right.gif"></td>
|
|---|
| 66 | </tr>
|
|---|
| 67 | </table>
|
|---|
| 68 | </td>
|
|---|
| 69 | </tr>
|
|---|
| 70 | </table>
|
|---|
| 71 | </div>
|
|---|
| 72 | <!--================= end Tabs ==================-->
|
|---|
| 73 | </td><td bgcolor="#294563"><img alt="" width="1" height="1" src="skin/images/spacer.gif"></td>
|
|---|
| 74 | </tr>
|
|---|
| 75 | <tr>
|
|---|
| 76 | <td bgcolor="#4C6C8F" colspan="4"><img width="1" height="10" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 77 | </tr>
|
|---|
| 78 | </table>
|
|---|
| 79 | <!--================= end Banner ==================-->
|
|---|
| 80 | <!--================= start Menu, NavBar, Content ==================-->
|
|---|
| 81 | <table summary="page content" bgcolor="#ffffff" width="100%" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 82 | <tr>
|
|---|
| 83 | <td valign="top">
|
|---|
| 84 | <table summary="menu" border="0" cellspacing="0" cellpadding="0">
|
|---|
| 85 | <tr>
|
|---|
| 86 | <!--================= start left top NavBar ==================-->
|
|---|
| 87 | <td rowspan="3" valign="top">
|
|---|
| 88 | <table summary="blue line" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 89 | <tr>
|
|---|
| 90 | <td bgcolor="#294563"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 91 | </tr>
|
|---|
| 92 | <tr>
|
|---|
| 93 | <td bgcolor="#CFDCED"><font color="#4C6C8F" size="4" face="Arial, Helvetica, Sans-serif"> </font></td>
|
|---|
| 94 | </tr>
|
|---|
| 95 | <tr>
|
|---|
| 96 | <td bgcolor="#294563"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 97 | </tr>
|
|---|
| 98 | </table>
|
|---|
| 99 | </td>
|
|---|
| 100 | <!--================= end left top NavBar ==================--><td bgcolor="#294563"><img width="1" height="1" alt="" src="skin/images/spacer.gif"></td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="skin/images/spacer.gif"></td><td nowrap="nowrap" valign="top" bgcolor="#4C6C8F">
|
|---|
| 101 | <!--================= start Menu items ==================-->
|
|---|
| 102 | <div class="menu">
|
|---|
| 103 | <ul>
|
|---|
| 104 | <li>
|
|---|
| 105 | <font color="#CFDCED">Home</font>
|
|---|
| 106 | <ul>
|
|---|
| 107 |
|
|---|
| 108 | <li>
|
|---|
| 109 | <a href="index.html">Introduction</a>
|
|---|
| 110 | </li>
|
|---|
| 111 |
|
|---|
| 112 | </ul>
|
|---|
| 113 | </li>
|
|---|
| 114 | <li>
|
|---|
| 115 | <font color="#CFDCED">Using FOP</font>
|
|---|
| 116 | <ul>
|
|---|
| 117 |
|
|---|
| 118 | <li>
|
|---|
| 119 | <a href="relnotes.html">Release Notes</a>
|
|---|
| 120 | </li>
|
|---|
| 121 |
|
|---|
| 122 | <li>
|
|---|
| 123 | <a href="download.html">Download</a>
|
|---|
| 124 | </li>
|
|---|
| 125 |
|
|---|
| 126 | <li>
|
|---|
| 127 | <a href="compiling.html">Build</a>
|
|---|
| 128 | </li>
|
|---|
| 129 |
|
|---|
| 130 | <li>
|
|---|
| 131 | <a href="configuration.html">Configure</a>
|
|---|
| 132 | </li>
|
|---|
| 133 |
|
|---|
| 134 | <li>
|
|---|
| 135 | <a href="running.html">Run</a>
|
|---|
| 136 | </li>
|
|---|
| 137 |
|
|---|
| 138 | <li>
|
|---|
| 139 | <a href="embedding.html">Embed</a>
|
|---|
| 140 | </li>
|
|---|
| 141 |
|
|---|
| 142 | <li>
|
|---|
| 143 | <a href="servlets.html">Servlets</a>
|
|---|
| 144 | </li>
|
|---|
| 145 |
|
|---|
| 146 | <li>
|
|---|
| 147 | <a href="anttask.html">Ant task</a>
|
|---|
| 148 | </li>
|
|---|
| 149 |
|
|---|
| 150 | </ul>
|
|---|
| 151 | </li>
|
|---|
| 152 | <li>
|
|---|
| 153 | <font color="#CFDCED">Features</font>
|
|---|
| 154 | <ul>
|
|---|
| 155 |
|
|---|
| 156 | <li>
|
|---|
| 157 | <a href="compliance.html">Compliance</a>
|
|---|
| 158 | </li>
|
|---|
| 159 |
|
|---|
| 160 | <li>
|
|---|
| 161 | <a href="output.html">Output Targets</a>
|
|---|
| 162 | </li>
|
|---|
| 163 |
|
|---|
| 164 | <li>
|
|---|
| 165 | <a href="pdfencryption.html">PDF encryption</a>
|
|---|
| 166 | </li>
|
|---|
| 167 |
|
|---|
| 168 | <li>
|
|---|
| 169 | <a href="graphics.html">Graphics</a>
|
|---|
| 170 | </li>
|
|---|
| 171 |
|
|---|
| 172 | <li>
|
|---|
| 173 | <a href="fonts.html">Fonts</a>
|
|---|
| 174 | </li>
|
|---|
| 175 |
|
|---|
| 176 | <li>
|
|---|
| 177 | <a href="hyphenation.html">Hyphenation</a>
|
|---|
| 178 | </li>
|
|---|
| 179 |
|
|---|
| 180 | <li>
|
|---|
| 181 | <a href="extensions.html">Extensions</a>
|
|---|
| 182 | </li>
|
|---|
| 183 |
|
|---|
| 184 | </ul>
|
|---|
| 185 | </li>
|
|---|
| 186 | <li>
|
|---|
| 187 | <font color="#CFDCED">Resources</font>
|
|---|
| 188 | <ul>
|
|---|
| 189 |
|
|---|
| 190 | <li>
|
|---|
| 191 | <a href="gethelp.html">Getting Help</a>
|
|---|
| 192 | </li>
|
|---|
| 193 |
|
|---|
| 194 | <li>
|
|---|
| 195 | <a href="faq.html">FAQs</a>
|
|---|
| 196 | </li>
|
|---|
| 197 |
|
|---|
| 198 | <li>
|
|---|
| 199 | <span class="sel"><font color="#ffcc00">XSL-FO</font></span>
|
|---|
| 200 | </li>
|
|---|
| 201 |
|
|---|
| 202 | <li>
|
|---|
| 203 | <a href="examples.html">Examples</a>
|
|---|
| 204 | </li>
|
|---|
| 205 |
|
|---|
| 206 | <li>
|
|---|
| 207 | <a href="maillist.html">Mailing Lists</a>
|
|---|
| 208 | </li>
|
|---|
| 209 |
|
|---|
| 210 | <li>
|
|---|
| 211 | <a href="bugs.html">Bugs</a>
|
|---|
| 212 | </li>
|
|---|
| 213 |
|
|---|
| 214 | <li>
|
|---|
| 215 | <a href="license.html">License</a>
|
|---|
| 216 | </li>
|
|---|
| 217 |
|
|---|
| 218 | <li>
|
|---|
| 219 | <a href="resources.html">Other</a>
|
|---|
| 220 | </li>
|
|---|
| 221 |
|
|---|
| 222 | </ul>
|
|---|
| 223 | </li>
|
|---|
| 224 | <li>
|
|---|
| 225 | <font color="#CFDCED">Project</font>
|
|---|
| 226 | <ul>
|
|---|
| 227 |
|
|---|
| 228 | <li>
|
|---|
| 229 | <a href="news.html">News</a>
|
|---|
| 230 | </li>
|
|---|
| 231 |
|
|---|
| 232 | <li>
|
|---|
| 233 | <a href="logocontest.html">Logo contest</a>
|
|---|
| 234 | </li>
|
|---|
| 235 |
|
|---|
| 236 | <li>
|
|---|
| 237 | <a href="status.html">Status</a>
|
|---|
| 238 | </li>
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | <li>
|
|---|
| 242 | <a href="team.html">Team</a>
|
|---|
| 243 | </li>
|
|---|
| 244 |
|
|---|
| 245 | </ul>
|
|---|
| 246 | </li>
|
|---|
| 247 | </ul>
|
|---|
| 248 | </div>
|
|---|
| 249 | <!--================= end Menu items ==================-->
|
|---|
| 250 | </td><td valign="bottom" bgcolor="#4C6C8F"><img width="10" height="10" alt="" src="skin/images/spacer.gif"></td><td bgcolor="#294563"><img width="1" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 251 | </tr>
|
|---|
| 252 | <tr>
|
|---|
| 253 | <td valign="bottom" align="left" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="skin/images/menu-left.gif"></td><td bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="skin/images/spacer.gif"></td><td valign="bottom" align="right" colspan="2" rowspan="2" bgcolor="#4C6C8F"><img height="10" width="10" border="0" alt="" src="skin/images/menu-right.gif"></td>
|
|---|
| 254 | </tr>
|
|---|
| 255 | <tr>
|
|---|
| 256 | <td height="1" bgcolor="#294563"><img width="1" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 257 | </tr>
|
|---|
| 258 | </table>
|
|---|
| 259 | </td><td valign="top" width="100%">
|
|---|
| 260 | <table summary="content" width="100%" border="0" cellpadding="0" cellspacing="0">
|
|---|
| 261 | <!--================= start middle NavBar ==================-->
|
|---|
| 262 | <tr>
|
|---|
| 263 | <td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 264 | </tr>
|
|---|
| 265 | <tr>
|
|---|
| 266 | <td align="left" width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td><td align="left" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 | </font><img width="10" height="8" alt="" src="skin/images/spacer.gif"></td><td align="right" width="50%" bgcolor="#CFDCED"><font color="#4C6C8F" size="3" face="Arial, Helvetica, Sans-serif">
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 | </font><img width="10" height="8" alt="" src="skin/images/spacer.gif"></td><td width="10" bgcolor="#CFDCED"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 273 | </tr>
|
|---|
| 274 | <tr>
|
|---|
| 275 | <td colspan="4" bgcolor="#294563"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 276 | </tr>
|
|---|
| 277 | <!--================= end middle NavBar ==================-->
|
|---|
| 278 | <!--================= start Content==================-->
|
|---|
| 279 | <tr>
|
|---|
| 280 | <td align="left" width="10"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td><td align="left" width="100%">
|
|---|
| 281 | <div class="content">
|
|---|
| 282 | <table class="title" summary="">
|
|---|
| 283 | <tr>
|
|---|
| 284 | <td valign="middle">
|
|---|
| 285 | <h1>XSL-FO Input</h1>
|
|---|
| 286 | </td><td nowrap="nowrap" width="80" align="center"><a class="dida" href="fo.pdf"><img alt="printer" src="skin/images/printer.gif" border="0"><br>
|
|---|
| 287 | print-friendly<br>
|
|---|
| 288 | PDF</a></td>
|
|---|
| 289 | </tr>
|
|---|
| 290 | </table>
|
|---|
| 291 | <h3>Basic Help for Using XML, XSLT, and XSL-FO</h3>
|
|---|
| 292 | <ul class="minitoc">
|
|---|
| 293 | <li>
|
|---|
| 294 | <a href="#overview">Overview</a>
|
|---|
| 295 | </li>
|
|---|
| 296 | <li>
|
|---|
| 297 | <a href="#xml">XML Issues</a>
|
|---|
| 298 | <ul class="minitoc">
|
|---|
| 299 | <li>
|
|---|
| 300 | <a href="#xml-special-chars">Special Characters</a>
|
|---|
| 301 | </li>
|
|---|
| 302 | <li>
|
|---|
| 303 | <a href="#xml-entity-chars">Entity Characters</a>
|
|---|
| 304 | </li>
|
|---|
| 305 | <li>
|
|---|
| 306 | <a href="#xml-encoding">Encoding Issues</a>
|
|---|
| 307 | </li>
|
|---|
| 308 | </ul>
|
|---|
| 309 | </li>
|
|---|
| 310 | <li>
|
|---|
| 311 | <a href="#xsl-fo">XSL-FO Issues</a>
|
|---|
| 312 | <ul class="minitoc">
|
|---|
| 313 | <li>
|
|---|
| 314 | <a href="#fo-center-vertical">Vertical Centering</a>
|
|---|
| 315 | </li>
|
|---|
| 316 | <li>
|
|---|
| 317 | <a href="#fo-center-table-horizon">Horizontal Centering (Tables)</a>
|
|---|
| 318 | </li>
|
|---|
| 319 | <li>
|
|---|
| 320 | <a href="#fo-oddeven">Recto/Verso Static Content Differences</a>
|
|---|
| 321 | </li>
|
|---|
| 322 | <li>
|
|---|
| 323 | <a href="#fo-first-page">Making the First Page Special</a>
|
|---|
| 324 | </li>
|
|---|
| 325 | <li>
|
|---|
| 326 | <a href="#fo-blank-pages">Blank Pages</a>
|
|---|
| 327 | </li>
|
|---|
| 328 | <li>
|
|---|
| 329 | <a href="#fo-preformat">Preformatting Content</a>
|
|---|
| 330 | </li>
|
|---|
| 331 | <li>
|
|---|
| 332 | <a href="#fo-total-pages">Total Document Pages</a>
|
|---|
| 333 | </li>
|
|---|
| 334 | <li>
|
|---|
| 335 | <a href="#fo-region-align">Aligning Regions</a>
|
|---|
| 336 | </li>
|
|---|
| 337 | <li>
|
|---|
| 338 | <a href="#fo-lines">Drawing Lines</a>
|
|---|
| 339 | </li>
|
|---|
| 340 | <li>
|
|---|
| 341 | <a href="#fo-validate">Validating XSL-FO</a>
|
|---|
| 342 | </li>
|
|---|
| 343 | <li>
|
|---|
| 344 | <a href="#landscape">Producing landscape pages</a>
|
|---|
| 345 | </li>
|
|---|
| 346 | <li>
|
|---|
| 347 | <a href="#external-resources">External Resources</a>
|
|---|
| 348 | </li>
|
|---|
| 349 | </ul>
|
|---|
| 350 | </li>
|
|---|
| 351 | </ul>
|
|---|
| 352 |
|
|---|
| 353 | <a name="N101C1"></a><a name="overview"></a>
|
|---|
| 354 | <h3>Overview</h3>
|
|---|
| 355 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 356 | <p>
|
|---|
| 357 | FOP uses XSL-FO as input.
|
|---|
| 358 | It is the responsibility of the user to make sure that the XSL-FO submitted to FOP is correct.
|
|---|
| 359 | The tutorial items presented here are not comprehensive, but are of the FAQ variety. Another
|
|---|
| 360 | good FAQ is <a target="_blank" href="http://www.dpawson.co.uk/xsl/xslfaq.html">Dave Pawson's XSL FAQ</a>.
|
|---|
| 361 | </p>
|
|---|
| 362 | </div>
|
|---|
| 363 |
|
|---|
| 364 | <a name="N101CF"></a><a name="xml"></a>
|
|---|
| 365 | <h3>XML Issues</h3>
|
|---|
| 366 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 367 | <a name="N101D5"></a><a name="xml-special-chars"></a>
|
|---|
| 368 | <h4>Special Characters</h4>
|
|---|
| 369 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 370 | <p>
|
|---|
| 371 | When entering special (non-ASCII) characters in XML, the general rule is to use the applicable Unicode character instead of trying to use a character entity as you would with HTML.
|
|---|
| 372 | Remember that HTML is an SGML document type.
|
|---|
| 373 | SGML has a limited character set, which requires it to use character entities to represent special characters.
|
|---|
| 374 | One of the improvements of XML over SGML (and thus HTML) is native support for Unicode.
|
|---|
| 375 | Basic XML has only a handful of character entities, primarily because it doesn't really need more.
|
|---|
| 376 | </p>
|
|---|
| 377 | <p>
|
|---|
| 378 | Entities such as <span class="codefrag">&uuml;</span> (u with an umlaut), which work in HTML, will be flagged as undefined entities unless you define them yourself in your DTD.
|
|---|
| 379 | Use the corresponding Unicode character instead.
|
|---|
| 380 | A list of predefined HTML entities and their Unicode codepoints can be found at <a href="http://www.w3.org/TR/html4/sgml/entities.html">Character entity references in HTML 4</a>.
|
|---|
| 381 | </p>
|
|---|
| 382 | <p>
|
|---|
| 383 | One common example is <span class="codefrag">&nbsp;</span>, used to obtain a non-breaking space in HTML.
|
|---|
| 384 | In XML, use &#160; instead.
|
|---|
| 385 | </p>
|
|---|
| 386 | <p>
|
|---|
| 387 | For other non-ASCII characters, such as the Euro symbol, checkbox, etc., see the <a href="http://www.unicode.org/charts/charindex.html">Unicode Reference By Name</a> document that is found at the <a href="http://www.unicode.org">Unicode Consortium</a> site.
|
|---|
| 388 | </p>
|
|---|
| 389 | <p>
|
|---|
| 390 | After finding the correct Unicode codepoint to represent the character, use <a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-references">XML Character References</a> to put the character into your source XML, XSLT or FO.
|
|---|
| 391 | See the non-breaking-space comments above for an example of the syntax using decimal notation.
|
|---|
| 392 | The following hexadecimal example will result in a Euro sign:
|
|---|
| 393 | </p>
|
|---|
| 394 | <pre class="code">&#x20AC;</pre>
|
|---|
| 395 | <p>
|
|---|
| 396 | Getting your XML correctly encoded is only part of the job.
|
|---|
| 397 | If you want the character to display or print correctly (and you probably do), then the selected font must contain the necessary glyph.
|
|---|
| 398 | Because of differences between font encoding methods, and limitations in some font technologies, this can be a troublesome issue, especially for symbol characters.
|
|---|
| 399 | The FOP example file <a href="fo/fonts.fo.pdf">Base-14 Font Character Mapping</a> is a very useful resource in sorting these issues out for the Base-14 fonts.
|
|---|
| 400 | For other fonts, use font editing sofware or operating system utilities (such as the Character Map in most Windows platforms) to determine what characters the font supports.
|
|---|
| 401 | </p>
|
|---|
| 402 | <p>
|
|---|
| 403 | An alternative to encoding the character and making it available through a font is to use an embedded graphic to represent the character: GIF, PNG, SVG, etc.
|
|---|
| 404 | </p>
|
|---|
| 405 | </div>
|
|---|
| 406 | <a name="N1020F"></a><a name="xml-entity-chars"></a>
|
|---|
| 407 | <h4>Entity Characters</h4>
|
|---|
| 408 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 409 | <p>
|
|---|
| 410 | The handful of basic XML character entities that do exist are the ampersand, apostrophe, less-than, greater-than, and single-quote characters.
|
|---|
| 411 | These are needed to distinguish markup tags from content, and to distinguish character entities from content.
|
|---|
| 412 | To avoid parser complaints about illegal characters and entities in your input, ensure that ampersands in text and attributes are written as &amp;, "<" is written as &lt;, and ">" as &gt;.
|
|---|
| 413 | It is not necessary everywhere, but it is wise to do so anyway, just to be sure.
|
|---|
| 414 | </p>
|
|---|
| 415 | <p>
|
|---|
| 416 | Most XML parsers will provide a line number and sometimes a column number for offending characters.
|
|---|
| 417 | </p>
|
|---|
| 418 | <p>
|
|---|
| 419 | Review the <a href="http://www.w3.org/XML/">XML Specification</a> or a good tutorial for details of the XML file format.
|
|---|
| 420 | </p>
|
|---|
| 421 | </div>
|
|---|
| 422 | <a name="N10223"></a><a name="xml-encoding"></a>
|
|---|
| 423 | <h4>Encoding Issues</h4>
|
|---|
| 424 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 425 | <p>
|
|---|
| 426 | If the parser complains about illegal bytes or characters in the input, or there are unexpected characters in the output, this is usually is the result of a character encoding problem.
|
|---|
| 427 | See the <a href="http://www.dpawson.co.uk/xsl">XSL FAQ</a> for additional information.
|
|---|
| 428 | Many software packages that produce XML, including XSLT processors, use UTF-8 encoding as a default.
|
|---|
| 429 | If you view their output with something not aware of the encoding, like Notepad for Win95/98/ME/NT, funny characters are displayed. A Å is a giveaway.
|
|---|
| 430 | </p>
|
|---|
| 431 | </div>
|
|---|
| 432 | </div>
|
|---|
| 433 |
|
|---|
| 434 | <a name="N10232"></a><a name="xsl-fo"></a>
|
|---|
| 435 | <h3>XSL-FO Issues</h3>
|
|---|
| 436 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 437 | <a name="N10238"></a><a name="fo-center-vertical"></a>
|
|---|
| 438 | <h4>Vertical Centering</h4>
|
|---|
| 439 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 440 | <p>
|
|---|
| 441 | To vertically center an image, table, or other item, use display-align="center".
|
|---|
| 442 | See <a href="compliance.html#fo-property-display-align">display-align Compliance</a> for implementation status.
|
|---|
| 443 | Here is a small, self-contained document centering an image on a page:
|
|---|
| 444 | </p>
|
|---|
| 445 | <pre class="code"><?xml version="1.0"?>
|
|---|
| 446 | <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
|---|
| 447 | <fo:layout-master-set>
|
|---|
| 448 | <fo:simple-page-master master-name="content"
|
|---|
| 449 | page-width="210mm" page-height="297mm">
|
|---|
| 450 | <fo:region-body/>
|
|---|
| 451 | </fo:simple-page-master>
|
|---|
| 452 | </fo:layout-master-set>
|
|---|
| 453 | <fo:page-sequence master-reference="content">
|
|---|
| 454 | <fo:flow flow-name="xsl-region-body">
|
|---|
| 455 | <fo:table table-layout="fixed" width="100%">
|
|---|
| 456 | <fo:table-column column-width="proportional-column-width(1)"/>
|
|---|
| 457 | <fo:table-body>
|
|---|
| 458 | <fo:table-row height="297mm">
|
|---|
| 459 | <fo:table-cell display-align="center">
|
|---|
| 460 | <fo:block text-align="center">
|
|---|
| 461 | <fo:external-graphic src="fop.jpg"/>
|
|---|
| 462 | </fo:block>
|
|---|
| 463 | </fo:table-cell>
|
|---|
| 464 | </fo:table-row>
|
|---|
| 465 | </fo:table-body>
|
|---|
| 466 | </fo:table>
|
|---|
| 467 | </fo:flow>
|
|---|
| 468 | </fo:page-sequence>
|
|---|
| 469 | </fo:root></pre>
|
|---|
| 470 | </div>
|
|---|
| 471 | <a name="N1024A"></a><a name="fo-center-table-horizon"></a>
|
|---|
| 472 | <h4>Horizontal Centering (Tables)</h4>
|
|---|
| 473 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 474 | <p>
|
|---|
| 475 | To center a table horizontally, one possibility is to add one column on the left and one on the right which pad the table so that the visible part is centered:
|
|---|
| 476 | </p>
|
|---|
| 477 | <pre class="code"><?xml version="1.0"?>
|
|---|
| 478 | <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
|---|
| 479 | <fo:layout-master-set>
|
|---|
| 480 | <fo:simple-page-master master-name="content"
|
|---|
| 481 | page-width="210mm" page-height="297mm">
|
|---|
| 482 | <fo:region-body/>
|
|---|
| 483 | </fo:simple-page-master>
|
|---|
| 484 | </fo:layout-master-set>
|
|---|
| 485 | <fo:page-sequence master-reference="content">
|
|---|
| 486 | <fo:flow flow-name="xsl-region-body">
|
|---|
| 487 | <fo:table table-layout="fixed" width="100%">
|
|---|
| 488 | <fo:table-column column-width="proportional-column-width(1)"/>
|
|---|
| 489 | <fo:table-column column-width="100mm"/>
|
|---|
| 490 | <fo:table-column column-width="proportional-column-width(1)"/>
|
|---|
| 491 | <fo:table-body>
|
|---|
| 492 | <fo:table-row>
|
|---|
| 493 | <fo:table-cell/>
|
|---|
| 494 | <fo:table-cell>
|
|---|
| 495 | <fo:block>foo</fo:block>
|
|---|
| 496 | </fo:table-cell>
|
|---|
| 497 | <fo:table-cell/>
|
|---|
| 498 | </fo:table-row>
|
|---|
| 499 | </fo:table-body>
|
|---|
| 500 | </fo:table>
|
|---|
| 501 | </fo:flow>
|
|---|
| 502 | </fo:page-sequence>
|
|---|
| 503 | </fo:root></pre>
|
|---|
| 504 | <p>
|
|---|
| 505 | If your table is more complicated, or if defining borders on individual cells becomes too much work, use the code above and nest your table within the middle cell.
|
|---|
| 506 | </p>
|
|---|
| 507 | </div>
|
|---|
| 508 | <a name="N1025B"></a><a name="fo-oddeven"></a>
|
|---|
| 509 | <h4>Recto/Verso Static Content Differences</h4>
|
|---|
| 510 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 511 | <p>
|
|---|
| 512 | One frequent request is that static content be different between recto pages (right-side or odd-numbered pages typically) and verso pages(left-side or even-numbered pages typically).
|
|---|
| 513 | For example, you may wish to place the page number on the "outer" side of each page.
|
|---|
| 514 | There are examples in the FO distribution and in the <a href="http://www.dpawson.co.uk/xsl/sect3/index.html">XSL FAQ FO section</a>.
|
|---|
| 515 | </p>
|
|---|
| 516 | <p>
|
|---|
| 517 | First, define a page master with alternating pages masters for odd and even pages.
|
|---|
| 518 | Then specify appropriate regions in these page masters, giving them different names.
|
|---|
| 519 | Use these names to put different static content in these regions. Here is a self-contained demonstration:
|
|---|
| 520 | </p>
|
|---|
| 521 | <pre class="code"><?xml version="1.0"?>
|
|---|
| 522 | <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
|---|
| 523 | <fo:layout-master-set>
|
|---|
| 524 | <fo:simple-page-master master-name="even"
|
|---|
| 525 | page-height="297mm" page-width="210mm"
|
|---|
| 526 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 527 | margin-left="25mm" margin-right="25mm">
|
|---|
| 528 | <fo:region-body margin-bottom="20mm"/>
|
|---|
| 529 | <fo:region-after region-name="footer-even" extent="20mm"/>
|
|---|
| 530 | </fo:simple-page-master>
|
|---|
| 531 | <fo:simple-page-master master-name="odd"
|
|---|
| 532 | page-height="297mm" page-width="210mm"
|
|---|
| 533 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 534 | margin-left="25mm" margin-right="25mm">
|
|---|
| 535 | <fo:region-body margin-bottom="20mm"/>
|
|---|
| 536 | <fo:region-after region-name="footer-odd" extent="20mm"/>
|
|---|
| 537 | </fo:simple-page-master>
|
|---|
| 538 | <fo:page-sequence-master master-name="document">
|
|---|
| 539 | <fo:repeatable-page-master-alternatives>
|
|---|
| 540 | <fo:conditional-page-master-reference odd-or-even="even"
|
|---|
| 541 | master-reference="even"/>
|
|---|
| 542 | <fo:conditional-page-master-reference odd-or-even="odd"
|
|---|
| 543 | master-reference="odd"/>
|
|---|
| 544 | </fo:repeatable-page-master-alternatives>
|
|---|
| 545 | </fo:page-sequence-master>
|
|---|
| 546 | </fo:layout-master-set>
|
|---|
| 547 | <fo:page-sequence master-reference="document">
|
|---|
| 548 | <fo:static-content flow-name="footer-even">
|
|---|
| 549 | <fo:block text-align="start"><fo:page-number/></fo:block>
|
|---|
| 550 | </fo:static-content>
|
|---|
| 551 | <fo:static-content flow-name="footer-odd">
|
|---|
| 552 | <fo:block text-align-last="end"><fo:page-number/></fo:block>
|
|---|
| 553 | </fo:static-content>
|
|---|
| 554 | <fo:flow flow-name="xsl-region-body">
|
|---|
| 555 | <fo:block/>
|
|---|
| 556 | <fo:block break-before="page"/>
|
|---|
| 557 | </fo:flow>
|
|---|
| 558 | </fo:page-sequence>
|
|---|
| 559 | </fo:root></pre>
|
|---|
| 560 | </div>
|
|---|
| 561 | <a name="N10270"></a><a name="fo-first-page"></a>
|
|---|
| 562 | <h4>Making the First Page Special</h4>
|
|---|
| 563 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 564 | <p>
|
|---|
| 565 | To get a special header on the first page, one possibility is to insert it into the flow instead of the static content. Alternatively, use a page master referring to different page masters for the first page and the rest. Here is a code sample:
|
|---|
| 566 | </p>
|
|---|
| 567 | <pre class="code"><?xml version="1.0"?>
|
|---|
| 568 | <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
|---|
| 569 | <fo:layout-master-set>
|
|---|
| 570 | <fo:simple-page-master master-name="first"
|
|---|
| 571 | page-height="297mm" page-width="210mm"
|
|---|
| 572 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 573 | margin-left="25mm" margin-right="25mm">
|
|---|
| 574 | <fo:region-body margin-bottom="20mm"/>
|
|---|
| 575 | <fo:region-after region-name="footer-first" extent="20mm"/>
|
|---|
| 576 | </fo:simple-page-master>
|
|---|
| 577 | <fo:simple-page-master master-name="rest"
|
|---|
| 578 | page-height="297mm" page-width="210mm"
|
|---|
| 579 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 580 | margin-left="25mm" margin-right="25mm">
|
|---|
| 581 | <fo:region-body margin-bottom="20mm"/>
|
|---|
| 582 | <fo:region-after region-name="footer-rest" extent="20mm"/>
|
|---|
| 583 | </fo:simple-page-master>
|
|---|
| 584 | <fo:page-sequence-master master-name="document">
|
|---|
| 585 | <fo:repeatable-page-master-alternatives>
|
|---|
| 586 | <fo:conditional-page-master-reference page-position="first"
|
|---|
| 587 | master-reference="first"/>
|
|---|
| 588 | <fo:conditional-page-master-reference page-position="rest"
|
|---|
| 589 | master-reference="rest"/>
|
|---|
| 590 | </fo:repeatable-page-master-alternatives>
|
|---|
| 591 | </fo:page-sequence-master>
|
|---|
| 592 | </fo:layout-master-set>
|
|---|
| 593 | <fo:page-sequence master-reference="document">
|
|---|
| 594 | <fo:static-content flow-name="footer-first">
|
|---|
| 595 | <fo:block text-align="center">First page.</fo:block>
|
|---|
| 596 | </fo:static-content>
|
|---|
| 597 | <fo:static-content flow-name="footer-rest">
|
|---|
| 598 | <fo:block text-align-last="center">Other page.</fo:block>
|
|---|
| 599 | </fo:static-content>
|
|---|
| 600 | <fo:flow flow-name="xsl-region-body">
|
|---|
| 601 | <fo:block/>
|
|---|
| 602 | <fo:block break-before="page"/>
|
|---|
| 603 | <fo:block break-before="page"/>
|
|---|
| 604 | </fo:flow>
|
|---|
| 605 | </fo:page-sequence>
|
|---|
| 606 | </fo:root></pre>
|
|---|
| 607 | </div>
|
|---|
| 608 | <a name="N1027E"></a><a name="fo-blank-pages"></a>
|
|---|
| 609 | <h4>Blank Pages</h4>
|
|---|
| 610 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 611 | <p>
|
|---|
| 612 | Sometimes it is desirable to insert blank pages within your output, starting, for example, a new chapter on an odd page or an even page.
|
|---|
| 613 | A blank page can be forced by using <span class="codefrag">break-before="page-even"</span> or similar properties, or by a force-page-count="end-on-odd" on a page sequence.
|
|---|
| 614 | </p>
|
|---|
| 615 | <p>
|
|---|
| 616 | To write "This page is intentionally left blank" (or something similar) on an intentionally blank page, first define a conditional page master with a page master specific for blank pages.
|
|---|
| 617 | This allows you to specify static content for blank pages (by definition, a page is blank if no content from a flow is rendered on the page).
|
|---|
| 618 | Omit your normal headers and footers, and use (for example) an extended header to print the "..left blank" statement:
|
|---|
| 619 | </p>
|
|---|
| 620 | <pre class="code"><?xml version="1.0"?>
|
|---|
| 621 | <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
|---|
| 622 | <fo:layout-master-set>
|
|---|
| 623 | <fo:simple-page-master master-name="normal"
|
|---|
| 624 | page-height="297mm" page-width="210mm"
|
|---|
| 625 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 626 | margin-left="25mm" margin-right="25mm">
|
|---|
| 627 | <fo:region-body margin-bottom="20mm"/>
|
|---|
| 628 | <fo:region-after region-name="footer-normal" extent="20mm"/>
|
|---|
| 629 | </fo:simple-page-master>
|
|---|
| 630 | <fo:simple-page-master master-name="blank"
|
|---|
| 631 | page-height="297mm" page-width="210mm"
|
|---|
| 632 | margin-top="20mm" margin-bottom="20mm"
|
|---|
| 633 | margin-left="25mm" margin-right="25mm">
|
|---|
| 634 | <fo:region-body/>
|
|---|
| 635 | <fo:region-before region-name="header-blank" extent="297mm"/>
|
|---|
| 636 | </fo:simple-page-master>
|
|---|
| 637 | <fo:page-sequence-master master-name="document">
|
|---|
| 638 | <fo:repeatable-page-master-alternatives>
|
|---|
| 639 | <fo:conditional-page-master-reference blank-or-not-blank="not-blank"
|
|---|
| 640 | master-reference="normal"/>
|
|---|
| 641 | <fo:conditional-page-master-reference blank-or-not-blank="blank"
|
|---|
| 642 | master-reference="blank"/>
|
|---|
| 643 | </fo:repeatable-page-master-alternatives>
|
|---|
| 644 | </fo:page-sequence-master>
|
|---|
| 645 | </fo:layout-master-set>
|
|---|
| 646 | <fo:page-sequence master-reference="document" force-page-count="end-on-even">
|
|---|
| 647 | <fo:static-content flow-name="footer-normal">
|
|---|
| 648 | <fo:block text-align="center">Normal footer</fo:block>
|
|---|
| 649 | </fo:static-content>
|
|---|
| 650 | <fo:static-content flow-name="header-blank">
|
|---|
| 651 | <fo:block space-before="100mm" text-align-last="center">
|
|---|
| 652 | Intentionally left blank.</fo:block>
|
|---|
| 653 | </fo:static-content>
|
|---|
| 654 | <fo:flow flow-name="xsl-region-body">
|
|---|
| 655 | <fo:block/>
|
|---|
| 656 | </fo:flow>
|
|---|
| 657 | </fo:page-sequence>
|
|---|
| 658 | </fo:root></pre>
|
|---|
| 659 | </div>
|
|---|
| 660 | <a name="N10292"></a><a name="fo-preformat"></a>
|
|---|
| 661 | <h4>Preformatting Content</h4>
|
|---|
| 662 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 663 | <p>
|
|---|
| 664 | Sometimes it is desirable to retain linebreaks and hard spaces, and to get preformatted text to pass through without being changed.
|
|---|
| 665 | The XSL-FO specification provides some properties for this: <a href="http://www.w3.org/TR/xsl/slice7.html#white-space-collapse">white-space-collapse</a> and <a href="http://www.w3.org/TR/xsl/slice7.html#linefeed-treatment">linefeed-treatment</a>.
|
|---|
| 666 | In FOP, use white-space-collapse="false" on an enclosing block.
|
|---|
| 667 | </p>
|
|---|
| 668 | <div class="frame warning">
|
|---|
| 669 | <div class="label">Warning</div>
|
|---|
| 670 | <div class="content">
|
|---|
| 671 | Due to a bug in current versions of FOP, setting white-space-collapse="false" will also preserve line breaks in the text. Do not rely on this behavior, as it is non-conformant and will be changed.
|
|---|
| 672 | </div>
|
|---|
| 673 | </div>
|
|---|
| 674 | </div>
|
|---|
| 675 | <a name="N102A7"></a><a name="fo-total-pages"></a>
|
|---|
| 676 | <h4>Total Document Pages</h4>
|
|---|
| 677 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 678 | <p>
|
|---|
| 679 | It is frequently desirable to know the total number of pages in a document and to use that number within the document.
|
|---|
| 680 | For example, you might wish to show the page number on the first page as being "page 1 of 12".
|
|---|
| 681 | To accomplish this, place an empty block with an id at the end of the flow:
|
|---|
| 682 | </p>
|
|---|
| 683 | <pre class="code"><fo:flow ...>
|
|---|
| 684 | ...
|
|---|
| 685 | <fo:block id="last-page"/>
|
|---|
| 686 | </fo:flow></pre>
|
|---|
| 687 | <p>
|
|---|
| 688 | Get the number of the last page as follows:
|
|---|
| 689 | </p>
|
|---|
| 690 | <pre class="code"> <fo:page-number-citation ref-id="last-page"/></pre>
|
|---|
| 691 | <p>
|
|---|
| 692 | This does not work in certain situations: multiple page sequences, an initial page number other than 1, or forcing a certain page count, thereby producing blank pages at the end.
|
|---|
| 693 | </p>
|
|---|
| 694 | <div class="frame warning">
|
|---|
| 695 | <div class="label">Warning</div>
|
|---|
| 696 | <div class="content">
|
|---|
| 697 | There is no reliable way to get the real total page count with FO mechanisms. You can only get <em>page numbers</em>.
|
|---|
| 698 | </div>
|
|---|
| 699 | </div>
|
|---|
| 700 | <p>
|
|---|
| 701 | The FOP library provides a method to get the total page count after an FO document has been rendered.
|
|---|
| 702 | One possibility is to implement your own wrapper to do a dummy rendering, inquire the total page count and then perform the real rendering, passing the total page count to the XSLT processor to splice it into the generated FO.
|
|---|
| 703 | For example:
|
|---|
| 704 | </p>
|
|---|
| 705 | <pre class="code">import org.apache.fop.apps.*;
|
|---|
| 706 | import org.xml.sax.*;
|
|---|
| 707 | import java.io.*;
|
|---|
| 708 | import javax.xml.transform.*;
|
|---|
| 709 | import javax.xml.transform.sax.*;
|
|---|
| 710 | import javax.xml.transform.stream.*;
|
|---|
| 711 |
|
|---|
| 712 | class rendtest {
|
|---|
| 713 |
|
|---|
| 714 | public static void main(String args[]) {
|
|---|
| 715 | try {
|
|---|
| 716 | Driver driver=new Driver();
|
|---|
| 717 | driver.setOutputStream(new FileOutputStream(args[2]));
|
|---|
| 718 | driver.setRenderer(Driver.RENDER_PDF);
|
|---|
| 719 | Transformer transformer=TransformerFactory.newInstance()
|
|---|
| 720 | .newTransformer(new StreamSource(new File(args[1])));
|
|---|
| 721 | transformer.setParameter("page-count","#");
|
|---|
| 722 | transformer.transform(new StreamSource(new File(args[0])),
|
|---|
| 723 | new SAXResult(driver.getContentHandler()));
|
|---|
| 724 | String pageCount=Integer.toString(driver.getResults().getPageCount());
|
|---|
| 725 | driver=new Driver();
|
|---|
| 726 | driver.setOutputStream(new FileOutputStream(args[2]));
|
|---|
| 727 | driver.setRenderer(Driver.RENDER_PDF);
|
|---|
| 728 | transformer=TransformerFactory.newInstance()
|
|---|
| 729 | .newTransformer(new StreamSource(new File(args[1])));
|
|---|
| 730 | transformer.setParameter("page-count",pageCount);
|
|---|
| 731 | transformer.transform(new StreamSource(new File(args[0])),
|
|---|
| 732 | new SAXResult(driver.getContentHandler()));
|
|---|
| 733 | }
|
|---|
| 734 | catch( Exception e) {
|
|---|
| 735 | e.printStackTrace();
|
|---|
| 736 | }
|
|---|
| 737 | }
|
|---|
| 738 | }</pre>
|
|---|
| 739 | <p>
|
|---|
| 740 | Declare and use the parameter "page-count" in your XSLT.
|
|---|
| 741 | </p>
|
|---|
| 742 | <div class="frame warning">
|
|---|
| 743 | <div class="label">Warning</div>
|
|---|
| 744 | <div class="content">
|
|---|
| 745 | It is possible to run into a convergence problem with this solution. Replacing the "#" placeholder in the first run with the actual page count in the second run, may change the total number of pages in the document.
|
|---|
| 746 | </div>
|
|---|
| 747 | </div>
|
|---|
| 748 | </div>
|
|---|
| 749 | <a name="N102D2"></a><a name="fo-region-align"></a>
|
|---|
| 750 | <h4>Aligning Regions</h4>
|
|---|
| 751 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 752 | <p>
|
|---|
| 753 | Although it may seem counterintuitive, the regions on a page may overlap.
|
|---|
| 754 | Defining a certain body region does not automatically constrain other regions.
|
|---|
| 755 | Instead, this has to be done explicitly.
|
|---|
| 756 | Sometimes for creative reasons it may be desirable to have the regions overlap.
|
|---|
| 757 | Otherwise, you will want to set them up so that the header does not overlap body content or the body extend into the footer.
|
|---|
| 758 | </p>
|
|---|
| 759 | <p>
|
|---|
| 760 | Assuming you wish to keep the regions separate, if you have a header region with an extent of 20mm, you should define a margin for the body region of at least 20mm too.
|
|---|
| 761 | Otherwise the header content may overwrite some stuff in the body region.
|
|---|
| 762 | This applies similarly to the extent of the after region and the bottom margin of the body region.
|
|---|
| 763 | </p>
|
|---|
| 764 | </div>
|
|---|
| 765 | <a name="N102DF"></a><a name="fo-lines"></a>
|
|---|
| 766 | <h4>Drawing Lines</h4>
|
|---|
| 767 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 768 | <p>
|
|---|
| 769 | It is frequently desirable to draw lines in a document, as separators, side bars or folding marks. There are several possibilities:
|
|---|
| 770 | </p>
|
|---|
| 771 | <ul>
|
|---|
| 772 |
|
|---|
| 773 | <li>
|
|---|
| 774 | Horizontal lines can be drawn using <a href="http://www.w3.org/TR/xsl/slice6.html#fo_leader">fo:leader</a>.
|
|---|
| 775 | </li>
|
|---|
| 776 |
|
|---|
| 777 | <li>
|
|---|
| 778 | Use a solid border on a suitable fo:block. This will work for horizontal and vertical lines only.
|
|---|
| 779 | </li>
|
|---|
| 780 |
|
|---|
| 781 | <li>
|
|---|
| 782 | Insert a graphic. GIF, PNG SVG, whatever.
|
|---|
| 783 | </li>
|
|---|
| 784 |
|
|---|
| 785 | </ul>
|
|---|
| 786 | </div>
|
|---|
| 787 | <a name="N102F9"></a><a name="fo-validate"></a>
|
|---|
| 788 | <h4>Validating XSL-FO</h4>
|
|---|
| 789 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 790 | <p>
|
|---|
| 791 |
|
|---|
| 792 | <a href="http://www.renderx.com">RenderX</a> has provided an <a href="http://www.renderx.com/Tests/validator/fo.dtd.html">Unofficial DTD for FO Documents</a>, which may be helpful in validating general FO issues.
|
|---|
| 793 | </p>
|
|---|
| 794 | <p>
|
|---|
| 795 | FOP also maintains an <a href="http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-fop/docs/foschema/fop.xsd?rev=HEAD&content-type=text/plain">Unofficial FOP Schema</a> in the FOP CVS Repository.
|
|---|
| 796 | This document can be used either to validate against the FO standard, or against the actual FOP implementation.
|
|---|
| 797 | See the notes near the beginning of the document for instructions on how to use it.
|
|---|
| 798 | </p>
|
|---|
| 799 | </div>
|
|---|
| 800 | <a name="N10312"></a><a name="landscape"></a>
|
|---|
| 801 | <h4>Producing landscape pages</h4>
|
|---|
| 802 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 803 | <p>
|
|---|
| 804 | Pages in landscape format can easily be produced by exchanging the page-height and page-width values of a simple-page-master element.
|
|---|
| 805 | </p>
|
|---|
| 806 | <pre class="code"><fo:layout-master-set>
|
|---|
| 807 | <fo:simple-page-master master-name="A4-portrait" page-height="29.7cm" page-width="21cm" [..]>
|
|---|
| 808 | <fo:region-body/>
|
|---|
| 809 | </fo:simple-page-master>
|
|---|
| 810 | <fo:simple-page-master master-name="A4-landscape" page-height="21cm" page-width="29.7cm" [..]>
|
|---|
| 811 | <fo:region-body/>
|
|---|
| 812 | </fo:simple-page-master>
|
|---|
| 813 | </fo:layout-master-set></pre>
|
|---|
| 814 | </div>
|
|---|
| 815 | <a name="N10320"></a><a name="external-resources"></a>
|
|---|
| 816 | <h4>External Resources</h4>
|
|---|
| 817 | <div style="margin-left: 0 ; border: 2px">
|
|---|
| 818 | <p>Resources needed by an XSL-FO file that are external to it (graphics, for example), are defined in the XSL-FO standard as being of type "uri-specification". This is defined in the standard at <a target="_top" href="http://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#section-N8794-Property-Datatypes">Section 5.11 Property Datatypes</a>, which includes a link to the URI standard itself. Refer to the XSL-FO and URI standards themselves for more detailed instructions.</p>
|
|---|
| 819 | <p>URIs may be either absolute or relative to a base URI. (See <a href="configuration.html">FOP: Configuration</a> for information on setting the base URI for a FOP session). Here is an example referencing an external-graphic that is relative to the base URI:</p>
|
|---|
| 820 | <pre class="code"><fo:external-graphic src="url('images/logo.jpg')"/></pre>
|
|---|
| 821 | <p>Here is an example referencing an external-graphic that is an absolute URI on a local filesystem:</p>
|
|---|
| 822 | <pre class="code">fo:external-graphic src="url('file:d:///images/logo.jpg')"/></pre>
|
|---|
| 823 | </div>
|
|---|
| 824 | </div>
|
|---|
| 825 |
|
|---|
| 826 | </div>
|
|---|
| 827 | </td><td width="10"><img width="10" height="1" alt="" src="skin/images/spacer.gif"></td>
|
|---|
| 828 | </tr>
|
|---|
| 829 | <!--================= end Content==================-->
|
|---|
| 830 | </table>
|
|---|
| 831 | </td>
|
|---|
| 832 | </tr>
|
|---|
| 833 | </table>
|
|---|
| 834 | <!--================= end Menu, NavBar, Content ==================-->
|
|---|
| 835 | <!--================= start Footer ==================-->
|
|---|
| 836 | <table summary="footer" cellspacing="0" cellpadding="0" width="100%" border="0">
|
|---|
| 837 | <tr>
|
|---|
| 838 | <td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1" width="1" alt="" src="skin/images/spacer.gif"><a href="skin/images/label.gif"></a><a href="skin/images/page.gif"></a><a href="skin/images/chapter.gif"></a><a href="skin/images/chapter_open.gif"></a><a href="skin/images/current.gif"></a><a href="/favicon.ico"></a></td>
|
|---|
| 839 | </tr>
|
|---|
| 840 | <tr>
|
|---|
| 841 | <td colspan="2" bgcolor="#CFDCED" class="copyright" align="center"><font size="2" face="Arial, Helvetica, Sans-Serif">Copyright ©
|
|---|
| 842 | 1999-2003 The Apache Software Foundation. All rights reserved.<script type="text/javascript" language="JavaScript"><!--
|
|---|
| 843 | document.write(" - "+"Last Published: " + document.lastModified);
|
|---|
| 844 | // --></script></font></td>
|
|---|
| 845 | </tr>
|
|---|
| 846 | <tr>
|
|---|
| 847 | <td colspan="2" align="left" bgcolor="#CFDCED" class="logos"></td>
|
|---|
| 848 | </tr>
|
|---|
| 849 | </table>
|
|---|
| 850 | <!--================= end Footer ==================-->
|
|---|
| 851 | </body>
|
|---|
| 852 | </html>
|
|---|