Example #1
44
 public function testPdfOutput()
 {
     $this->markTestIncomplete('Transparency rendering on signature not working.');
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 052');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 052', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     /*
     NOTES:
      - To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
      - To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12
      - To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes
     */
     // set certificate file
     $certificate = 'file://tests/data/cert/tcpdf.crt';
     // set additional information
     $info = array('Name' => 'TCPDF', 'Location' => 'Office', 'Reason' => 'Testing TCPDF', 'ContactInfo' => 'http://www.tcpdf.org');
     // set document signature
     $pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info);
     // set font
     $pdf->SetFont('helvetica', '', 12);
     // add a page
     $pdf->AddPage();
     // print a line of text
     $text = 'This is a <b color="#FF0000">digitally signed document</b> using the default (example) <b>tcpdf.crt</b> certificate.<br />To validate this signature you have to load the <b color="#006600">tcpdf.fdf</b> on the Arobat Reader to add the certificate to <i>List of Trusted Identities</i>.<br /><br />For more information check the source code of this example and the source code documentation for the <i>setSignature()</i> method.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>';
     $pdf->writeHTML($text, true, 0, true, 0);
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     // *** set signature appearance ***
     // create content for signature (image and/or text)
     $pdf->Image('tests/images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG');
     // define active area for signature appearance
     $pdf->setSignatureAppearance(180, 60, 15, 15);
     // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     // *** set an empty signature appearance ***
     $pdf->addEmptySignatureAppearance(180, 80, 15, 15);
     $this->comparePdfs($pdf);
 }
Example #2
18
    public function testPdfOutput()
    {
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 001');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // set some language-dependent strings (optional)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        // 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('dejavusans', '', 14, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage();
        // set text shadow effect
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        // Set some content to print
        $html = <<<EOD
<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a>!</h1>
<i>This is the first example of TCPDF library.</i>
<p>This text is printed using the <i>writeHTMLCell()</i> method but you can also use: <i>Multicell(), writeHTML(), Write(), Cell() and Text()</i>.</p>
<p>Please check the source code documentation and other examples for further information.</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        $this->comparePdfs($pdf);
    }
Example #3
14
 function convertHtmlToPdf($html)
 {
     if (!$html) {
         throw new \Exception("Html Not Given");
     }
     $pagelayout = array($this->options['width'], $this->options['height']);
     //  or array($width,$height)
     $pdf = new \TCPDF('l', 'px', $pagelayout, true, 'UTF-8', false);
     $pdf->SetMargins(0, 0, 0);
     $pdf->SetHeaderMargin(0);
     $pdf->SetFooterMargin(0);
     // $pdf = new \TCPDF_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetAutoPageBreak(false);
     if ($this->options['header_font_family']) {
         $pdf->SetFont($this->options['header_font_family']);
     }
     // add a page
     $pdf->AddPage();
     $pdf->WriteHTML($html, true, false, true, false);
     $this->pdf = $pdf->Output(null, 'S');
     //for test
     // $this->pdf = $pdf->Output(null);
     // echo $this->pdf;
     // exit;
 }
Example #4
11
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 017');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 017', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', '', 20);
     // add a page
     $pdf->AddPage();
     $pdf->Write(0, 'Example of independent Multicell() columns', '', 0, 'L', true, 0, false, false, 0);
     $pdf->Ln(5);
     $pdf->SetFont('times', '', 12);
     // create columns content
     // create columns content
     $left_column = '[LEFT COLUMN] left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column left column' . "\n";
     $right_column = '[RIGHT COLUMN] right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column right column' . "\n";
     // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
     // set color for background
     $pdf->SetFillColor(255, 255, 200);
     // set color for text
     $pdf->SetTextColor(0, 63, 127);
     // write the first column
     $pdf->MultiCell(80, 0, $left_column, 1, 'J', 1, 0, '', '', true, 0, false, true, 0);
     // set color for background
     $pdf->SetFillColor(215, 235, 255);
     // set color for text
     $pdf->SetTextColor(127, 31, 0);
     // write the second column
     $pdf->MultiCell(80, 0, $right_column, 1, 'J', 1, 1, '', '', true, 0, false, true, 0);
     // reset pointer to the last page
     $pdf->lastPage();
     $this->comparePdfs($pdf);
 }
