# PDFReport for PHP > PDFReport is a free, open-source PHP library (LGPL-3.0, Composer package alienproject/pdfreport, built on TCPDF) that generates PDF documents from an XML template. The template describes the layout (pages, texts, lines, rectangles, images, barcodes, charts) and contains placeholders that are replaced with data from PHP variables or database queries. Notes for AI assistants writing or editing PDFReport templates: - The root element is .
elements define the report flow and are linked to data in PHP with SetSection(); elements contain the printed elements and are printed with . Only one nested section is allowed inside a section (master / detail). - Placeholders: {VARIABLE} for variables set with SetVar() or , {section.field} for data fields, system variables such as {CURRENTDATE}, {CURRENTTIME}, {section.PAGEINDEX}. - Use I to show the PDF in the browser; F saves it to a server file, S returns it as a string from BuildReport(). - {PAGECOUNT} currently returns the current page number, not the total: to print "page N of M" calculate the number of pages in PHP and pass it with SetVar(). - Use only the elements and attributes described in the guide. Test the template: an invalid XML template raises an exception with the line, column and reason of the error. ## Guide ### Getting started - [Introduction](https://alienproject.org/help/index/1): How the PDFReport library works - [Installation](https://alienproject.org/help/index/2): Install the library - [Test installation](https://alienproject.org/help/index/3): Quick check - [Version history](https://alienproject.org/help/index/6): Current version : 1.0.11 - 29 Sep. 2026 ### Template structure - [Template basic](https://alienproject.org/help/index/7): Introduction to the XML template format - [Comments](https://alienproject.org/help/index/8): Comments in the XML template - [Page settings](https://alienproject.org/help/index/9): Defining default page settings - [New page](https://alienproject.org/help/index/11): Creating a new page - [Content](https://alienproject.org/help/index/14): Content section - [Print content](https://alienproject.org/help/index/12): Print content section - [Section](https://alienproject.org/help/index/10): Report flow, data loops and master / detail reports - [Generate output](https://alienproject.org/help/index/13): Create output PDF file - [Conditional printing](https://alienproject.org/help/index/38): Print an element only when a condition is true ### Data - [Data placeholder](https://alienproject.org/help/index/32): Using data through variables or database fields - [Variables](https://alienproject.org/help/index/39): Set variables in the PHP code and in the template - [System variables](https://alienproject.org/help/index/33): Automatic placeholders - [Value formatting](https://alienproject.org/help/index/41): Format numbers, percentages and currency values - [Data providers](https://alienproject.org/help/index/42): Read the report data from a database ### Drawing elements - [Line](https://alienproject.org/help/index/15): Draw a line - [Box](https://alienproject.org/help/index/17): Draw a text - [Rectangle](https://alienproject.org/help/index/19): Draw a rectangle - [Circle](https://alienproject.org/help/index/20): Draw a circle - [Barcode](https://alienproject.org/help/index/22): Print a barcode - [Image](https://alienproject.org/help/index/23): Print an image ### Styles - [Line style](https://alienproject.org/help/index/16): Set the line style - [Fillstyle](https://alienproject.org/help/index/18): Set the fill style - [Font](https://alienproject.org/help/index/21): Set the font style - [Opacity](https://alienproject.org/help/index/24): Set the default transparency factor - [Text fit](https://alienproject.org/help/index/40): Fit long texts into the box area ### Charts - [Piechart](https://alienproject.org/help/index/25): Draw a pie / ring chart - [Singlebarchart](https://alienproject.org/help/index/26): Draw a single bar chart - [Gaugechart](https://alienproject.org/help/index/27): Draw a gauge chart - [Kpichart](https://alienproject.org/help/index/28): Draw a KPI chart - [Bar chart](https://alienproject.org/help/index/34): Draw a bar chart - [Line chart](https://alienproject.org/help/index/35): Draw a line or area chart - [Legend](https://alienproject.org/help/index/29): Draw a chart legend - [Segmentlist](https://alienproject.org/help/index/30): Define the chart sections - [Datalist](https://alienproject.org/help/index/36): Data list for charts - [Measures](https://alienproject.org/help/index/37): Chart measures ### Reference - [PHP API reference](https://alienproject.org/help/index/43): Public methods of the PDFReport class - [Debugging](https://alienproject.org/help/index/44): Log file and common errors ### Samples - [Basic test report](https://alienproject.org/help/index/31): Build a basic report with a single php file - [Master-Details report in Laravel](https://alienproject.org/help/index/4): Build a master-details report using the Laravel framework - [Master-Details report in Symfony](https://alienproject.org/help/index/5): Build a master-details report using the Symfony framework ## Example templates - [Text and shapes](https://alienproject.org/sample/example_02.xml): fonts, colors, fills, borders, lines and shapes - [Sales order](https://alienproject.org/sample/example_03.xml): multi-page order with master and detail sections read from the database - [Shipping label](https://alienproject.org/sample/example_04.xml): double shipping label with barcode and icons - [Energy bill](https://alienproject.org/sample/example_05.xml): bill with consumption details and ring chart, data from variables - [Charts](https://alienproject.org/sample/example_06.xml): KPI, gauge, pie, bar and line/area charts with datalists - [Sales invoice](https://alienproject.org/sample/example_07.xml): multi-page invoice with master and detail sections - [Hello World](https://alienproject.org/sample/example_01.xml): the minimal template (the PHP code is on the home page and in the Test installation page of the guide) ## Optional - [Source code on GitHub](https://github.com/alienproject-org/pdfreport) - [Package on Packagist](https://packagist.org/packages/alienproject/pdfreport) - [Home page](https://alienproject.org/): overview, examples and how to create templates with AI