API for PDF Generation

0 Shares

Recently I had the opportunity to work on a cool project for Performance Associates, a company who constructs character tests for companies and schools. The project requirement was a third party would send me data and I would need to place it into a PDF, specifically designed for multiple clients.

html-pdfI used Symfony2 to create an API that would take the content, insert it into an HTML template, build the graphs and values with JavaScript and then export and email the PDF to the client’s email, which was specified in the content that was received.

The content received comes in as JSON, making it easy to use on the front and backend.

{
"key": "value", "skills": {
"skill1": "value1"
}
}

The application ingests this and populates a Twig template, which is the way a frontend developer can receive PHP variables from the backend.


<dl class="col-xs-11 col-xs-offset-1">
<dt class="col-xs-3"<Skill:</dt>l;
<dd class="col-xs-4">{{ model.skill }}</dd>
<dt class="col-xs-3">Skill Group:</dt>
<dd class="col-xs-2">{{ model.group }} <!-- etc -->

On the backend FOSRestBundle is used to ingest the JSON.

The PDF conversion then happens with KnpSnappyBundle, which is a nice little Sf wrapper for wkhtmltopdf.advised dosage by doctors healthy people, and 5mg of seniors and malnourished patients, together with those with liver failure. The tablet is recommended to be taken http://www.theirishmanwhiskey.com/tour/ right before going to bed.

0 Shares