Example #5
1
 function createPdfFromImage($arrImagename, $strFilename)
 {
     $this->load->library('tcpdf/TCPDF');
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
         require_once dirname(__FILE__) . '/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // -------------------------------------------------------------------
     $pdf->AddPage();
     $pdf->setJPEGQuality(75);
     $imgdata = base64_decode('iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==');
     $pdf->Image('@' . $imgdata);
     $intY = 25;
     foreach ($arrImagename as $intkey => $oneImage) {
         if ($intkey % 2 == 0 && $intkey != 0) {
             $intY = 25;
             $pdf->AddPage();
         }
         $pdf->Image($oneImage, 10, $intY, 180, 103, 'png', '', 'C', true, 150, '', false, false, 1, false, false, false);
         $intY += 125;
     }
     $pdf->Output($strFilename . '.pdf', 'I');
 }
/**
 * Creates an example PDF TEST document using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract TCPDF - Example: Default Header and Footer
 * @author Nicola Asuni
 * @since 2008-03-04
 */
function citation_exporter_create_pdf($html_input, $output_filename)
{
    module_load_include('php', 'citation_exporter', '/lib/tcpdf/config/lang/eng');
    module_load_include('php', 'citation_exporter', '/lib/tcpdf/tcpdf');
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    // set document information
    //$pdf->SetCreator(PDF_CREATOR);
    //$pdf->SetAuthor('Nicola Asuni');
    //$pdf->SetTitle('Exported Citations');
    //$pdf->SetSubject('Citations');
    //$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    // set default header data
    //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 001', PDF_HEADER_STRING);
    // set header and footer fonts
    //$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    //$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    //set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    // ---------------------------------------------------------
    // set default font subsetting mode
    $pdf->setFontSubsetting(true);
    // Set font
    // 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('dejavusans', '', 14, '', true);
    // Add a page
    // This method has several options, check the source code documentation for more information.
    $pdf->AddPage();
    // Print text using writeHTMLCell()
    $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html_input, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
    // ---------------------------------------------------------
    // Close and output PDF document
    // This method has several options, check the source code documentation for more information.
    $pdf->Output($output_filename, 'F');
    //============================================================+
    // END OF FILE
    //============================================================+
}
 /**
  * Method creates a PDF in landscape mode, using ilPDFGeneration Job
  * Rest of method similar to superclass method
  *
  * @param ilPDFGenerationJob $job
  */
 public static function generatePDF(ilPDFGenerationJob $job)
 {
     // create new PDF document
     // 'L' for Landscape
     $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator($job->getCreator());
     $pdf->SetAuthor($job->getAuthor());
     $pdf->SetTitle($job->getTitle());
     $pdf->SetSubject($job->getSubject());
     $pdf->SetKeywords($job->getKeywords());
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins($job->getMarginLeft(), $job->getMarginTop(), $job->getMarginRight());
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->SetAutoPageBreak($job->getAutoPageBreak(), $job->getMarginBottom());
     $pdf->setImageScale($job->getImageScale());
     $pdf->SetFont('dejavusans', '', 10);
     foreach ($job->getPages() as $page) {
         $pdf->AddPage();
         $pdf->writeHTML($page, true, false, true, false, '');
     }
     $result = $pdf->Output($job->getFilename(), $job->getOutputMode());
     // (I - Inline, D - Download, F - File)
 }
Example #8
0
 public function __construct($orientation = 'P', $format = "Letter", $color = 'gray')
 {
     parent::__construct($orientation, "pt", $format);
     self::$document_orientation = $orientation;
     self::$document_format = $format;
     $margins = parent::getMargins();
     $this->document_width = parent::getPageWidth() - $margins['left'] - $margins['right'];
     $this->last_width = $margins['left'];
     $this->last_height = $margins['top'];
     $this->document_color = $color;
     if ($color == 'red') {
         parent::SetDrawColorArray(array(255, 128, 128));
     } elseif ($color == 'green') {
         parent::SetDrawColorArray(array(128, 255, 128));
     } elseif ($color == 'blue') {
         parent::SetDrawColorArray(array(128, 128, 255));
     } else {
         parent::SetDrawColorArray(array(128, 128, 128));
     }
     parent::SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     parent::SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
     parent::setImageScale(PDF_IMAGE_SCALE_RATIO);
     parent::SetHeaderMargin(PDF_MARGIN_HEADER);
     parent::SetFooterMargin(PDF_MARGIN_FOOTER + 10);
 }
