<li><b>1.</b><ahref='#q1'>What's exactly the license of FPDF? Are there any usage restrictions?</a></li>
<li><b>2.</b><ahref='#q2'>When I try to create a PDF, a lot of weird characters show on the screen. Why?</a></li>
<li><b>3.</b><ahref='#q3'>I try to generate a PDF and IE displays a blank page. What happens?</a></li>
<li><b>4.</b><ahref='#q4'>I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.</a></li>
<li><b>5.</b><ahref='#q5'>I try to display a variable in the Header method but nothing prints.</a></li>
<li><b>6.</b><ahref='#q6'>I defined the Header and Footer methods in my PDF class but nothing appears.</a></li>
<li><b>7.</b><ahref='#q7'>Accented characters are replaced by some strange characters like é.</a></li>
<li><b>8.</b><ahref='#q8'>I try to display the Euro symbol but it doesn't work.</a></li>
<li><b>9.</b><ahref='#q9'>I get the following error when I try to generate a PDF: Some data has already been output, can't send PDF file</a></li>
<li><b>10.</b><ahref='#q10'>I draw a frame with very precise dimensions, but when printed I notice some differences.</a></li>
<li><b>11.</b><ahref='#q11'>I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?</a></li>
<li><b>12.</b><ahref='#q12'>How can I put a background in my PDF?</a></li>
<li><b>13.</b><ahref='#q13'>How can I set a specific header or footer on the first page?</a></li>
<li><b>14.</b><ahref='#q14'>I'd like to use extensions provided by different scripts. How can I combine them?</a></li>
<li><b>15.</b><ahref='#q15'>How can I send the PDF by email?</a></li>
<li><b>16.</b><ahref='#q16'>What's the limit of the file sizes I can generate with FPDF?</a></li>
<li><b>17.</b><ahref='#q17'>Can I modify a PDF with FPDF?</a></li>
<li><b>18.</b><ahref='#q18'>I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?</a></li>
<li><b>19.</b><ahref='#q19'>Can I convert an HTML page to PDF with FPDF?</a></li>
<li><b>20.</b><ahref='#q20'>Can I concatenate PDF files with FPDF?</a></li>
</ul>
<ulid='answers'>
<liid='q1'>
<p><b>1.</b><spanclass='question'>What's exactly the license of FPDF? Are there any usage restrictions?</span></p>
FPDF is released under a permissive license: there is no usage restriction. You may embed it
freely in your application (commercial or not), with or without modifications.
</li>
<liid='q2'>
<p><b>2.</b><spanclass='question'>When I try to create a PDF, a lot of weird characters show on the screen. Why?</span></p>
These "weird" characters are in fact the actual content of your PDF. This behavior is a bug of
IE6. When it first receives an HTML page, then a PDF from the same URL, it displays it directly
without launching Acrobat. This happens frequently during the development stage: on the least
script error, an HTML page is sent, and after correction, the PDF arrives.
<br>
To solve the problem, simply quit and restart IE. You can also go to another URL and come
back.
<br>
To avoid this kind of inconvenience during the development, you can generate the PDF directly
to a file and open it through the explorer.
</li>
<liid='q3'>
<p><b>3.</b><spanclass='question'>I try to generate a PDF and IE displays a blank page. What happens?</span></p>
First of all, check that you send nothing to the browser after the PDF (not even a space or a
carriage return). You can put an exit statement just after the call to the Output() method to
be sure. If it still doesn't work, it means you're a victim of the "blank page syndrome". IE
used in conjunction with the Acrobat plug-in suffers from many bugs. To avoid these problems
in a reliable manner, two main techniques exist:
<br>
<br>
- Disable the plug-in and use Acrobat as a helper application. To do this, launch Acrobat, go
to the Edit menu, Preferences, Internet, and uncheck "Display PDF in browser". Then, the next
time you load a PDF in IE, it displays the dialog box "Open it" or "Save it to disk". Uncheck
the option "Always ask before opening this type of file" and choose Open. From now on, PDF files
will open automatically in an external Acrobat window.
<br>
The drawback of the method is that you need to alter the client configuration, which you can do
in an intranet environment but not for the Internet.
<br>
<br>
- Use a redirection technique. It consists in generating the PDF in a temporary file on the server
and redirect the client to it. For example, at the end of the script, you can put the following:
<divclass="doc-source">
<pre><code>//Determine a temporary file name in the current directory
$file = basename(tempnam('.', 'tmp'));
rename($file, $file.'.pdf');
$file .= '.pdf';
//Save PDF to file
$pdf->Output($file, 'F');
//Redirect
header('Location: '.$file);</code></pre>
</div>
This method turns the dynamic PDF into a static one and avoids all troubles. But you have to do
some cleaning in order to delete the temporary files. For example:
<p><b>8.</b><spanclass='question'>I try to display the Euro symbol but it doesn't work.</span></p>
The standard fonts have the Euro character at position 128. You can define a constant like this
for convenience:
<divclass="doc-source">
<pre><code>define('EURO', chr(128));</code></pre>
</div>
</li>
<liid='q9'>
<p><b>9.</b><spanclass='question'>I get the following error when I try to generate a PDF: Some data has already been output, can't send PDF file</span></p>
You must send nothing to the browser except the PDF itself: no HTML, no space, no carriage return. A common
case is having extra blank at the end of an included script file.<br>
If you can't figure out where the problem comes from, this other message appearing just before can help you:<br>
<br>
<b>Warning:</b> Cannot modify header information - headers already sent by (output started at script.php:X)<br>
<br>
It means that script.php outputs something at line X. Go to this line and fix it.
In case the message doesn't show, first check that you didn't disable warnings, then add this at the very
beginning of your script:
<divclass="doc-source">
<pre><code>ob_end_clean();</code></pre>
</div>
If you still don't see it, disable zlib.output_compression in your php.ini and it should appear.
</li>
<liid='q10'>
<p><b>10.</b><spanclass='question'>I draw a frame with very precise dimensions, but when printed I notice some differences.</span></p>
To respect dimensions, select "None" for the Page Scaling setting instead of "Shrink to Printable Area" in the print dialog box.
</li>
<liid='q11'>
<p><b>11.</b><spanclass='question'>I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?</span></p>
Printers have physical margins (different depending on the models); it is therefore impossible to remove
them and print on the whole surface of the paper.
</li>
<liid='q12'>
<p><b>12.</b><spanclass='question'>How can I put a background in my PDF?</span></p>
For a picture, call Image() in the Header() method, before any other output. To set a background color, use Rect().
</li>
<liid='q13'>
<p><b>13.</b><spanclass='question'>How can I set a specific header or footer on the first page?</span></p>
Simply test the page number:
<divclass="doc-source">
<pre><code>function Header()
{
if($this->PageNo()==1)
{
//First page
...
}
else
{
//Other pages
...
}
}</code></pre>
</div>
</li>
<liid='q14'>
<p><b>14.</b><spanclass='question'>I'd like to use extensions provided by different scripts. How can I combine them?</span></p>
Use an inheritance chain. If you have two classes, say A in a.php:
<divclass="doc-source">
<pre><code>require('fpdf.php');
class A extends FPDF
{
...
}</code></pre>
</div>
and B in b.php:
<divclass="doc-source">
<pre><code>require('fpdf.php');
class B extends FPDF
{
...
}</code></pre>
</div>
then make B extend A:
<divclass="doc-source">
<pre><code>require('a.php');
class B extends A
{
...
}</code></pre>
</div>
and make your own class extend B:
<divclass="doc-source">
<pre><code>require('b.php');
class PDF extends B
{
...
}
$pdf = new PDF();</code></pre>
</div>
</li>
<liid='q15'>
<p><b>15.</b><spanclass='question'>How can I send the PDF by email?</span></p>
As any other file, but an easy way is to use <ahref="http://phpmailer.codeworxtech.com">PHPMailer</a> and
<p><b>20.</b><spanclass='question'>Can I concatenate PDF files with FPDF?</span></p>
Not directly, but it is possible to use <ahref="http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/concatenate-fake/"target="_blank">FPDI</a>
to perform this task. Some free command-line tools also exist:<br>
- The MakeFont utility has been completely rewritten and doesn't depend on ttf2pt1 anymore.<br>
- Alpha channel is now supported for PNGs.<br>
- When inserting an image, it's now possible to specify its resolution.<br>
- Default resolution for images was increased from 72 to 96 dpi.<br>
- When inserting a GIF image, no temporary file is used anymore if the PHP version is 5.1 or higher.<br>
- When output buffering is enabled and the PDF is about to be sent, the buffer is now cleared if it contains only a UTF-8 BOM and/or whitespace (instead of throwing an error).<br>
- Symbol and ZapfDingbats fonts now support underline style.<br>
- Custom page sizes are now checked to ensure that width is smaller than height.<br>
- Standard font files were changed to use the same format as user fonts.<br>
- A bug in the embedding of Type1 fonts was fixed.<br>
- A bug related to SetDisplayMode() and the current locale was fixed.<br>
- A display issue occurring with the Adobe Reader X plug-in was fixed.<br>
- An issue related to transparency with some versions of Adobe Reader was fixed.<br>
- The Content-Length header was removed because it caused an issue when the HTTP server applies compression.<br>
</dd>
<dt><strong>v1.6</strong> (2008-08-03)</dt>
<dd>
- PHP 4.3.10 or higher is now required.<br>
- GIF image support.<br>
- Images can now trigger page breaks.<br>
- Possibility to have different page formats in a single document.<br>
- Document properties (author, creator, keywords, subject and title) can now be specified in UTF-8.<br>
- Fixed a bug: when a PNG was inserted through a URL, an error sometimes occurred.<br>
- An automatic page break in Header() doesn't cause an infinite loop any more.<br>
- Removed some warning messages appearing with recent PHP versions.<br>
- Added HTTP headers to reduce problems with IE.<br>
</dd>
<dt><strong>v1.53</strong> (2004-12-31)</dt>
<dd>
- When the font subdirectory is in the same directory as fpdf.php, it's no longer necessary to define the FPDF_FONTPATH constant.<br>
- The array $HTTP_SERVER_VARS is no longer used. It could cause trouble on PHP5-based configurations with the register_long_arrays option disabled.<br>
- Fixed a problem related to Type1 font embedding which caused trouble to some PDF processors.<br>
- The file name sent to the browser could not contain a space character.<br>
- The Cell() method could not print the number 0 (you had to pass the string '0').<br>
</dd>
<dt><strong>v1.52</strong> (2003-12-30)</dt>
<dd>
- Image() now displays the image at 72 dpi if no dimension is given.<br>
- Output() takes a string as second parameter to indicate destination.<br>
- Open() is now called automatically by AddPage().<br>
- Inserting remote JPEG images doesn't generate an error any longer.<br>
- Decimal separator is forced to dot in the constructor.<br>
- Added several encodings (Turkish, Thai, Hebrew, Ukrainian and Vietnamese).<br>
- The last line of a right-aligned MultiCell() was not correctly aligned if it was terminated by a carriage return.<br>
- No more error message about already sent headers when outputting the PDF to the standard output from the command line.<br>
- The underlining was going too far for text containing characters \, ( or ).<br>
- $HTTP_ENV_VARS has been replaced by $HTTP_SERVER_VARS.<br>
</dd>
<dt><strong>v1.51</strong> (2002-08-03)</dt>
<dd>
- Type1 font support.<br>
- Added Baltic encoding.<br>
- The class now works internally in points with the origin at the bottom in order to avoid two bugs occurring with Acrobat 5 :<br> * The line thickness was too large when printed under Windows 98 SE and ME.<br> * TrueType fonts didn't appear immediately inside the plug-in (a substitution font was used), one had to cause a window refresh to make them show up.<br>
- It's no longer necessary to set the decimal separator as dot to produce valid documents.<br>
- The clickable area in a cell was always on the left independently from the text alignment.<br>
- JPEG images in CMYK mode appeared in inverted colors.<br>
- Transparent PNG images in grayscale or true color mode were incorrectly handled.<br>
- Adding new fonts now works correctly even with the magic_quotes_runtime option set to on.<br>
</dd>
<dt><strong>v1.5</strong> (2002-05-28)</dt>
<dd>
- TrueType font (AddFont()) and encoding support (Western and Eastern Europe, Cyrillic and Greek).<br>