This PDF Composer project has been an initiative to improve user experience and add some interactivity to the download section of some websites.
In the world of integrated reporting, delivering tailored information is the cutting edge level of what an online report could offer, the adoption of a friendly user interface was essential in this scenario to allow users compile their own custom report with available PDF documents and download it.
The interface is built with
HTML5 on Boostrap reponsive framework, some
Shell to merge the PDF documents,
Ajax were 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 an
jQuery Array, Once the “generate” button is clicked, the PDF merging takes place. The merged PDF document is stored on the server and prompted to be downloaded by the user.
With the help of
PHP session I could solve the issue of having two users merging different PDF documents at the same time, this increments a counter variable to allow us keep track of the number of generated PDF documents.
The idea of the
Shell script came to mind when I tried to find a lighter version of the famous PDF library
TCPDF, the latter is pretty powerful to generating and creating PDF documents from HTML with extensive styling possibilities, but in this case I was looking for a simple solution to merge PDF documents only without having to load all the library files that
The websites that used this application were hosted on a
Linux server hence
Shell came into play, Most Linux kernels come with
Ghostscript interpreter which offers PDF manipulation.
The following command allowed me to combine PDF documents together easily:
[php]gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName[/php]
To run the
Shell script with
PHP I simply used