diff --git a/FAQ.htm b/FAQ.htm index a4abc2c..6379a4b 100644 --- a/FAQ.htm +++ b/FAQ.htm @@ -46,13 +46,13 @@
2. I get the following error when I try to generate a PDF: Some data has already been output, can't send PDF file
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.ob_end_clean();
3. Accented letters are replaced with some strange characters like é.
-Don't use UTF-8 with the standard fonts; they expect text encoded in ISO-8859-1 or windows-1252. -You can use utf8_decode() to perform a conversion to ISO-8859-1: +Don't use UTF-8 with the standard fonts; they expect text encoded in windows-1252. +You can perform a conversion with iconv:$str = utf8_decode($str);
+$str = iconv('UTF-8', 'windows-1252', $str);
$str = iconv('UTF-8', 'windows-1252', $str);
+$str = mb_convert_encoding($str, 'windows-1252', 'UTF-8');
$pdf = new FPDF('P','mm',array(100,150));
+$pdf = new FPDF('P', 'mm', array(100,150));
class PDF extends FPDF
{
-var $col = 0;
+ protected $col = 0;
-function SetCol($col)
-{
- // Move position to a column
- $this->col = $col;
- $x = 10+$col*65;
- $this->SetLeftMargin($x);
- $this->SetX($x);
-}
-
-function AcceptPageBreak()
-{
- if($this->col<2)
+ function SetCol($col)
{
- // Go to next column
- $this->SetCol($this->col+1);
- $this->SetY(10);
- return false;
+ // Move position to a column
+ $this->col = $col;
+ $x = 10 + $col*65;
+ $this->SetLeftMargin($x);
+ $this->SetX($x);
}
- else
+
+ function AcceptPageBreak()
{
- // Go back to first column and issue page break
- $this->SetCol(0);
- return true;
+ if($this->col<2)
+ {
+ // Go to next column
+ $this->SetCol($this->col+1);
+ $this->SetY(10);
+ return false;
+ }
+ else
+ {
+ // Go back to first column and issue page break
+ $this->SetCol(0);
+ return true;
+ }
}
}
-}
$pdf = new PDF();
$pdf->AddPage();
-$pdf->SetFont('Arial','',12);
+$pdf->SetFont('Arial', '', 12);
for($i=1;$i<=300;$i++)
- $pdf->Cell(0,5,"Line $i",0,1);
+ $pdf->Cell(0, 5, "Line $i", 0, 1);
$pdf->Output();
$pdf->AddFont('Comic','I');
+$pdf->AddFont('Comic', 'I');
$pdf->AddFont('Comic','I','comici.php');
+$pdf->AddFont('Comic', 'I', 'comici.php');
class PDF extends FPDF
{
-function Footer()
-{
- // Go to 1.5 cm from bottom
- $this->SetY(-15);
- // Select Arial italic 8
- $this->SetFont('Arial','I',8);
- // Print current and total page numbers
- $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
-}
+ function Footer()
+ {
+ // Go to 1.5 cm from bottom
+ $this->SetY(-15);
+ // Select Arial italic 8
+ $this->SetFont('Arial', 'I', 8);
+ // Print current and total page numbers
+ $this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}', 0, 0, 'C');
+ }
}
$pdf = new PDF();
diff --git a/doc/cell.htm b/doc/cell.htm
index d46359a..8b69ba5 100644
--- a/doc/cell.htm
+++ b/doc/cell.htm
@@ -81,11 +81,11 @@ Parameters
Example
// Set font
-$pdf->SetFont('Arial','B',16);
+$pdf->SetFont('Arial', 'B', 16);
// Move to 8 cm to the right
$pdf->Cell(80);
// Centered text in a framed 20*10 mm cell and line break
-$pdf->Cell(20,10,'Title',1,1,'C');
+$pdf->Cell(20, 10, 'Title', 1, 1, 'C');
See also
SetFont,
diff --git a/doc/footer.htm b/doc/footer.htm
index a3a2018..4398bd8 100644
--- a/doc/footer.htm
+++ b/doc/footer.htm
@@ -16,15 +16,15 @@ Example
class PDF extends FPDF
{
-function Footer()
-{
- // Go to 1.5 cm from bottom
- $this->SetY(-15);
- // Select Arial italic 8
- $this->SetFont('Arial','I',8);
- // Print centered page number
- $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
-}
+ function Footer()
+ {
+ // Go to 1.5 cm from bottom
+ $this->SetY(-15);
+ // Select Arial italic 8
+ $this->SetFont('Arial', 'I', 8);
+ // Print centered page number
+ $this->Cell(0, 10, 'Page '.$this->PageNo(), 0, 0, 'C');
+ }
}
See also
diff --git a/doc/header.htm b/doc/header.htm
index 3c3da96..984fc6a 100644
--- a/doc/header.htm
+++ b/doc/header.htm
@@ -16,17 +16,17 @@ Example
class PDF extends FPDF
{
-function Header()
-{
- // Select Arial bold 15
- $this->SetFont('Arial','B',15);
- // Move to the right
- $this->Cell(80);
- // Framed title
- $this->Cell(30,10,'Title',1,0,'C');
- // Line break
- $this->Ln(20);
-}
+ function Header()
+ {
+ // Select Arial bold 15
+ $this->SetFont('Arial', 'B', 15);
+ // Move to the right
+ $this->Cell(80);
+ // Framed title
+ $this->Cell(30, 10, 'Title', 1, 0, 'C');
+ // Line break
+ $this->Ln(20);
+ }
}
See also
diff --git a/doc/image.htm b/doc/image.htm
index 96ab907..aad4775 100644
--- a/doc/image.htm
+++ b/doc/image.htm
@@ -87,9 +87,9 @@ Parameters
Example
// Insert a logo in the top-left corner at 300 dpi
-$pdf->Image('logo.png',10,10,-300);
+$pdf->Image('logo.png', 10, 10, -300);
// Insert a dynamic image from a URL
-$pdf->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World',60,30,90,0,'PNG');
+$pdf->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World', 60, 30, 90, 0, 'PNG');
See also
AddLink
diff --git a/doc/index.htm b/doc/index.htm
index f4766ba..211032b 100644
--- a/doc/index.htm
+++ b/doc/index.htm
@@ -2,11 +2,11 @@
-FPDF 1.84 Reference Manual
+FPDF 1.85 Reference Manual
-FPDF 1.84 Reference Manual
+FPDF 1.85 Reference Manual
__construct - constructor
AcceptPageBreak - accept or not automatic page break
AddFont - add a new font
diff --git a/doc/output.htm b/doc/output.htm
index 229e0a7..8992f93 100644
--- a/doc/output.htm
+++ b/doc/output.htm
@@ -38,6 +38,15 @@ Parameters
The default value is false
.
+Example
+Save the document to a local directory:
+
+$pdf->Output('F', 'reports/report.pdf');
+
+Force a download:
+
+$pdf->Output('D', 'report.pdf');
+
See also
Close
diff --git a/doc/setfont.htm b/doc/setfont.htm
index a1de05c..072de22 100644
--- a/doc/setfont.htm
+++ b/doc/setfont.htm
@@ -23,13 +23,12 @@ Description
Note: the font definition files must be accessible. They are searched successively in:
-- The directory defined by the
FPDF_FONTPATH
constant (if this constant is defined)
+- The directory defined by the
FPDF_FONTPATH
constant (if that constant is defined)
- The
font
directory located in the same directory as fpdf.php
(if it exists)
-- The directories accessible through
include()
Example using FPDF_FONTPATH
:
-define('FPDF_FONTPATH','/home/www/font');
+define('FPDF_FONTPATH', '/home/www/font');
require('fpdf.php');
If the file corresponding to the requested font is not found, the error "Could not include font
@@ -66,7 +65,7 @@ Parameters
Font size in points.
The default value is the current size. If no size has been specified since the beginning of
-the document, the value taken is 12.
+the document, the value is 12.
Example
@@ -74,11 +73,11 @@ Example
// Times regular 12
$pdf->SetFont('Times');
// Arial bold 14
-$pdf->SetFont('Arial','B',14);
+$pdf->SetFont('Arial', 'B', 14);
// Removes bold
$pdf->SetFont('');
// Times bold, italic and underlined 14
-$pdf->SetFont('Times','BIU');
+$pdf->SetFont('Times', 'BIU');
// Begin with regular font
-$pdf->SetFont('Arial','',14);
-$pdf->Write(5,'Visit ');
+$pdf->SetFont('Arial', '', 14);
+$pdf->Write(5, 'Visit ');
// Then put a blue underlined link
-$pdf->SetTextColor(0,0,255);
-$pdf->SetFont('','U');
-$pdf->Write(5,'www.fpdf.org','http://www.fpdf.org');
+$pdf->SetTextColor(0, 0, 255);
+$pdf->SetFont('', 'U');
+$pdf->Write(5, 'www.fpdf.org', 'http://www.fpdf.org');