print_pdf_dompdf.module 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * Generate a PDF for the print_pdf module using the dompdf library.
  5. *
  6. * @ingroup print
  7. */
  8. define('PRINT_PDF_DOMPDF_UNICODE_DEFAULT', 0);
  9. define('PRINT_PDF_DOMPDF_FONT_SUBSETTING_DEFAULT', FALSE);
  10. /**
  11. * Implements hook_pdf_tool_info().
  12. */
  13. function print_pdf_dompdf_pdf_tool_info() {
  14. return array(
  15. 'name' => 'dompdf',
  16. 'url' => 'http://code.google.com/p/dompdf/downloads/list',
  17. 'expand_css' => FALSE,
  18. 'public_dirs' => array(
  19. 'fonts',
  20. ),
  21. );
  22. }
  23. /**
  24. * Implements hook_theme().
  25. */
  26. function print_pdf_dompdf_theme() {
  27. return array(
  28. 'print_pdf_dompdf_footer' => array(
  29. 'variables' => array('html' => ''),
  30. 'file' => 'print_pdf_dompdf.pages.inc',
  31. ),
  32. );
  33. }
  34. /**
  35. * Implements hook_menu().
  36. */
  37. function print_pdf_dompdf_menu() {
  38. $items = array();
  39. $items['admin/config/user-interface/print/pdf/dompdf'] = array(
  40. 'title' => 'dompdf',
  41. 'description' => 'Configure the dompdf options.',
  42. 'page callback' => 'drupal_get_form',
  43. 'page arguments' => array('print_pdf_dompdf_settings'),
  44. 'access arguments' => array('administer print'),
  45. 'type' => MENU_LOCAL_TASK,
  46. 'file' => 'print_pdf_dompdf.admin.inc',
  47. );
  48. return $items;
  49. }
  50. /**
  51. * Implements hook_pdf_tool_version().
  52. */
  53. function print_pdf_dompdf_pdf_tool_version($pdf_tool) {
  54. require_once(DRUPAL_ROOT . '/' . $pdf_tool);
  55. // Poor man's way to find dompdf version
  56. if (!defined('DOMPDF_DIR')) {
  57. return 'unknown';
  58. }
  59. elseif (!defined('DOMPDF_CHROOT')) {
  60. return '0.5.1';
  61. }
  62. elseif (!defined('DOMPDF_FONT_CACHE')) {
  63. return '0.5.2';
  64. }
  65. elseif (!defined('DOMPDF_LOG_OUTPUT_FILE')) {
  66. return '0.6.0 beta1';
  67. }
  68. elseif (!defined('DOMPDF_ADMIN_USERNAME')) {
  69. return '0.6.0 beta2';
  70. }
  71. else {
  72. return '0.6.0 beta3';
  73. }
  74. }
  75. /**
  76. * Implements hook_print_pdf_available_libs_alter().
  77. */
  78. function print_pdf_dompdf_print_pdf_available_libs_alter(&$pdf_tools) {
  79. module_load_include('inc', 'print', 'includes/print');
  80. $tools = _print_scan_libs('dompdf', '!^dompdf_config.inc.php$!');
  81. foreach ($tools as $tool) {
  82. $pdf_tools['print_pdf_dompdf|' . $tool] = 'dompdf (' . dirname($tool) . ')';
  83. }
  84. }