Beispiel #1
0
 /**
 * Page header.
 *
 	public function Header() {
 		// Logo
 		$image_file = K_PATH_IMAGES.'logo_example.jpg';
 		$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
 		// Set font
 		$this->SetFont('helvetica', 'B', 20);
 		// Title
 		$this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
 	}
 
 	/**
 * Page footer.
 */
 public function Footer()
 {
     // Position at 15 mm from bottom
     //$this->SetY(-15);
     // Set font
     //$this->SetFont('helvetica', 'I', 8);
     $invoice_type = $this->invoice_type;
     $footer_text = apply_filters('wcj_get_option_filter', 'Page %page_number% / %total_pages%', get_option('wcj_invoicing_' . $invoice_type . '_footer_text'));
     //$this->Cell( 0, 0, do_shortcode( $footer_text ), 0, false, 'L', 0, '', 0, false, 'T', 'M' );
     $footer_text = str_replace('%page_number%', $this->getAliasNumPage(), $footer_text);
     $footer_text = str_replace('%total_pages%', $this->getAliasNbPages(), $footer_text);
     $border_desc = array('T' => array('color' => wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_line_color')), 'width' => 0));
     $footer_text_color_rgb = wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_text_color'));
     $this->SetTextColor($footer_text_color_rgb[0], $footer_text_color_rgb[1], $footer_text_color_rgb[2]);
     $this->writeHTMLCell(0, 0, '', '', do_shortcode($footer_text), $border_desc, 1, 0, true, '', true);
 }
 /**
  * prepare_pdf.
  *
  * @version 2.5.2
  */
 function prepare_pdf()
 {
     $invoice_type = $this->invoice_type;
     // Create new PDF document
     require_once wcj_plugin_path() . '/includes/classes/class-wcj-tcpdf.php';
     $pdf = new WCJ_TCPDF(get_option('wcj_invoicing_' . $invoice_type . '_page_orientation', 'P'), PDF_UNIT, get_option('wcj_invoicing_' . $invoice_type . '_page_format', 'A4'), true, 'UTF-8', false);
     $pdf->set_invoice_type($invoice_type);
     // Set document information
     $pdf->SetCreator(PDF_CREATOR);
     //		$pdf->SetAuthor( 'Algoritmika Ltd.' );
     $invoice_title = $invoice_type;
     $invoice_types = wcj_get_invoice_types();
     foreach ($invoice_types as $invoice_type_data) {
         if ($invoice_type === $invoice_type_data['id']) {
             $invoice_title = $invoice_type_data['title'];
             break;
         }
     }
     $pdf->SetTitle($invoice_title);
     $pdf->SetSubject('Invoice PDF');
     $pdf->SetKeywords('invoice, PDF');
     // Header - set default header data
     if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_header_enabled')) {
         $the_logo = '';
         $the_logo_width_mm = 0;
         if ('' != get_option('wcj_invoicing_' . $invoice_type . '_header_image')) {
             $the_logo = parse_url(get_option('wcj_invoicing_' . $invoice_type . '_header_image'), PHP_URL_PATH);
             $the_logo_width_mm = get_option('wcj_invoicing_' . $invoice_type . '_header_image_width_mm');
         }
         $pdf->SetHeaderData($the_logo, $the_logo_width_mm, do_shortcode(get_option('wcj_invoicing_' . $invoice_type . '_header_title_text')), do_shortcode(get_option('wcj_invoicing_' . $invoice_type . '_header_text')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_header_text_color')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_header_line_color')));
     } else {
         $pdf->SetPrintHeader(false);
     }
     // Footer
     if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_footer_enabled')) {
         $pdf->setFooterData(wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_text_color')), wcj_hex2rgb(get_option('wcj_invoicing_' . $invoice_type . '_footer_line_color')));
     } else {
         $pdf->SetPrintFooter(false);
     }
     // Set Header and Footer fonts
     $pdf->setHeaderFont(array(get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans'), '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans'), '', PDF_FONT_SIZE_DATA));
     // Set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // Set margins
     $pdf->SetMargins(get_option('wcj_invoicing_' . $invoice_type . '_margin_left'), get_option('wcj_invoicing_' . $invoice_type . '_margin_top'), get_option('wcj_invoicing_' . $invoice_type . '_margin_right'));
     $pdf->SetHeaderMargin(get_option('wcj_invoicing_' . $invoice_type . '_margin_header'));
     $pdf->SetFooterMargin(get_option('wcj_invoicing_' . $invoice_type . '_margin_footer'));
     // Set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, get_option('wcj_invoicing_' . $invoice_type . '_margin_bottom'));
     // Set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     /*// Set some language-dependent strings (optional)
     		if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
     			require_once(dirname(__FILE__).'/lang/eng.php');
     			$pdf->setLanguageArray($l);
     		}*/
     // Set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     /* if ( 'DroidSansFallback' === apply_filters( 'booster_get_option', 'dejavusans', get_option( 'wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans' ) ) ) {
     			$pdf->addTTFfont( wcj_plugin_path() . '/includes/lib/tcpdf_min/fonts/' . 'DroidSansFallback.ttf' );
     		} */
     // dejavusans is a UTF-8 Unicode font, if you only need to print standard ASCII chars, you can use core fonts like  helvetica or times to reduce file size.
     $pdf->SetFont(apply_filters('booster_get_option', 'dejavusans', get_option('wcj_invoicing_' . $invoice_type . '_general_font_family', 'dejavusans')), '', apply_filters('booster_get_option', 8, get_option('wcj_invoicing_' . $invoice_type . '_general_font_size', 8)), '', true);
     // Add a page
     $pdf->AddPage();
     // Set text shadow effect
     if ('yes' === get_option('wcj_invoicing_' . $invoice_type . '_general_font_shadowed', 'yes')) {
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
     }
     return $pdf;
 }