I would like to theme the PDF generated through the Print module. I have created a view for displaying the fields of my choice in PDF.
Can anyone help me out on how to theme the PDF?
I would like to theme the PDF generated through the Print module. I have created a view for displaying the fields of my choice in PDF.
Can anyone help me out on how to theme the PDF?
Create your own template file:
print[--html|--mail|--pdf][--node--node-type].tpl.php
Look inside the modules directory and you will see the template files, say print.tpl.php. Copy these and modify as needed.
You should use Views PDF module
With this module you can output a view as a PDF document. Each field of the view can be placed on the PDF page directly in the administration interface. Therefore a new display called "PDF" is added.
I did the same thing recently: I had a view on my nodes page that outputs fields, including fields from a referenced node, but of course this was not included in the default PDF file output by the Print module.
What I did was:
Making a custom template as Chadpeppers explained. The filename should have a name like print[--html|--mail|--pdf][--node--node-type].tpl.php; in my case, it was print--pdf--node--job.tpl.php.
Embedding the view I needed in the template, using the current node ID as argument.
$view = views_get_view('VIEW_NAME');
$view->set_arguments(array($node->nid));
$view->execute();
I now have a view object with all the results I expected.
You could use the FillPDF module and plug your data into a pre-designed fillable PDF.
Most PDF modules generate PDFs from scratch; FillPDF is not one of those modules. Instead, it lets you fill in existing editable PDFs with data from your Drupal site. Editable PDFs are those forms that let you type into them
I agree with @Rupesh. You should use the Views PDF module. First create the view, add the fields you need, take full advantage of theming, then add a PDF display, which this module provides. This is easier than theming the print module IMO.