function create_pdf($content, $title)
{
    tcpdf();
    $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $obj_pdf->SetCreator(PDF_CREATOR);
    $title = $title;
    $obj_pdf->SetTitle('MultiTV analytics');
    $obj_pdf->SetAuthor('MultiTv');
    $obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING);
    $obj_pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $obj_pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    $obj_pdf->SetDefaultMonospacedFont('helvetica');
    $obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $obj_pdf->SetFont('helvetica', '', 9);
    $obj_pdf->setFontSubsetting(false);
    $obj_pdf->AddPage();
    //ob_start();
    // we can have any view part here like HTML, PHP etc
    //$content = ob_get_contents();
    ob_end_clean();
    $obj_pdf->writeHTML($content, true, false, true, false, '');
    $obj_pdf->Output('output.pdf', 'I');
}
Example #10
0
 function display($tpl = null)
 {
     global $mainframe;
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $this->assignRef('params', $params);
     $user = JFactory::getUser();
     $username = $user->username;
     $this->child = JFactory::getUser($username);
     $layout = $params->get('layout');
     $this->tasks = JoomdleHelperContent::call_method("get_children_grade_user_report", $username);
     $tpl = "catspdf";
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->_prepareDocument();
     $htmlcontent = parent::loadTemplate($tpl);
     require_once JPATH_SITE . '/libraries/tcpdf/tcpdf.php';
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $header = JText::_('COM_JOOMDLE_GRADES');
     $pdf->SetHeaderData('', 0, $header);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFontSubsetting(false);
     $pdf->SetFont('times', '', 8);
     // add a page
     $pdf->AddPage("L");
     // output the HTML content
     $pdf->writeHTML($htmlcontent, true, 0, true, 0);
     $pdf->Output("grades.pdf", 'D');
     exit;
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $loggedInUserId = $session->get('user/id');
     $pageId = $request->get('id');
     $page = $this->getRepository(Entity::class)->getById($pageId, $loggedInUserId);
     // create new PDF document
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->setPrintHeader(false);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('dejavusans', '', 10);
     // add a page
     $pdf->AddPage();
     $html = $page['content'];
     $pdf->writeHTML($html, true, false, true, false, '');
     // Close and output PDF document
     $pdf->Output('./../../' . $page['name'] . '.pdf', 'D');
 }
Example #12
0
    public static function new_pdf($orientation='P',$unit='mm',$format=null) {
        ini_set('memory_limit', '512M');
        require_once(TCPDF_DIR.'tcpdf.php');
        
        if ($format===null) $format = Base_User_SettingsCommon::get('Libs/TCPDF','page_format');

        $tcpdf = new TCPDF($orientation, $unit, $format, true);

        $tcpdf->SetCreator(PDF_CREATOR);
        $tcpdf->SetAuthor("Powered by epesi");
        $tcpdf->SetKeywords("PDF");

        // set header and footer fonts
        $tcpdf->setHeaderFont(Array(self::$default_font, '', PDF_FONT_SIZE_MAIN));
        $tcpdf->setFooterFont(Array(self::$default_font, '', PDF_FONT_SIZE_DATA));

        //set margins
        $tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);

        //set auto page breaks
        $tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

        //set image scale factor
        $tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

        return $tcpdf;
    }
Example #13
0
 private function initTcpdfObject()
 {
     $tcpdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     if ($this->creator) {
         $tcpdf->SetCreator($this->creator);
     }
     if ($this->author) {
         $tcpdf->SetAuthor($this->author);
     }
     if ($this->title) {
         $tcpdf->SetTitle($this->title);
     }
     if ($this->subject) {
         $tcpdf->SetSubject($this->subject);
     }
     if (!empty($this->keywords)) {
         $tcpdf->SetKeywords(implode(', ', $this->keywords));
     }
     // set default header data
     //$tcpdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
     // document defaults
     $tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $tcpdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
     $tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     return $tcpdf;
 }
