[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/tcpdf/ -> test_unicode.php (source)

   1  <?php
   2  //============================================================+
   3  // File name   : test_unicode.php
   4  // Begin       : 2004-07-14
   5  // Last Update : 2007-03-06
   6  // 
   7  // Description : Test page fot TCPDF class
   8  // 
   9  // Author: Nicola Asuni
  10  // 
  11  // (c) Copyright:
  12  //               Tecnick.com S.r.l.
  13  //               Via Ugo Foscolo n.19
  14  //               09045 Quartu Sant'Elena (CA)
  15  //               ITALY
  16  //               www.tecnick.com
  17  //               [email protected]
  18  //============================================================+
  19  
  20  /**
  21   * Create PDF document -test for unicode
  22   * @package com.tecnick.tcpdf
  23   * @abstract TCPDF - unicode test.
  24   * @author Nicola Asuni
  25   * @copyright 2004-2006 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY - www.tecnick.com - [email protected]
  26   * @link http://tcpdf.sourceforge.net
  27   * @license http://www.gnu.org/copyleft/lesser.html LGPL
  28   * @since 2004-07-14
  29   */
  30  
  31  $doc_title = "test title";
  32  $doc_subject = "test description";
  33  $doc_keywords = "test keywords";
  34  $htmlcontent = "&lt; € &euro; &#8364; &amp; è &egrave; &copy; &gt;<br /><h1>heading 1</h1><h2>heading 2</h2><h3>heading 3</h3><h4>heading 4</h4><h5>heading 5</h5><h6>heading 6</h6>ordered list:<br /><ol><li><b>bold text</b></li><li><i>italic text</i></li><li><u>underlined text</u></li><li><a href=\"http://www.tecnick.com\">link to http://www.tecnick.com</a></li><li>test break<br />second line<br />third line</li><li><font size=\"+3\">font + 3</font></li><li><small>small text</small></li><li>normal <sub>subscript</sub> <sup>superscript</sup></li></ul><hr />table:<br /><table border=\"1\" cellspacing=\"1\" cellpadding=\"1\"><tr><th>#</th><th>A</th><th>B</th></tr><tr><th>1</th><td bgcolor=\"#cccccc\">A1</td><td>B1</td></tr><tr><th>2</th><td>A2 € &euro; &#8364; &amp; è &egrave; </td><td>B2</td></tr><tr><th>3</th><td>A3</td><td><font color=\"#FF0000\">B3</font></td></tr></table><hr />image:<br /><img src=\"images/logo_example.png\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" />";
  35  
  36  require_once ('config/lang/eng.php');
  37  require_once ('tcpdf.php');
  38  
  39  //create new PDF document (document units are set by default to millimeters)
  40  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 
  41  
  42  // set document information
  43  $pdf->SetCreator(PDF_CREATOR);
  44  $pdf->SetAuthor(PDF_AUTHOR);
  45  $pdf->SetTitle($doc_title);
  46  $pdf->SetSubject($doc_subject);
  47  $pdf->SetKeywords($doc_keywords);
  48  
  49  $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
  50  
  51  //set margins
  52  $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  53  //set auto page breaks
  54  $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  55  $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
  56  $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  57  $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
  58  
  59  $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  60  $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  61  
  62  $pdf->setLanguageArray($l); //set language items
  63  
  64  
  65  //initialize document
  66  $pdf->AliasNbPages();
  67  
  68  $pdf->AddPage();
  69  
  70  // set barcode
  71  $pdf->SetBarcode(date("Y-m-d H:i:s", time()));
  72  
  73  // output some HTML code
  74  $pdf->writeHTML($htmlcontent, true, 0);
  75  
  76  // output two html columns
  77  $first_column_width = 80;
  78  $current_y_position = $pdf->getY();
  79  $pdf->writeHTMLCell($first_column_width, 0, 0, $current_y_position, "<b>hello</b>", 0, 0, 0); 
  80  $pdf->writeHTMLCell(0, 0, $first_column_width, $current_y_position, "<i>world</i>", 0, 1, 0); 
  81  
  82  // output some content
  83  $pdf->SetFont("vera", "BI", 20);
  84  $pdf->Cell(0,10,"TEST Bold-Italic Cell",1,1,'C');
  85  
  86  // output some UTF-8 test content
  87  $pdf->AddPage();
  88  $pdf->SetFont("FreeSerif", "", 12);
  89  $utf8text = file_get_contents("utf8test.txt", false); // get utf-8 text form file
  90  $pdf->SetFillColor(230, 240, 255, true);
  91  $pdf->Write(5,$utf8text, '', 1);
  92  
  93  // remove page header/footer
  94  $pdf->setPrintHeader(false);
  95  $pdf->setPrintFooter(false);
  96  
  97  // Two HTML columns test
  98  $pdf->AddPage();
  99  $right_column = "<b>right column</b> right column right column right column right column
 100  right column right column right column right column right column right column
 101  right column right column right column right column right column right column";
 102  $left_column = "<b>left column</b> left column left column left column left column left
 103  column left column left column left column left column left column left column
 104  left column left column left column left column left column left column left
 105  column";
 106  $first_column_width = 80;
 107  $second_column_width = 80;
 108  $column_space = 20; 
 109  $current_y_position = $pdf->getY(); 
 110  $pdf->writeHTMLCell($first_column_width, 0, 0, 0, $left_column, 1, 0, 0);
 111  $pdf->Cell(0);
 112  $pdf->writeHTMLCell($second_column_width, 0, $first_column_width+$column_space, $current_y_position, $right_column, 0, 0, 0);
 113  
 114  // add page header/footer
 115  $pdf->setPrintHeader(true);
 116  $pdf->setPrintFooter(true);
 117  
 118  $pdf->AddPage();
 119  
 120  // Multicell test
 121  $pdf->MultiCell(40, 5, "A test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
 122  $pdf->MultiCell(40, 5, "B test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
 123  $pdf->MultiCell(40, 5, "C test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 0);
 124  $pdf->MultiCell(40, 5, "D test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0, 2);
 125  $pdf->MultiCell(40, 5, "F test multicell line 1\ntest multicell line 2\ntest multicell line 3", 1, 'J', 0);
 126  
 127  //Close and output PDF document
 128  $pdf->Output();
 129  
 130  //============================================================+
 131  // END OF FILE                                                 
 132  //============================================================+
 133  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1