Exemplo n.º 1
0
 public function setPDFDefaults($output, $filename)
 {
     $this->pdf_defaults['generator']['output'] = $output;
     self::$pdf_filename = $filename;
     $this->SetFont('Helvetica', '', 10, '', true);
     $this->setFontSubsetting(true);
     $this->SetCreator($this->pdf_defaults['document']['author']);
     $this->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $this->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $this->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $this->SetMargins(50, 35, 35, true);
     $this->setFooterMargin(20);
     $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
     $this->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $this->setJPEGQuality(100);
 }
Exemplo n.º 2
0
 public function __construct()
 {
     /*
      * Ensure the system is fully installed		 
      * We run this after the 'settings' page has been set up (above)		 
      */
     if (GFPDF_Core_Model::is_fully_installed() === false) {
         return;
     }
     global $gfpdfe_data;
     /*
      * Set up the PDF configuration and indexer
      * Accessed through $this->configuration and $this->index.
      */
     parent::__construct();
     /*
      * Add our main hooks
      */
     add_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link'), 10, 4);
     add_action("gform_entry_info", array('GFPDF_Core_Model', 'detail_pdf_link'), 10, 2);
     add_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages'));
     /*
      * Apply default filters
      */
     add_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags'), 10, 3);
     /* convert mergetags in PDF template automatically */
     add_filter('gfpdfe_pdf_template', 'do_shortcode', 10, 1);
     /* convert shortcodes in PDF template automatically */
     /* Check if on the entries page and output javascript */
     if (is_admin() && rgget('page') == 'gf_entries') {
         wp_enqueue_script('gfpdfeentries', PDF_PLUGIN_URL . 'resources/javascript/entries-admin.min.js', array('jquery'));
     }
     /*
      * Register render class
      */
     $this->render = new PDFRender();
     /*
      * Run the notifications filter / save action hook if the web server can write to the output folder
      */
     if ($gfpdfe_data->can_write_output_dir === true) {
         add_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf'), 10, 2);
         add_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf'), 100, 3);
         /* ensure it's called later than standard so the attachment array isn't overridden */
     }
 }
 /**
  * Renders passed in content to a PDF.
  *
  * If $outputTo == '', then the temporary filename is returned, with the expectation
  * that the caller will correctly handle the streaming of the content.
  *
  * @param String $content
  * 			Raw content to render into a pdf
  * @param String $outputTo
  * 				'file' or 'browser'
  * @param String $outname
  * 				A filename if the pdf is sent direct to the browser
  * @return String
  * 				The filename of the output file
  */
 protected function render($content, $outputTo = null, $outname = '')
 {
     // Setup a temp folder for the pdfs
     $tempFolder = getTempFolder();
     if (!is_dir($tempFolder)) {
         throw new Exception("Temp directory could not be found " . var_export(getTempFolder(), true));
     }
     $pdfFolder = $tempFolder . '/' . self::$temp_folder_name;
     if (!file_exists($pdfFolder)) {
         @mkdir($pdfFolder, 0750);
     }
     if (!is_dir($pdfFolder)) {
         throw new Exception("PDF temp directory could not be found " . $pdfFolder);
     }
     // Change all the links and urls in the content to use absolute paths
     $content = $this->fixLinks($content);
     // Translate all the breaking spaces that tinymce litters everywhere
     $content = $this->fixEntities($content);
     // Create a temp pdf file ready for the pdf convertor output
     $pdfFile = tempnam($pdfFolder, "pdf_");
     // Start up the pdf generator and tell it where to write its output
     $pdfGenerator = new PDFGenerator($pdfFile);
     // Convert the content into pdf
     if (!$pdfGenerator->generatePDF($content)) {
         throw new Exception("PDF could not be created");
     }
     if (!file_exists($pdfFile)) {
         throw new Exception("Could not generate pdf " . $pdfFile);
     }
     // Return the pdf contents if the output type is anything but 'browser'
     if ($outputTo != 'browser') {
         return $pdfFile;
     }
     // Return the pdf to the browser as a file download
     if (file_exists($pdfFile)) {
         $filedata = array('path' => $pdfFile, 'name' => urlencode(htmlentities($outname)), 'mime' => "application/pdf");
         // TODO: use this instead
         //$this->send_file($filedata);
         $size = filesize($pdfFile);
         $type = "application/pdf";
         $name = urlencode(htmlentities($outname));
         if (!headers_sent()) {
             // set cache-control headers explicitly for https traffic, otherwise no-cache will be used,
             // which will break file attachments in IE
             // Thanks to Niklas Forsdahl <*****@*****.**>
             if (isset($_SERVER['HTTPS'])) {
                 header('Cache-Control: private');
                 header('Pragma: ');
             }
             header('Content-disposition: attachment; filename=' . $name);
             header('Content-type: application/pdf');
             //octet-stream');
             header('Content-Length: ' . $size);
             readfile($pdfFile);
         } else {
             echo "Invalid file";
         }
         // Delete the pdf temp file
         unlink($pdfFile);
     }
     return true;
 }
Exemplo n.º 4
0
define("FPDF_FONTPATH", "lib/fpdf/font/");
include_once 'lib/fpdf/fpdf.php';
if (isset($_POST['order_id'])) {
    $order_id = $_POST["order_id"];
    $order_type = $_POST['order_type'];
    $client_id = $_POST["client_id"];
    $o_id = $_POST['o_id'];
}
// Settings Data
$myData = new Data();
$myData->init();
$tempSettings = $myData->read_settings();
$tempClient = $myData->get_client_data($client_id);
$tempOrder = $myData->order_read_item($order_id, $order_type);
$tempPositionen = $myData->read_order_position($order_id, $o_id);
$myPDFGenerator = new PDFGenerator();
$myPDFGenerator->logo = $tempSettings[0]->owner_logo;
$myPDFGenerator->owner_firma = $tempSettings[0]->owner_firma;
$myPDFGenerator->owner_vorname = $tempSettings[0]->owner_vorname;
$myPDFGenerator->owner_nachname = $tempSettings[0]->owner_nachname;
$myPDFGenerator->owner_strasse = $tempSettings[0]->owner_strasse;
$myPDFGenerator->owner_plz = $tempSettings[0]->owner_plz . " " . $tempSettings[0]->owner_ort;
$myPDFGenerator->owner_email = $tempSettings[0]->owner_email;
$myPDFGenerator->owner_web = $tempSettings[0]->owner_web;
$myPDFGenerator->owner_tel = $tempSettings[0]->owner_telefon;
$myPDFGenerator->owner_bank = $tempSettings[0]->owner_bank_name;
$myPDFGenerator->owner_iban = $tempSettings[0]->owner_bank_iban;
$myPDFGenerator->owner_bic = $tempSettings[0]->owner_bank_bic;
$myPDFGenerator->empfaenger_firma = $tempClient[0]->firma;
$myPDFGenerator->empfaenger_nachname = $tempClient[0]->nachname;
$myPDFGenerator->empfaenger_vorname = $tempClient[0]->vorname;