Example #14
0
 /**
  * @param string $html 要转为pdf的内容
  * @param string $filename 文件名
  * @param string $type 'I'在页面中显示;'D'直接下载
  */
 public static function pdf($html, $filename = 'hzd.pdf', $type = 'I')
 {
     import("Tools.TCPDF.TCPDF");
     import("Tools.TCPDF.config.tcpdf_config.php");
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('HZD');
     $pdf->SetTitle('HZD');
     $pdf->SetSubject('HZD');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $pdf->setPrintHeader(false);
     //不显示头部
     $pdf->setPrintFooter(false);
     //不显示底部
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('stsongstdlight', '', 20);
     // add a page
     $pdf->AddPage();
     // output the HTML content
     $pdf->writeHTML($html, true, false, true, false, '');
     // ---------------------------------------------------------
     //Close and output PDF document
     $pdf->Output($filename, $type);
 }
Example #15
0
    public function testPdfOutput()
    {
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 023');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 023', PDF_HEADER_STRING);
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // set some language-dependent strings (optional)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set font
        $pdf->SetFont('times', 'BI', 14);
        // Start First Page Group
        $pdf->startPageGroup();
        // add a page
        $pdf->AddPage();
        // set some text to print
        $txt = <<<EOD
Example of page groups.
Check the page numbers on the page footer.

This is the first page of group 1.
EOD;
        // print a block of text using Write()
        $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
        // add second page
        $pdf->AddPage();
        $pdf->Cell(0, 10, 'This is the second page of group 1', 0, 1, 'L');
        // Start Second Page Group
        $pdf->startPageGroup();
        // add some pages
        $pdf->AddPage();
        $pdf->Cell(0, 10, 'This is the first page of group 2', 0, 1, 'L');
        $pdf->AddPage();
        $pdf->Cell(0, 10, 'This is the second page of group 2', 0, 1, 'L');
        $pdf->AddPage();
        $pdf->Cell(0, 10, 'This is the third page of group 2', 0, 1, 'L');
        $pdf->AddPage();
        $pdf->Cell(0, 10, 'This is the fourth page of group 2', 0, 1, 'L');
        $this->comparePdfs($pdf);
    }
Example #16
0
    public function testPdfOutput()
    {
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 047');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 047', PDF_HEADER_STRING);
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // set some language-dependent strings (optional)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set font
        $pdf->SetFont('helvetica', '', 16);
        // add a page
        $pdf->AddPage();
        $txt = 'Example of Transactions.
TCPDF allows you to undo some operations using the Transactions.
Check the source code for further information.';
        $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
        $pdf->Ln(5);
        $pdf->SetFont('times', '', 12);
        // start transaction
        $pdf->startTransaction();
        $pdf->Write(0, "LINE 1\n");
        $pdf->Write(0, "LINE 2\n");
        // restarts transaction
        $pdf->startTransaction();
        $pdf->Write(0, "LINE 3\n");
        $pdf->Write(0, "LINE 4\n");
        // rolls back to the last (re)start
        $pdf = $pdf->rollbackTransaction();
        $pdf->Write(0, "LINE 5\n");
        $pdf->Write(0, "LINE 6\n");
        // start transaction
        $pdf->startTransaction();
        $pdf->Write(0, "LINE 7\n");
        // commit transaction (actually just frees memory)
        $pdf->commitTransaction();
        $this->comparePdfs($pdf);
    }
Example #17
0
    public function testPdfOutput()
    {
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 053');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 053', PDF_HEADER_STRING);
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // set some language-dependent strings (optional)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set font
        $pdf->SetFont('times', '', 14);
        // add a page
        $pdf->AddPage();
        // print a some of text
        $text = 'This is an example of <strong>JavaScript</strong> usage on PDF documents.<br /><br />For more information check the source code of this example, the source code documentation for the <i>IncludeJS()</i> method and the <i>JavaScript for Acrobat API Reference</i> guide.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>';
        $pdf->writeHTML($text, true, 0, true, 0);
        // write some JavaScript code
        $js = <<<EOD
app.alert('JavaScript Popup Example', 3, 0, 'Welcome');
var cResponse = app.response({
    cQuestion: 'How are you today?',
    cTitle: 'Your Health Status',
    cDefault: 'Fine',
    cLabel: 'Response:'
});
if (cResponse == null) {
    app.alert('Thanks for trying anyway.', 3, 0, 'Result');
} else {
    app.alert('You responded, "'+cResponse+'", to the health question.', 3, 0, 'Result');
}
EOD;
        // force print dialog
        $js .= 'print(true);';
        // set javascript
        $pdf->IncludeJS($js);
        // ---------------------------------------------------------
        $this->comparePdfs($pdf);
    }
