Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Creating PDF documents with XSL-FO

1,462 views

Published on

Creating PDF documents with XSL-FO

Published in: Software
  • Hello! Who wants to chat with me? Nu photos with me here http://bit.ly/helenswee
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Creating PDF documents with XSL-FO

  1. 1. Creating PDF documents with XSL-FO Audrius Mičiulis
  2. 2. XSL  XSLT, a language for transforming XML documents  XSL-FO, a language for formatting XML documents  XPath, a language for navigating in XML documents 2
  3. 3. XSL-FO  W3C recommendation from 15th October 2001  XSL-FO describes the formatting of XML data for output to screen, paper or other media.  Java implementation: Apache™ FOP 3
  4. 4. Apache™ FOP  Current version  1.1 (20th October 2012)  Supported output:  PDF, PostScript, Direct printer output (PCL), RTF, etc.  Limitations:  Most of XSL-FO 1.1 (flow maps, table markers, indexes, etc.)  Some of XSL-FO 1.0 (automatic table layout, floats) 4
  5. 5. XSL-FO document structure <?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="A4"> <!-- Page template --> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="A4"> <!-- Page content --> </fo:page-sequence> </fo:root> 5
  6. 6. XSL-FO Regions 6
  7. 7. XSL-FO elements  <fo:block />  <fo:table />  <fo:table-column />  <fo:table-row />  <fo:table-cell />  <fo:list-block />  <fo:list-item />  <fo:list-item-label />  <fo:list-item-body /> 7
  8. 8. Formatting XSL-FO with XSLT + XPath  Convert object(s) to document object  Use dozer  Generate XML  Use JAXB  Evaluate XSLT transformation  Evaluate XSL-FO transformation 8
  9. 9. Formatting XSL-FO with XSLT + XPath  Advantages  W3C recommendation, syntax already known to developers  Easy data filtering with XPath  Possibility to store XML that holds additional data  Possibility to regenerate later  Possibility to use existing XML files  Possibility to execute multiple XSLT transformations  XSL templates are very reusable  Disadvantages  Too much code to write 9
  10. 10. Formatting XSL-FO with Velocity  Put all needed objects to Map  Evaluate Velocity template  Evaluate XSL-FO transformation 10
  11. 11. Formatting XSL-FO with XSL + XPath  Advantages  Less code, saves time  Possibility to call methods  Possibility to use existing Java classes (e.g. Utils)  Possibility to write macros  Disadvantages  Template is not XML  Templates breaks on Java model changes  Additional dependency 11
  12. 12. Klausimai 12

×