Linx Main Linx Help

Generate PDF Reports with Linx

A very helpful feature of any system is to be able to automatically generate reports and forward it to users, either via Emails, or on a site for download. There are a lot of technologies available for large report generation, i.e. SQL Reporting Services, Knowage, Crystal Reports etc. But they are mostly targeting large setups, and sometimes you just want a quick report without the hassle.

Although Linx, by itself cannot create PDFs, with the help of some other tools, it’s really simple.

Download the Example Solution (Linx 5.19): ReportWithRazorAndPDF.lsoz (13.3 KB)

In this example I’ve created a small Linx Solution that:

  • Uses data in a understandable structure
  • With Razor Templates, generates an HTML file
  • Which then can be converted to a PDF file using a tool called wkhtmltopdf (https://wkhtmltopdf.org/) You’ll need to download and install this to run this sample.

Data Structure:

I’ve created a Custom Type in Linx called “Report” which consists of some Report data, i.e. Report Name, Author, Date and Version. It also contains another Custom Type called “Rows”. Each “Row” is split up into “Columns” which contains a “Value”. Something like this:

Processes:

  • CleanUpData: This first process simply takes the Report Data given and makes sure that each of the Rows has the same amount of Columns. That is important because the Report Generation will fail if they are not the same.
  • FormatReport: Using Razor Templates and some really simple HTML, the Report Data is used to generate and HTML page for the report. Being HTML one can make use of CSS to give the Report really good aesthetics, or keep it simple like in this example.
  • HtmlToPDF: This process then uses the wkhtmltopdf EXE file to convert the HTML to PDF. https://wkhtmltopdf.org/downloads.html

Here’s the Razor Template. All fit into one screen:

HARDCODE WARNING - This is just an Example Solution, so I’ve Hardcoded the file paths and Report Data. You can change this in any way you need.

Example Report: Report (1).pdf (17.5 KB)

The report looks really basic, as I’ve used Standard HTML styling, but you can make it look any way you’d like.

1 Like