Example #18
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $this->assignRef('params', $params);
     $this->course_id = $params->get('course_id');
     if (!$this->course_id) {
         $this->course_id = JRequest::getVar('course_id');
     }
     $this->course_id = (int) $this->course_id;
     // Only for logged users
     $user = JFactory::getUser();
     $username = $user->username;
     if (!$username) {
         return;
     }
     if (!$this->course_id) {
         echo JText::_('COM_JOOMDLE_NO_COURSE_SELECTED');
         return;
     }
     $this->course_info = JoomdleHelperContent::getCourseInfo($this->course_id, $username);
     // user not enroled
     if (!$this->course_info['enroled']) {
         return;
     }
     $document = JFactory::getDocument();
     $document->setTitle($this->course_info['fullname'] . ': ' . JText::_('COM_JOOMDLE_GRADES'));
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     //  $this->gcats = JoomdleHelperContent::call_method ("get_course_grades_by_category", $this->course_id, $username);
     $this->gcats = JoomdleHelperContent::call_method("get_grade_user_report", $this->course_id, $username);
     $tpl = "catspdf";
     $this->_prepareDocument();
     $htmlcontent = parent::loadTemplate($tpl);
     require_once JPATH_SITE . '/libraries/tcpdf/tcpdf.php';
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $header = $this->course_info['fullname'];
     $header2 = JText::_('COM_JOOMDLEGRADES_TEACHER') . ': ' . $user->name;
     $header2 .= ' ' . JText::_('COM_JOOMDLEGRADES_DATE') . ': ' . date('d-m-Y');
     //	$pdf->SetHeaderData('', 0, $header, $header2);
     $pdf->SetHeaderData('', 0, $header);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFontSubsetting(false);
     $pdf->SetFont('times', '', 8);
     // add a page
     $pdf->AddPage("L");
     // output the HTML content
     $pdf->writeHTML($htmlcontent, true, 0, true, 0);
     $pdf->Output("grades.pdf", 'D');
     exit;
     //parent::display($tpl);
 }
function prepareStockStatusReport($conn)
{
    $lan = $_POST['lan'];
    if ($lan == 'en-GB') {
        $MonthList = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
    } else {
        $MonthList = array('1' => 'Janvier', '2' => 'F�vrier', '3' => 'Mars', '4' => 'Avril', '5' => 'Mai', '6' => 'Juin', '7' => 'Juillet', '8' => 'Ao�t', '9' => 'Septembre', '10' => 'Octobre', '11' => 'Novembre', '12' => 'D�cembre');
    }
    require_once 'tcpdf/tcpdf.php';
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->SetFont('dejavusans', '', 12);
    $pdf->AddPage();
    ini_set('magic_quotes_gpc', 'off');
    $html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
    $html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
    $alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
    $alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/stock_status.svg';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $file = fopen($filePath, "w");
    fwrite($file, $html);
    fclose($file);
    $pdf->ImageSVG($file = 'pdfslice/stock_status.svg', $x = 8, $y = 20, $w = 180, $h = '', $link = '', $align = 'left', $palign = 'center', $border = 0, $fitonpage = false);
    $html2 = <<<EOF
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
    </style>
    <body>
        <div id="barchartlegend">
            {$alavel}
        </div>
    </body>
EOF;
    echo $html2;
    $pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 0, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'C', $autopadding = true);
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/StockStatusChart.pdf';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $pdf->Output('pdfslice/StockStatusChart.pdf', 'F');
}
Example #20
0
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 035');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 035', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('times', 'BI', 16);
     // add a page
     $pdf->AddPage();
     $pdf->Write(0, 'Example of SetLineStyle() method', '', 0, 'L', true, 0, false, false, 0);
     $pdf->Ln();
     $pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 4, 'color' => array(255, 0, 0)));
     $pdf->SetFillColor(255, 255, 128);
     $pdf->SetTextColor(0, 0, 128);
     $text = "DUMMY";
     $pdf->Cell(0, 0, $text, 1, 1, 'L', 1, 0);
     $pdf->Ln();
     $pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 255)));
     $pdf->SetFillColor(255, 255, 0);
     $pdf->SetTextColor(0, 0, 255);
     $pdf->MultiCell(60, 4, $text, 1, 'C', 1, 0);
     $pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 255, 0)));
     $pdf->SetFillColor(0, 0, 255);
     $pdf->SetTextColor(255, 255, 0);
     $pdf->MultiCell(60, 4, $text, 'TB', 'C', 1, 0);
     $pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 255)));
     $pdf->SetFillColor(0, 255, 0);
     $pdf->SetTextColor(255, 0, 255);
     $pdf->MultiCell(60, 4, $text, 1, 'C', 1, 1);
     $this->comparePdfs($pdf);
 }
