example_058.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. //============================================================+
  3. // File name : example_058.php
  4. // Begin : 2010-04-22
  5. // Last Update : 2013-05-14
  6. //
  7. // Description : Example 058 for TCPDF class
  8. // SVG Image
  9. //
  10. // Author: Nicola Asuni
  11. //
  12. // (c) Copyright:
  13. // Nicola Asuni
  14. // Tecnick.com LTD
  15. // www.tecnick.com
  16. // info@tecnick.com
  17. //============================================================+
  18. /**
  19. * Creates an example PDF TEST document using TCPDF
  20. * @package com.tecnick.tcpdf
  21. * @abstract TCPDF - Example: SVG Image
  22. * @author Nicola Asuni
  23. * @since 2010-05-02
  24. * @group svg
  25. * @group image
  26. * @group pdf
  27. */
  28. // Include the main TCPDF library (search for installation path).
  29. require_once('tcpdf_include.php');
  30. // create new PDF document
  31. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  32. // set document information
  33. $pdf->setCreator(PDF_CREATOR);
  34. $pdf->setAuthor('Nicola Asuni');
  35. $pdf->setTitle('TCPDF Example 058');
  36. $pdf->setSubject('TCPDF Tutorial');
  37. $pdf->setKeywords('TCPDF, PDF, example, test, guide');
  38. // set default header data
  39. $pdf->setHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 058', PDF_HEADER_STRING);
  40. // set header and footer fonts
  41. $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  42. $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  43. // set default monospaced font
  44. $pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  45. // set margins
  46. $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  47. $pdf->setHeaderMargin(PDF_MARGIN_HEADER);
  48. $pdf->setFooterMargin(PDF_MARGIN_FOOTER);
  49. // set auto page breaks
  50. $pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  51. // set image scale factor
  52. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  53. // set some language-dependent strings (optional)
  54. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  55. require_once(dirname(__FILE__).'/lang/eng.php');
  56. $pdf->setLanguageArray($l);
  57. }
  58. // ---------------------------------------------------------
  59. // set font
  60. $pdf->setFont('helvetica', '', 10);
  61. // add a page
  62. $pdf->AddPage();
  63. // NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library.
  64. //$pdf->setRasterizeVectorImages(true);
  65. $pdf->ImageSVG($file='images/testsvg.svg', $x=15, $y=30, $w='', $h='', $link='http://www.tcpdf.org', $align='', $palign='', $border=1, $fitonpage=false);
  66. $pdf->ImageSVG($file='images/tux.svg', $x=30, $y=100, $w='', $h=100, $link='', $align='', $palign='', $border=0, $fitonpage=false);
  67. $pdf->setFont('helvetica', '', 8);
  68. $pdf->setY(195);
  69. $txt = '© The copyright holder of the above Tux image is Larry Ewing, allows anyone to use it for any purpose, provided that the copyright holder is properly attributed. Redistribution, derivative work, commercial use, and all other use is permitted.';
  70. $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
  71. // ---------------------------------------------------------
  72. //Close and output PDF document
  73. $pdf->Output('example_058.pdf', 'D');
  74. //============================================================+
  75. // END OF FILE
  76. //============================================================+