You are here

function hook_pdf_export_renderers in Views Data Export PDF 7

Same name and namespace in other branches
  1. 7.2 views_data_export_pdf.api.php \hook_pdf_export_renderers()

Defines PDF renderers for converting HTML to PDF.

This hook allows modules to register additional PDF renderers that can be used when performing an export.

Return value

array[] An array of renderers. Each renderer has a key corresponding to a unique machine name that is used elsewhere in the VDE PDF UI to identify the renderer; it must be unique across all modules the define renderers. The corresponding array value is an associative array that may contain the following key-value pairs:

  • "title": Required. The translated, human-friendly name of the renderer.
  • "description": The translated description of the renderer.
  • "class": Required. The fully-qualified name of the renderer class to instantiate.
  • "file": A file that will be included before the renderer is instantiated. The file should be relative to the implementing module's directory unless otherwise specified by the "file path" option.
  • "file path": The path to the directory containing the file specified in "file". This defaults to the path to the module implementing the hook.
  • "constructor arguments": An array containing the arguments to pass to the renderer class upon instantiation.
3 functions implement hook_pdf_export_renderers()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

vde_pdf_mpdf_pdf_export_renderers in modules/vde_pdf_mpdf/vde_pdf_mpdf.module
Implements hook_pdf_export_renderers().
vde_pdf_wkhtmltopdf_mpdf_pdf_export_renderers in modules/vde_pdf_wkhtmltopdf_mpdf/vde_pdf_wkhtmltopdf_mpdf.module
Implements hook_pdf_export_renderers().
vde_pdf_wkhtmltopdf_pdf_export_renderers in modules/vde_pdf_wkhtmltopdf/vde_pdf_wkhtmltopdf.module
Implements hook_pdf_export_renderers().
1 invocation of hook_pdf_export_renderers()
views_data_export_pdf_get_renderer_types in ./views_data_export_pdf.module
Gets all of the renderers defined on this site.

File

./views_data_export_pdf.api.php, line 39
API documentation for Views Data Export PDF.

Code

function hook_pdf_export_renderers() {
  $renderers = [];
  $renderers['wkhtmltopdf_in_proc'] = [
    'title' => t('wkhtmltopdf (In-process, blocking)'),
    'description' => t('Invokes <code>wkhtmltopdf</code> within the request and blocks further processing of that request until the PDF has been generated.'),
    'class' => 'views_data_export_pdf_wkhtmltopdf_in_proc_renderer',
    'file' => 'src/views_data_export_pdf_wkhtmltopdf_in_proc_renderer.inc',
  ];
  if (module_exists('vde_pdf_background_process')) {

    // This renderer wraps the in-proc renderer in a background process renderer
    $renderers['wkhtmltopdf_background_process'] = [
      'title' => t('wkhtmltopdf (Background process, async)'),
      'description' => t('During batched exports, invokes <code>wkhtmltopdf</code> in an asynchronous background process to avoid load balancer timeouts on large data sets.'),
      'class' => 'views_data_export_pdf_background_process_renderer',
      'file' => 'src/views_data_export_pdf_background_process_renderer.inc',
      'file path' => drupal_get_path('module', 'vde_pdf_background_process'),
      'constructor arguments' => [
        'vde_pdf_wkhtmltopdf',
        'views_data_export_pdf_wkhtmltopdf_in_proc_renderer',
      ],
    ];
  }
  return $renderers;
}