Styling of PDF Reports
From opReports version 4.6.7, reports can be generated as a PDF document.
PDF reports are generated from the HTML version of the report server-side utilising wkhtmltopdf. There are 3 configuration options which control how this PDF document will display.
opreports_pdf_orientation
Controls whether to render the PDF report in landscape or portrait orientation.
The available values are portrait or landscape, with portrait being the default.
landscape is recommend to maximise the horizontal space available for reports.
opreports_pdf_css
A custom CSS document location which will be applied to the HTML report only for the purposes of rendering the PDF report.
If not set, the CSS file in <omk_public>/omk/css/opReports_report_pdf.css will be used for this purpose.
To apply different CSS, create a new CSS file (or make a copy of the default), and set the opreports_pdf_css configuration option to the location of your custom CSS document, e.g.:
"opreports_pdf_css" : "<omk_public>/omk/css/opReports_report_pdf_custom.css"`
opreports_default_closing_image
An optional custom image (normally used for branding of PDF reports) can be specified using this option.
To include a logo at the end of your PDF report, place the custom image on your server and reference it, e.g.:
"opreports_default_closing_image" : "<omk_public>/omk/img/branded_pdf_logo.png"
Valid file types are JPG, PNG and GIF.
Note that this file must exist, and the configuration option set prior to the HTML version of the report being generated (before the report is run).
Example: Including a closing logo, right aligned, with PDF in portrait orientation.
So that the image is available to the application, first copy your logo file to your server.
To right align the image you will need to modify the PDF generation CSS file, first make a copy of <omk_public>/omk/css/opReports_report_pdf.css
Modify this file to include your custom CSS:
/* inlude this at the end of your custom pdf css file */
img.closing-image {
float: right;
margin-top: 20px;
}Now modify your opCommon.json configuration to include all three options under the opreports section:
"opreports_pdf_css": "<omk_public>/omk/css/custom_pdf.css",
"opreports_default_closing_image": "<omk_public>/omk/img/fw_logo.png",
"opreports_pdf_orientation": "portrait",This will result in your logo at the end of the generated portrait PDF document, right aligned: