Skip to main content

Transformation

The webPDF server can apply a transformation to the source format before converting a document via the "Converter" web service, provided that the data is in XML format. The result of the transformation is then used as a new source document for the conversion and converted into a PDF document.

tip

Ideally, at the end of the transformation there is an HTML document, which is then converted into a PDF document using the HTML converter.

To enable this transformation, the transform block must be present in the web service call parameters:

API {REST}:/converter

{
 "converter": {
   "html": {
     "downloadImages": true,
   },
   "pdfa": {
     "convert": {
       "level": "3b",
     }
   },
   "transform": {
     "xslTransformation": {
       "resources": {
         "file": [
           {
             "fileName": "",
             "format": "xslt",
             "source": "value",
             "uri": "",
             "value": ""
           }
         ]
       }
     }
   }
 }
}

If this block is available, then the transferred document (XML document) is first converted by applying an XLST transformation. The resulting document is then passed to the converter for further processing as a new source document. If, for example, an HTML document results from the transformation, the corresponding parameters are then also applied (see html above) that were passed for the format. Other parameters, such as a PDF/A conversion (see example above), will then also be applied.

In the transform element, xslTransformation> or xInvoice determines the type of transformation. Thereby xslTransformation represents a generic transformation for general XML data, while xInvoice is a targeted transformation that expects the XML data in the concrete XInvoice format.

With xslTransformation the transformations are passed as XSLT (Extensible Stylesheet Language Transformations) under resources. One to n documents can be entered via the file element, each of which corresponds to a resource in the transformation. With the resources at least one XSLT document must be indicated, so that the transformation can be executed. In addition, resources can also be defined via file (such as "CSS Stylsheets), which are required later, for example, during the conversion of the output document (e.g. HTML). The data of the file element is passed BASE64 encoded.

note

For the XSLT transformation the webPDF server uses the library "Saxon-HE" in version 12. When defining and applying the transformations, the technical possibilities and limitations of the library apply.

Currently, the open source implementation of XSLT 3.0, XPath 2.0 and 3.1, and XQuery 3.1 is supported for XSLT transformation. Please see the corresponding note regarding the limitation in the implementation at https://www.saxonica.com/products/feature-matrix-12.xml of the library "Saxon-HE".

Besides the general transformation, special XML data such as XInvoice can be transformed in a simplified way to create a visual image. For this purpose the element xslTransformation is used instead of the element xInvoice and the detailed specification of the XSLT documents is not necessary. For details, see "XInvoice".