Monday, April 16, 2012

PDF Creation

PDF Creation:

First we need to download the DOMPDF [Html to Pdf converter] from [].Then keep that folder inside your pdf module.

function pdf_creation_menu(){
  $items['pdf_creation'] = array(
    'page callback' => 'pdf_creation',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  return $items;

function  pdf_creation () {
//You can add your own HTML or you can print your DB details as a HTML
//You can theme it by default drupal theming and pass that value to this $content
// Ex: $content = theme('create_pdf', $value);
// In this create_pdf tpl you can theme with your own styles,but you need to give the styles inside the same file itself. Like <style>your styles</style> at the top of the tpl file.

$content = '<html><body>'.
  '<p>Put your html here, or generate it with your favourite '.
  'templating system.</p>'.

  require_once("dompdf/");  //Path to identify the dompdf converter.
  $dompdf = new DOMPDF();
  $dompdf->set_paper('letter', 'portrait');



Finally give this link [pdf_creation] as your PDF downloader link.

No comments:

Post a Comment