image.htm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Image</title>
  6. <link type="text/css" rel="stylesheet" href="../fpdf.css">
  7. </head>
  8. <body>
  9. <h1>Image</h1>
  10. <code>Image(<b>string</b> file [, <b>float</b> x [, <b>float</b> y [, <b>float</b> w [, <b>float</b> h [, <b>string</b> type [, <b>mixed</b> link]]]]]])</code>
  11. <h2>Description</h2>
  12. Puts an image. The size it will take on the page can be specified in different ways:
  13. <ul>
  14. <li>explicit width and height (expressed in user unit or dpi)</li>
  15. <li>one explicit dimension, the other being calculated automatically in order to keep the original proportions</li>
  16. <li>no explicit dimension, in which case the image is put at 96 dpi</li>
  17. </ul>
  18. Supported formats are JPEG, PNG and GIF. The GD extension is required for GIF.
  19. <br>
  20. <br>
  21. For JPEGs, all flavors are allowed:
  22. <ul>
  23. <li>gray scales</li>
  24. <li>true colors (24 bits)</li>
  25. <li>CMYK (32 bits)</li>
  26. </ul>
  27. For PNGs, are allowed:
  28. <ul>
  29. <li>gray scales on at most 8 bits (256 levels)</li>
  30. <li>indexed colors</li>
  31. <li>true colors (24 bits)</li>
  32. </ul>
  33. For GIFs: in case of an animated GIF, only the first frame is displayed.<br>
  34. <br>
  35. Transparency is supported.<br>
  36. <br>
  37. The format can be specified explicitly or inferred from the file extension.<br>
  38. <br>
  39. It is possible to put a link on the image.<br>
  40. <br>
  41. Remark: if an image is used several times, only one copy is embedded in the file.
  42. <h2>Parameters</h2>
  43. <dl class="param">
  44. <dt><code>file</code></dt>
  45. <dd>
  46. Path or URL of the image.
  47. </dd>
  48. <dt><code>x</code></dt>
  49. <dd>
  50. Abscissa of the upper-left corner. If not specified or equal to <code>null</code>, the current abscissa
  51. is used.
  52. </dd>
  53. <dt><code>y</code></dt>
  54. <dd>
  55. Ordinate of the upper-left corner. If not specified or equal to <code>null</code>, the current ordinate
  56. is used; moreover, a page break is triggered first if necessary (in case automatic page breaking is enabled)
  57. and, after the call, the current ordinate is moved to the bottom of the image.
  58. </dd>
  59. <dt><code>w</code></dt>
  60. <dd>
  61. Width of the image in the page. There are three cases:
  62. <ul>
  63. <li>If the value is positive, it represents the width in user unit</li>
  64. <li>If the value is negative, the absolute value represents the horizontal resolution in dpi</li>
  65. <li>If the value is not specified or equal to zero, it is automatically calculated</li>
  66. </ul>
  67. </dd>
  68. <dt><code>h</code></dt>
  69. <dd>
  70. Height of the image in the page. There are three cases:
  71. <ul>
  72. <li>If the value is positive, it represents the height in user unit</li>
  73. <li>If the value is negative, the absolute value represents the vertical resolution in dpi</li>
  74. <li>If the value is not specified or equal to zero, it is automatically calculated</li>
  75. </ul>
  76. </dd>
  77. <dt><code>type</code></dt>
  78. <dd>
  79. Image format. Possible values are (case insensitive): <code>JPG</code>, <code>JPEG</code>, <code>PNG</code> and <code>GIF</code>.
  80. If not specified, the type is inferred from the file extension.
  81. </dd>
  82. <dt><code>link</code></dt>
  83. <dd>
  84. URL or identifier returned by AddLink().
  85. </dd>
  86. </dl>
  87. <h2>Example</h2>
  88. <div class="doc-source">
  89. <pre><code>// Insert a logo in the top-left corner at 300 dpi
  90. $pdf-&gt;Image('logo.png',10,10,-300);
  91. // Insert a dynamic image from a URL
  92. $pdf-&gt;Image('http://chart.googleapis.com/chart?cht=p3&amp;chd=t:60,40&amp;chs=250x100&amp;chl=Hello|World',60,30,90,0,'PNG');</code></pre>
  93. </div>
  94. <h2>See also</h2>
  95. <a href="addlink.htm">AddLink</a>
  96. <hr style="margin-top:1.5em">
  97. <div style="text-align:center"><a href="index.htm">Index</a></div>
  98. </body>
  99. </html>