XSL FO

Extensible Stylesheet Language – Formatting Objects (XSL-FO), also referred to as XSL, is a markup language for formatting XML data for output to screen, paper, or other media.

XSL-FO transformation pipeline: XML and XSL feed an XSLT engine (Saxon or Xalan) producing an XSL-FO document, which an XSL-FO formatter (Apache FOP or RenderX) renders to PDF, PCL, TeX, PS, or RTF for printing
An XML document and an XSL stylesheet are fed into an XSLT engine (such as Saxon or Xalan), which produces an XSL-FO document. That XSL-FO document is then fed into an XSL-FO formatter (such as Apache FOP or RenderX), which renders the final output as PDF, PCL, TeX, PS, or RTF, ready for printing.

The following defines a simple page master and a two-block page body.

<?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="simple"
              page-height="11in" page-width="8.5in"
              margin-top="1.0in" margin-bottom="1.0in"
              margin-left="1.25in" margin-right="1.25in">
         <fo:region-body margin-top="0.25in" />
      </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="simple">
      <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">
              Title
         </fo:block>
         <fo:block font-size="12pt" font-family="sans-serif"
                       line-height="15pt" space-after.optimum="3pt"
                       text-align="justify">
               Some Text
         </fo:block>
      </fo:flow>
   </fo:page-sequence>
</fo:root>