/**
 * Allows other modules to get hold of the pdf object for making changes.
 *
 * Only use this function if you're not able to achieve the right outcome with
 * a custom template and CSS.
 *
 * @param \Drupal\entity_print\Plugin\PdfEngineInterface $pdf_engine
 *   The pdf engine plugin.
 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
 *   The entity we're rending.
 */
function hook_entity_print_pdf_alter(PdfEngineInterface $pdf_engine, ContentEntityInterface $entity)
{
    $terms = \Drupal::config('mymodule.settings')->get('terms_and_conditions');
    $pdf_engine->addPage($terms);
}
 /**
  * {@inheritdoc}
  */
 public function getEntityRenderedAsPdf(ContentEntityInterface $entity, PdfEngineInterface $pdf_engine, $force_download = FALSE, $use_default_css = TRUE)
 {
     // Force CSS optimization for the PDF.
     $html = $this->getHtml($entity, $use_default_css, TRUE);
     $pdf_engine->addPage($html);
     // Allow other modules to alter the generated PDF object.
     $this->moduleHandler->alter('entity_print_pdf', $pdf_engine, $entity);
     // If we're forcing a download we need a filename otherwise it's just sent
     // straight to the browser.
     $filename = $force_download ? $this->generateFilename($entity) : NULL;
     // Try to send the PDF otherwise return the error.
     if (!($result = $pdf_engine->send($filename))) {
         return $pdf_engine->getError();
     }
     return $result;
 }