You are here

function tcpdf_example_simple_pdf in TCPDF 7

Generates a pdf file using TCPDF module.

Return value

string Binary string of the generated pdf.

1 call to tcpdf_example_simple_pdf()
tcpdf_example_download in tcpdf_example/tcpdf_example.pages.inc
Page callback for downloading example pdf files.

File

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

Code

function tcpdf_example_simple_pdf() {

  // Get the content we want to convert into pdf.
  $html = theme('tcpdf_example_basic_html');

  // Never make an instance of TCPDF or TCPDFDrupal classes manually.
  // Use tcpdf_get_instance() instead.
  $tcpdf = tcpdf_get_instance();

  /* DrupalInitialize() is an extra method added to TCPDFDrupal that initializes
   *  some TCPDF variables (like font types), and makes possible to change the
   *  default header or footer without creating a new class.
   */
  $tcpdf
    ->DrupalInitialize(array(
    'footer' => array(
      'html' => 'This is a test!! <em>Bottom of the page</em>',
    ),
    'header' => array(
      'callback' => array(
        'function' => 'tcpdf_example_default_header',
        // You can pass extra data to your callback.
        'context' => array(
          'welcome_message' => 'Hello, context array!',
        ),
      ),
    ),
  ));

  // Insert the content. Note that DrupalInitialize automaticly adds the first
  // page to the pdf document.
  $tcpdf
    ->writeHTML($html);
  return $tcpdf
    ->Output('', 'S');
}