Example #21
0
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 029');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 029', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set array for viewer preferences
     $preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2);
     // Check the example n. 60 for advanced page settings
     // set pdf viewer preferences
     $pdf->setViewerPreferences($preferences);
     // set font
     $pdf->SetFont('times', '', 14);
     // add a page
     $pdf->AddPage();
     // print a line
     $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 1', 1, 1, 'C');
     $pdf->Ln(5);
     $pdf->Write(0, 'You can use the setViewerPreferences() method to change viewer preferences.', '', 0, 'L', true, 0, false, false, 0);
     // add a page
     $pdf->AddPage();
     // print a line
     $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 2', 0, 0, 'C');
     // add a page
     $pdf->AddPage();
     // print a line
     $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 3', 0, 0, 'C');
     $this->comparePdfs($pdf);
 }
function prepareFundingStatusReport($conn)
{
    require_once 'tcpdf/tcpdf.php';
    //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf = new TCPDF('L', PDF_UNIT, 'Letter', true, 'UTF-8', false);
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
        require_once dirname(__FILE__) . '/lang/eng.php';
        $pdf->setLanguageArray($l);
    }
    $pdf->SetFont('dejavusans', '', 7);
    $pdf->AddPage($orientation = L, $format = 'Letter', $keepmargins = true, $tocpage = false);
    ini_set('magic_quotes_gpc', 'off');
    $html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
    $html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
    $alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
    $alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/funding_status.svg';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $file = fopen($filePath, "w");
    fwrite($file, $html);
    fclose($file);
    $pdf->ImageSVG($file = 'pdfslice/funding_status.svg', $x = 3, $y = 20, $w = 1291, $h = 400, $link = '', $align = '', $palign = 'center', $border = 0, $fitonpage = false);
    $html2 = <<<EOF
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
    </style>
    <body>
        <div id="barchartlegend">
            {$alavel}
        </div>
    </body>
EOF;
    echo $html2;
    $pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 130, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'middle', $autopadding = true);
    $filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/FundingStatusChart.pdf';
    if (file_exists($filePath)) {
        unlink($filePath);
    }
    $pdf->Output('pdfslice/FundingStatusChart.pdf', 'F');
}
Example #23
0
 public function testPdfOutput()
 {
     $this->markTestIncomplete('Travis failure needs further investigation. ');
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 042');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 042', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set JPEG quality
     //$pdf->setJPEGQuality(75);
     $pdf->SetFont('helvetica', '', 18);
     // add a page
     $pdf->AddPage();
     // create background text
     $background_text = str_repeat('TCPDF test PNG Alpha Channel ', 50);
     $pdf->MultiCell(0, 5, $background_text, 0, 'J', 0, 2, '', '', true, 0, false);
     // --- Method (A) ------------------------------------------
     // the Image() method recognizes the alpha channel embedded on the image:
     $pdf->SetAlpha(0.71);
     $pdf->Image('tests/images/image_with_alpha.png', 50, 50, 100, '', '', 'http://www.tcpdf.org', '', false, 300);
     $pdf->SetAlpha(1);
     // --- Method (B) ------------------------------------------
     // provide image + separate 8-bit mask
     // first embed mask image (w, h, x and y will be ignored, the image will be scaled to the target image's size)
     $mask = $pdf->Image('tests/images/alpha.png', 50, 140, 100, '', '', '', '', false, 300, '', true);
     // embed image, masked with previously embedded mask
     $pdf->Image('tests/images/img.png', 50, 140, 100, '', '', 'http://www.tcpdf.org', '', false, 300, '', false, $mask);
     $this->comparePdfs($pdf);
 }
