GSoC2015 Week nine and adding another PDF library
This post is about the progress which I have made while porting print module to Drupal 8 as part of GSoC 2015. Below is an excerpts about the work done in week nine while work done in week eight can be tracked over here.
This week I again re-visited PDF generating libraries. And this time I managed to add dompdf to PDF submodule. It is an HTML to PDF converter and is compliant with CSS 2.1. The library is available on GitHub over here and was easily installed via composer by adding following lines as a requirement in composer.json file of the module:
{
"require" : {
"dompdf/dompdf" : "0.6.*"
}
} </code>
The library makes use php-font-lib hence when we are installing library using composer it is recommended to set parameter DOMPDF_ENABLE_AUTOLOAD
defined in the dompdf_config.inc.php file to false
. This was done by adding following lines in the generator
define('DOMPDF_ENABLE_AUTOLOAD', false);
require_once ‘/path/to/vendor/dompdf/dompdf/dompdf_config.inc.php’; </code>
After following the above procedure I was finally able to generate PDF for my node’s content. It is one of the problem of this library that it does not supports rendering of SVG images but the themes logo which are present in Drupal 8 are of SVG type hence they are not able to render themselves in the PDF. I am still searching a solution for this but currently it seems that the user who wants to have a logo in the PDF will have to themself convert SVG to any other compatible formats like png or GIF. The dompdf generator still lacks function for generating header and footer which I will be adding in coming week.
In this week I was able to add some more unit tests in the module mainly related to testing of configuration of tabs and block generation. The tests can be browsed over here. Next week after completing the dompdf generator I will be taking care of some of the loose ends present in the code and then will be adding some more functional tests.
Some progress of PDF part of module can be viewed over here and remaining over here.