public function EntityPrintPdfBuilder::getMultipleEntitiesRenderedAsPdf in Entity Print 8
Render any content entity as a PDF.
Parameters
array $entities: An array of content entities to render, 1 per page.
\Drupal\entity_print\Plugin\PdfEngineInterface $pdf_engine: The plugin id of the PDF engine to use.
bool $force_download: (optional) TRUE to try and force the PDF to be downloaded rather than opened.
bool $use_default_css: (optional) TRUE if you want the default CSS included, otherwise FALSE.
Return value
string FALSE or the PDF content will be sent to the browser.
Overrides PdfBuilderInterface::getMultipleEntitiesRenderedAsPdf
File
- src/
EntityPrintPdfBuilder.php, line 61
Class
Namespace
Drupal\entity_printCode
public function getMultipleEntitiesRenderedAsPdf(array $entities, PdfEngineInterface $pdf_engine, $force_download = FALSE, $use_default_css = TRUE) {
$pdf_engine
->addPage($this->rendererFactory
->create($entities)
->getHtmlMultiple($entities, $use_default_css, TRUE));
// Allow other modules to alter the generated PDF object.
$this->dispatcher
->dispatch(PdfEvents::PRE_SEND_MULTIPLE, new PreSendPdfMultipleEvent($pdf_engine, $entities));
// If we're forcing a download we need a filename otherwise it's just sent
// straight to the browser.
$filename = $force_download ? $this
->generateMultiFilename($entities) : NULL;
return $pdf_engine
->send($filename);
}