Example #24
0
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 031');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 031', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', 'B', 20);
     // add a page
     $pdf->AddPage();
     $pdf->Write(0, 'Example of PieSector() method.');
     $xc = 105;
     $yc = 100;
     $r = 50;
     $pdf->SetFillColor(0, 0, 255);
     $pdf->PieSector($xc, $yc, $r, 20, 120, 'FD', false, 0, 2);
     $pdf->SetFillColor(0, 255, 0);
     $pdf->PieSector($xc, $yc, $r, 120, 250, 'FD', false, 0, 2);
     $pdf->SetFillColor(255, 0, 0);
     $pdf->PieSector($xc, $yc, $r, 250, 20, 'FD', false, 0, 2);
     // write labels
     $pdf->SetTextColor(255, 255, 255);
     $pdf->Text(105, 65, 'BLUE');
     $pdf->Text(60, 95, 'GREEN');
     $pdf->Text(120, 115, 'RED');
     $this->comparePdfs($pdf);
 }
Example #25
0
    public function testPdfOutput()
    {
        $this->markTestIncomplete('Repository excludes pdfahelvetica font.');
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false, true);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Nicola Asuni');
        $pdf->SetTitle('TCPDF Example 065');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
        // set default header data
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 065', PDF_HEADER_STRING);
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // set some language-dependent strings (optional)
        $pdf->setLanguageArray($this->langSettings);
        // ---------------------------------------------------------
        // set default font subsetting mode
        $pdf->setFontSubsetting(true);
        // Set font
        $pdf->SetFont('helvetica', '', 14, '', true);
        // Add a page
        // This method has several options, check the source code documentation for more information.
        $pdf->AddPage();
        // Set some content to print
        $html = <<<EOD
<h1>Example of <a href="http://www.tcpdf.org" style="text-decoration:none;background-color:#CC0000;color:black;">&nbsp;<span style="color:black;">TC</span><span style="color:white;">PDF</span>&nbsp;</a> document in <span style="background-color:#99ccff;color:black;"> PDF/A-1b </span> mode.</h1>
<i>This document conforms to the standard <b>PDF/A-1b (ISO 19005-1:2005)</b>.</i>
<p>Please check the source code documentation and other examples for further information (<a href="http://www.tcpdf.org">http://www.tcpdf.org</a>).</p>
<p style="color:#CC0000;">TO IMPROVE AND EXPAND TCPDF I NEED YOUR SUPPORT, PLEASE <a href="http://sourceforge.net/donate/index.php?group_id=128076">MAKE A DONATION!</a></p>
EOD;
        // Print text using writeHTMLCell()
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        // ---------------------------------------------------------
        $this->comparePdfs($pdf);
    }
 public function exporttopdf($title, $filename, $html)
 {
     Yii::import('application.extensions.tcpdf.*');
     require_once 'tcpdf/tcpdf.php';
     require_once 'tcpdf/config/lang/eng.php';
     ob_clean();
     $pdf = new TCPDF();
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(Yii::app()->name);
     $pdf->SetTitle($title);
     $pdf->SetSubject($title);
     $pdf->SetKeywords('example, text, report');
     $pdf->SetHeaderData('', 0, "Student Report", '');
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Example Report by ".Yii::app()->name, "");
     $pdf->setHeaderFont(array('helvetica', '', 8));
     $pdf->setFooterFont(array('helvetica', '', 6));
     $pdf->SetMargins(15, 18, 15);
     $pdf->SetHeaderMargin(5);
     $pdf->SetFooterMargin(10);
     $pdf->SetAutoPageBreak(TRUE, 15);
     $pdf->SetFont('dejavusans', '', 7);
     $resolution = array(150, 150);
     $pdf->AddPage('P', $resolution);
     $pdf->writeHTML($html, true, false, true, false, '');
     $pdf->LastPage();
     $pdf->Output($filename, "I");
 }
Example #27
-1
 function Generate_Content()
 {
     $pdf = new TCPDF();
     //kods ņemts no
     // http://www.tecnick.com/pagefiles/tcpdf/example_001.phps
     // galvene
     $pdf->setHeaderData("", "", "", "Atzīmju izraksts");
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 12));
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //initialize document
     $pdf->AliasNbPages();
     // add a page
     $pdf->AddPage();
     // set font
     $pdf->SetFont("helvetica", "", 10);
     // print a line using Cell()
     $pdf->Cell(50, 12, "Skolēns: {$this->studentName}", 0, 0, 'L');
     $pdf->Ln();
     //ģenerē visu butisko saturu
     for ($i = 0; $i < count($this->grades); $i++) {
         $grade = $this->grades[$i];
         $pdf->Cell(0, 0, sprintf("%s  %s  %s", $grade["date"], $grade["lesson"], $grade["grade"]), 0, 0, 'L');
         $pdf->Ln();
     }
     $this->fileContents = $pdf;
 }
