<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>
<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>