pdfreport - Generate PDF reports from PostgreSQL
pdfreport [-x] [-h host] [-p port] [-U user] [-P password] [-D variable=value] [-Z debuglevel] report.xml
pdfreport parses an XML template and replaces elements in it from the results of PostgreSQL select statements. It then converts the XML to PDF output.
It has optional support for embedded graphs and charts using the chartdir library.
Each template must be a well-formed XML file. If the file is not well-formed pdfreport will be unable to parse it, and will exit with the error ``Failed to parse <filename>''. An XML parser, such as xmlwf from the expat distribution may be useful in finding the exact location of the error.
The outermost tag in the template must be <report>. Within this may be <sql>, <loop>, <table>, <meta> or <t> elements. It takes no attributes.
If this tag has an attribute name
with value title
then the
content of this tag will be used as the title of the report on
the web page indexing all the reports. This is not the same as
the title at the top of the report, and does not affect the generated
PDF file at all, but can be used by wrapper scripts to e.g. generate
HTML index pages for reports.
<meta name="title">Daily User Report</meta>
A loop has a name and a loop count variable, set by several tag attributes:
Either count or end must be provided. All other attributes are optional.
The contents of the <loop> tag will be duplicated once for each pass
through the loop. Any occurence of the string $<name>.row$
(where <name> is
the name of the loop) will be replaced by the value of the loop count
variable.
This executes a single SQL query to the PostgreSQL database. If the query is
a select then it will duplicate the contents of the tag once for each
row returned, replacing any occurence of $<name>.<column>$
with
the value returned from the database - where <name> is the value of the
name attribute of the sql tag.
There are two standard tags:
Any attributes other than query and name will be bound as named parameters (oracle-style - :name) into the query. There are some odd issues with doing this with PostgreSQL with the current Qt libraries, so using this feature isn't recommended yet.
A container for text, and other things. Similar to <P> in HTML. May contain <b>, <i>, <u>, <br/>, <font>, <t>, <img/> and <chart>.
Optional attributes include:
Makes the text contained by the tag bold.
Makes the text contained by the tag italic.
Underlines the text contained by the tag. (Not supported).
Inserts a line break. Takes one optional attribute:
Changes the font of the text contained within the tag.
Optional attributes:
Includes an image, in jpeg, png or gif format.
If no width is specified, but a height is, the width will be chosen to preserve the aspect ratio of the image. If neither height nor width is specified then the image will be scaled to the full width of the page.
If no height is specified, but a width is, the height will be chosen to preserve the aspect ratio of the image.
Plots a chart.
If neither width nor height are specified the width will default to the maximum usable width of the page.
Unless both width and height are specified the chart will default to being 80% as high as wide.
A chart may contain one or more <data> tags. Each of those can contain zero or more <d> tags. Each of those must contain an <x> and a <y> tag. It may contain a <title> tag.
The title of the chart.
Contains (typically) one dataset within a chart. Contains one or more <d> elements.
Defines a single datapoint on the chart. Contains an <x> and a <y> element.
The x value for this datapoint. Need not be numeric.
The y value for this datapoint. Must be numeric.
Outermost tag for a table. Contains zero or more <tr> tags.
Defines one row of a table. Contains one or more <td> elements.
Defines a single cell of a table. It can contain anything a <t> tag can. Tables embedded within tables are not recommended yet.
Colours are used in a number of places - background colours, font colours. Within CDML text, follow the CDML colour syntax. Elsewhere colours are specified as
Any single colour can be preceded by a number and '%' to specify an alpha channel.
Multiple colours, separated by colons can be used in a single colour value. When used ss the bg attribute of a <td> field the colours will be used in sequence on successive table rows. When used as the bg attribute of <chart> or <title> they define a multiple colour gradient, and each colour element can be followed by '.' and a number to set a width for that colour gradient.