Example #28
-1
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 040');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 040', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set display mode
     $pdf->SetDisplayMode($zoom = 'fullpage', $layout = 'TwoColumnRight', $mode = 'UseNone');
     // set pdf viewer preferences
     $pdf->setViewerPreferences(array('Duplex' => 'DuplexFlipLongEdge'));
     // set booklet mode
     $pdf->SetBooklet(true, 10, 30);
     // set core font
     $pdf->SetFont('helvetica', '', 18);
     // add a page (left page)
     $pdf->AddPage();
     $pdf->Write(0, 'Example of booklet mode', '', 0, 'L', true, 0, false, false, 0);
     // print a line using Cell()
     $pdf->Cell(0, 0, 'PAGE 1', 1, 1, 'C');
     // add a page (right page)
     $pdf->AddPage();
     // print a line using Cell()
     $pdf->Cell(0, 0, 'PAGE 2', 1, 1, 'C');
     // add a page (left page)
     $pdf->AddPage();
     // print a line using Cell()
     $pdf->Cell(0, 0, 'PAGE 3', 1, 1, 'C');
     // add a page (right page)
     $pdf->AddPage();
     // print a line using Cell()
     $pdf->Cell(0, 0, 'PAGE 4', 1, 1, 'C');
     $this->comparePdfs($pdf);
 }
Example #29
-4
 public function testPdfOutput()
 {
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('TCPDF Example 055');
     $pdf->SetSubject('TCPDF Tutorial');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // set default header data
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 055', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     $pdf->setLanguageArray($this->langSettings);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', '', 14);
     // array of font names
     $core_fonts = array('courier', 'courierB', 'courierI', 'courierBI', 'helvetica', 'helveticaB', 'helveticaI', 'helveticaBI', 'times', 'timesB', 'timesI', 'timesBI', 'symbol', 'zapfdingbats');
     // set fill color
     $pdf->SetFillColor(221, 238, 255);
     // create one HTML table for each core font
     foreach ($core_fonts as $font) {
         // add a page
         $pdf->AddPage();
         // Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
         // set font for title
         $pdf->SetFont('helvetica', 'B', 16);
         // print font name
         $pdf->Cell(0, 10, 'FONT: ' . $font, 1, 1, 'C', true, '', 0, false, 'T', 'M');
         // set font for chars
         $pdf->SetFont($font, '', 16);
         // print each character
         for ($i = 0; $i < 256; ++$i) {
             if ($i > 0 and $i % 16 == 0) {
                 $pdf->Ln();
             }
             $pdf->Cell(11.25, 11.25, TCPDF_FONTS::unichr($i), 1, 0, 'C', false, '', 0, false, 'T', 'M');
         }
         $pdf->Ln(20);
         // print a pangram
         $pdf->Cell(0, 0, 'The quick brown fox jumps over the lazy dog', 0, 1, 'C', false, '', 0, false, 'T', 'M');
     }
     // ---------------------------------------------------------
     $this->comparePdfs($pdf);
 }
Example #30
-10
    function index()
    {
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // 设置文档的基本信息
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('tongji');
        $pdf->SetTitle('下载');
        $pdf->SetSubject('打印文档');
        $pdf->SetKeywords('下载, 打印文档');
        // 默认页眉页脚
        $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 023', PDF_HEADER_STRING);
        // 页眉页脚字体
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // 默认等宽字体
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // 间距设置
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // 自动分页
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // 图像缩放因子
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        // ---------------------------------------------------------
        // 设置中文字体
        $pdf->SetFont('droidsansfallback', 'BI', 14);
        // Start First Page Group
        $pdf->startPageGroup();
        // add a page
        $pdf->AddPage();
        // set some text to print
        $txt = <<<EOD
Example of page groups.
Check the page numbers on the page footer.

This is the first page of group 1.
EOD;
        // print a block of text using Write()
        $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
        // add second page
        $pdf->AddPage();
        $pdf->Cell(0, 10, '发热551', 0, 1, 'L');
        // ---------------------------------------------------------
        //Bug出现下载文档
        //Close and output PDF document
        $pdf->Output('example_023.pdf', 'I');
    }