function entity_print_entity_to_pdf in Entity Print 7
Output an entity as a PDF.
Parameters
string $entity_type: The entity type.
int $entity_id: The entity id.
1 string reference to 'entity_print_entity_to_pdf'
- entity_print_menu in ./
entity_print.module - Implements hook_entity_print().
File
- ./
entity_print.module, line 98 - Print any entity.
Code
function entity_print_entity_to_pdf($entity_type, $entity_id) {
if ($entities = entity_load($entity_type, array(
$entity_id,
))) {
$library = libraries_load('phpwkhtmltopdf');
if (!empty($library['loaded'])) {
$pdf = new WkHtmlToPdf(array(
'binary' => variable_get('entity_print_wkhtmltopdf', '/usr/local/bin/wkhtmltopdf'),
));
$entity = reset($entities);
$html = _entity_print_get_generated_html($entity_type, $entity);
// Add a HTML file, a HTML string or a page from a URL.
$pdf
->addPage($html);
// Allow other modules to alter the generated PDF object.
drupal_alter('entity_print_pdf', $pdf, $entity_type, $entity);
if (!$pdf
->send()) {
print $pdf
->getError();
}
}
else {
print $library['error message'];
}
}
}