In the annual integrated reporting realm, here in South Africa, Producing well designed and readable PDFs, is vital.
Stakeholders and analysts are accustomed to reviewing financial data on PDF format despite the emerging of online reporting.
Usually, the entire integrated report is compiled into one downloadable single PDF, which is not optimal to consume by users from different trades.
The aim was to make this experience easier, allowing users to be able to compile their own reports from granular PDF files.
Build a tool to be included on online annual report websites, that allows users to compile their own custom integrated reports from small PDF files.
My role consisted of the following:
Once the publishing of the full integrated report is complete and signed off by the client, publishers split it into several PDF files, based on sections.
These PDF files are used in combination with the PDF Composer tool, which resides on the download page on the website.
Instead of downloading the entire integrated report PDF file, it is now possible for the user to compose a custom PDF report based on a specific PDF selection.
The selected PDF files are merged into one single PDF, that is downloaded by the user.
The tool's wireframe and structure had to be consistent on all websites that feature it, regardless of the look and feel of the website, this will guarantee good usability on all mediums.
The UI consists of 2 blocks, the left block will list all PDFs of the reports while the right block is empty, signifying the empty "custom report".
When the user selects PDFs on the left block, they are moved to the custom report block on the right.
The interface is built with HTML5 on Boostrap responsive framework, PHP and Shell to merge the PDF documents, jQuery/Ajax was used for the manipulation of the DOM.
The application allows the user to select PDF documents from the left-hand side with a click, the selected documents appear on the right-hand side and added into a jQuery Array.
Once the “Create my report” button is clicked, the selected PDF documents merge together; the merged PDF document is stored on the server and prompted to be downloaded by the user.
I used PHP session to solve the issue of having two users merging different PDF documents at the same time, this increments a counter variable to allow keeping track of the number of generated PDF documents.
For PDF handling and merging, the first thing that came to mind was TCPDF PHP library, it is quite powerful for this matter, yet, slightly over-kill and I had to find a more elegant way to merge the selected PDF.
All our websites and online reports were hosted on a LAMP stack, Most Linux kernels come with Ghostscript interpreter which offers PDF manipulation, therefore the use of a Shell script was definitely a plausible option.
The following command allowed me to combine PDF documents together easily:
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName
To run the Shell script with PHP I simply used: