You are here

function tcpdf_example_download in TCPDF 7

Page callback for downloading example pdf files.

1 string reference to 'tcpdf_example_download'
tcpdf_example_menu in tcpdf_example/tcpdf_example.module
Implements hook_menu().

File

tcpdf_example/tcpdf_example.pages.inc, line 17
Contains page callbacks and related functions of TCPDF module.

Code

function tcpdf_example_download($example_name) {
  switch ($example_name) {
    case 'simple':
      $pdf = tcpdf_example_simple_pdf();
      break;
    default:
      return t('No such example.');
  }
  if (!$pdf) {
    return t('An error occured.');
  }

  // Tell the browser that this is not an HTML file to show, but a pdf file to
  // download.
  header('Content-Type: application/pdf');
  header('Content-Length: ' . strlen($pdf));
  header('Content-Disposition: attachment; filename="mydocument.pdf"');
  print $pdf;
  return NULL;
}