On line guide/help
You are on page 10 of the online help. Navigate sequentially through the guide pages or search for a topic of interest to you.
Index Prev. NextSection
Report flow, data loops and master / detail reports
The section element defines the flow of the report. A template contains one or more sections, processed in the order they are written. A section can:
- print one or more contents (print_content)
- create a new page (page)
- set variables (var)
- generate the PDF document (output)
- contain one nested section
A section can be linked to a data provider (for example a query on a database): in this case the section is repeated for each data row, and the fields of the current row can be printed with the placeholders {section_id.field_name}. A section not linked to data is processed only once.
Parameters
Elements / attributes of the <section> element:
<id> (required) Unique identifier of the section. It is the key used in the PHP code to link a data provider to the section (SetSection method) and the prefix of the data placeholders, eg. {ord.orderNumber}
<page> Optional page settings (format, orientation, ..): if set, a new page is created each time the section is repeated (for each data row, and when the nested section needs a new page)
<print_content> Prints a content (it can be used several times)
<section> Optional nested section (only one), usually linked to the detail rows of the current data row
<var> Sets a variable
<output> Generates the PDF document (usually in the last section of the template)
Attributes used to print a list of data rows on the same page (sections without the page element, eg. the detail rows of an invoice):
<row_height> Height of each row (default 0): each data row is printed row_height lower than the previous one. The coordinates of the printed contents are the coordinates of the first row.
<rows_count> Maximum number of rows printed on each page (default 1)
<y_start> Y position of the first row (default 0). It is used to calculate the current position (placeholder {Y}) and to check the y_end limit.
<y_end> Maximum Y position of the rows (default 296). To use only this limit, set rows_count to a high value.
<columns> Number of columns (default 1, version 1.0.12 or later): the rows fill the columns from left to right, then the next line. Each page contains rows_count x columns data rows (eg. a sheet of labels)
<column_width> Distance between the columns (mm): each column is printed column_width to the right of the previous one
When rows_count or y_end is reached, the section stops and the processing goes back to the parent section. If the parent section has the page element, it creates a new page, prints its contents again (eg. header and footer) and then the nested section continues with the remaining rows.
The parent section is printed again for each page also when it is not linked to a data provider, eg. a price list: a section with the header and the footer, and a nested section with the product rows. If the parent section has no page element, the remaining rows continue on a new page with the default page settings. (Version 1.0.12 or later: in the previous versions, when the parent section was not linked to a data provider, the rows that did not fit in the first page were not printed.)
Basic section example
Master / detail report
The following template prints one page for each order (master section "ord"), with the order rows (detail section "ord_det") printed in a table, 11 rows for each page. If an order has more than 11 rows, a new page is created and the order header and footer are printed again. The last section, not linked to data, generates the PDF document.
Master / detail template (orders.xml)
The PHP code links the data providers to the two sections. The query of the detail section contains the placeholder {ord.orderNumber}: it is replaced with the number of the current order each time the detail section starts. See the Data providers page.
PHP code
Labels and badges: sections with columns
A sheet of labels is a single section with columns (version 1.0.12 or later). The following template prints 24 product labels on each A4 page (3 columns x 8 lines, label 63.5 x 38.1 mm): the content is drawn at the coordinates of the first label, the following labels are moved by column_width to the right and by row_height down. When the page is full, a new page is created. A complete example is the Product labels template.
Sheet of labels (labels.xml)
The data provider of the section reads the products, eg. from a CSV file:
PHP code