How to Turn an XML File into a Readable PDF (With or Without XSLT)
Make XML human-readable: what XSLT stylesheets are, using one to produce a PDF, printing XML as a tree or tidy source, and dealing with broken XML.
&c=%23155e75&k=to-pdf)
How to Turn an XML File into a Readable PDF
XML files arrive more often than people expect: an electronic invoice from a supplier, a tax or payroll submission, a bank statement export, a product feed, a configuration file. Opened in a text editor they are a wall of tags. This guide explains how to make them readable and printable with XML to PDF.
Data and presentation
XML holds data with labels, for example <Total currency="GBP">1250.00</Total>. It says nothing about how the data should look. That job belongs to a stylesheet. The classic stylesheet language for XML is XSLT, which transforms XML into another document, usually HTML for display.
Many official formats publish an XSLT stylesheet for exactly this purpose. E-invoicing networks, tax authorities and banks often offer a "visualisation" stylesheet that turns the XML into a familiar invoice or statement layout.
Using a stylesheet
Load the XML and choose the XSL or XSLT file. The browser's built-in XSLT 1.0 engine applies it, and the resulting document is laid out as a PDF with headings, paragraphs, lists and tables. If the XML names a stylesheet in its first lines, the report shows the name so you know what to look for.
Browsers are gradually removing XSLT support, and some already have. If yours cannot run it, the tool says so; Firefox still supports XSLT, and the tree view always works.
Without a stylesheet
Two views make any XML readable:
- Tree view shows each element on its own line, indented by depth, with attributes in brackets and text values after a colon. Non-programmers find it easiest.
- Pretty-printed source shows the XML itself, indented and with one element per line. Developers and support staff use it to read structures and spot problems.
Both use a monospaced font so the indentation lines up across pages.
When the XML is broken
A single missing closing tag or an illegal character makes XML invalid. The report shows the parser's error message, which usually names the line and the problem. Fix it in a text editor and load the file again.
Common formats
- E-invoices in UBL or CII format.
- SEPA and camt bank statements.
- Payroll and tax submissions.
- Product feeds for marketplaces.
- Sitemaps and RSS feeds.
- Office configuration and export files.
Example
A supplier sends a 38 KB e-invoice XML with its XSLT stylesheet. The PDF has two pages: supplier and buyer blocks, a table of 12 items and the totals, ready for the accounts file. Without the stylesheet, the tree view prints 214 tidy lines that still show every value clearly.
Where to find the stylesheet
Look in the documentation of whoever produced the XML. E-invoicing standards and national tax portals often publish official visualisation stylesheets for download. Software vendors sometimes ship them with their export function. If the XML header mentions an .xsl file, search for that file name. If no stylesheet exists, the tree view is a perfectly good record.
Keeping the original
For accounting and tax purposes, the XML is usually the legal record and the PDF a readable copy. Keep both together, with the same file name.
Paper and text size
Wide XML trees with deep nesting fit better on A4 landscape or A3 with a smaller text size. For invoices produced by a stylesheet, A4 portrait is usually right.
Limits
Only XSLT 1.0 is supported, because that is what browsers provide. Colours, CSS layout and images in the transformed output are simplified into a clean document. Very large XML files are slow in tree view.
Privacy
Invoices and tax data are confidential. The transformation runs in your browser and nothing is uploaded.


&c=%23b45309&k=from-pdf)
