php-fpdf-1.8.2.dfsg/ 0000755 0001750 0001750 00000000000 13650525357 014423 5 ustar adezorzi adezorzi php-fpdf-1.8.2.dfsg/changelog.htm 0000755 0001750 0001750 00000022140 13572676660 017075 0 ustar adezorzi adezorzi
boolean AcceptPageBreak()
class PDF extends FPDF
{
var $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)
{
// 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);
for($i=1;$i<=300;$i++)
$pdf->Cell(0,5,"Line $i",0,1);
$pdf->Output();
AddFont(string family [, string style [, string file]])
family
style
B
: boldI
: italicBI
or IB
: bold italicfile
$pdf->AddFont('Comic','I');
$pdf->AddFont('Comic','I','comici.php');
int AddLink()
AddPage([string orientation [, mixed size [, int rotation]]])
orientation
P
or Portrait
L
or Landscape
size
A3
A4
A5
Letter
Legal
rotation
0
.
AliasNbPages([string alias])
alias
{nb}
.
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');
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, boolean fill [, mixed link]]]]]]])
w
0
, the cell extends up to the right margin.
h
0
.
txt
border
0
: no border1
: frameL
: leftT
: topR
: rightB
: bottom0
.
ln
0
: to the right1
: to the beginning of the next line2
: below1
is equivalent to putting 0
and calling Ln() just after.
Default value: 0
.
align
L
or empty string: left align (default value)C
: centerR
: right alignfill
true
) or transparent (false
).
Default value: false
.
link
// Set font
$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');
Close()
Error(string msg)
msg
Footer()
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');
}
}
float GetPageHeight()
float GetPageWidth()
float GetStringWidth(string s)
s
float GetX()
float GetY()
Header()
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);
}
}
Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed link]]]]]])
file
x
null
, the current abscissa
is used.
y
null
, the current ordinate
is used; moreover, a page break is triggered first if necessary (in case automatic page breaking is enabled)
and, after the call, the current ordinate is moved to the bottom of the image.
w
h
type
JPG
, JPEG
, PNG
and GIF
.
If not specified, the type is inferred from the file extension.
link
// Insert a logo in the top-left corner at 300 dpi
$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');
Line(float x1, float y1, float x2, float y2)
x1
y1
x2
y2
Link(float x, float y, float w, float h, mixed link)
x
y
w
h
link
Ln([float h])
h
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
w
0
, they extend up to the right margin of the page.
h
txt
border
0
: no border1
: frameL
: leftT
: topR
: rightB
: bottom0
.
align
L
: left alignmentC
: centerR
: right alignmentJ
: justification (default value)fill
true
) or transparent (false
).
Default value: false
.
string Output([string dest [, string name [, boolean isUTF8]]])
dest
I
: send the file inline to the browser. The PDF viewer is used if available.D
: send to the browser and force a file download with the name given by name
.F
: save to a local file with the name given by name
(may include a path).S
: return the document as a string.I
.
name
S
.doc.pdf
.
isUTF8
name
is encoded in ISO-8859-1 (false
) or UTF-8 (true
).
Only used for destinations I
and D
.false
.
int PageNo()
Rect(float x, float y, float w, float h [, string style])
x
y
w
h
style
D
or empty string: draw. This is the default value.F
: fillDF
or FD
: draw and fillSetAuthor(string author [, boolean isUTF8])
author
isUTF8
false
) or UTF-8 (true
).false
.
SetAutoPageBreak(boolean auto [, float margin])
auto
margin
SetCompression(boolean compress)
compress
SetCreator(string creator [, boolean isUTF8])
creator
isUTF8
false
) or UTF-8 (true
).false
.
SetDisplayMode(mixed zoom [, string layout])
zoom
fullpage
: displays the entire page on screenfullwidth
: uses maximum width of windowreal
: uses real size (equivalent to 100% zoom)default
: uses viewer default modelayout
single
: displays one page at oncecontinuous
: displays pages continuouslytwo
: displays two pages on two columnsdefault
: uses viewer default modedefault
.
SetDrawColor(int r [, int g, int b])
r
g
et b
are given, red component; if not, indicates the gray level.
Value between 0 and 255.
g
b
SetFillColor(int r [, int g, int b])
r
g
and b
are given, red component; if not, indicates the gray level.
Value between 0 and 255.
g
b
SetFont(string family [, string style [, float size]])
FPDF_FONTPATH
constant (if this constant is defined)font
directory located in the same directory as fpdf.php
(if it exists)include()
FPDF_FONTPATH
:
define('FPDF_FONTPATH','/home/www/font');
require('fpdf.php');
family
Courier
(fixed-width)Helvetica
or Arial
(synonymous; sans serif)Times
(serif)Symbol
(symbolic)ZapfDingbats
(symbolic)style
B
: boldI
: italicU
: underlineSymbol
and ZapfDingbats
.
size
// Times regular 12
$pdf->SetFont('Times');
// Arial bold 14
$pdf->SetFont('Arial','B',14);
// Removes bold
$pdf->SetFont('');
// Times bold, italic and underlined 14
$pdf->SetFont('Times','BIU');
SetFontSize(float size)
size
SetKeywords(string keywords [, boolean isUTF8])
keywords
isUTF8
false
) or UTF-8 (true
).false
.
SetLeftMargin(float margin)
margin
SetLineWidth(float width)
width
SetLink(int link [, float y [, int page]])
link
y
-1
indicates the current position.
The default value is 0
(top of page).
page
-1
indicates the current page. This is the default value.
SetMargins(float left, float top [, float right])
left
top
right
SetRightMargin(float margin)
margin
SetSubject(string subject [, boolean isUTF8])
subject
isUTF8
false
) or UTF-8 (true
).false
.
SetTextColor(int r [, int g, int b])
r
g
et b
are given, red component; if not, indicates the gray level.
Value between 0 and 255.
g
b
SetTitle(string title [, boolean isUTF8])
title
isUTF8
false
) or UTF-8 (true
).false
.
SetTopMargin(float margin)
margin
SetX(float x)
x
SetXY(float x, float y)
x
y
SetY(float y [, boolean resetX])
y
resetX
true
.
Text(float x, float y, string txt)
x
y
txt
Write(float h, string txt [, mixed link])
h
txt
link
// Begin with regular font
$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');
__construct([string orientation [, string unit [, mixed size]]])
orientation
P
or Portrait
L
or Landscape
P
.
unit
pt
: pointmm
: millimetercm
: centimeterin
: inchmm
.
size
A3
A4
A5
Letter
Legal
unit
).A4
.
$pdf = new FPDF('P','mm',array(100,150));
1. What's exactly the license of FPDF? Are there any usage restrictions?
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.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:$str = utf8_decode($str);
$str = iconv('UTF-8', 'windows-1252', $str);
4. I try to display the Euro symbol but it doesn't work.
The standard fonts have the Euro character at position 128. You can define a constant like this for convenience:define('EURO', chr(128));
5. I try to display a variable in the Header method but nothing prints.
You have to use theglobal
keyword to access global variables, for example:
function Header()
{
global $title;
$this->SetFont('Arial', 'B', 15);
$this->Cell(0, 10, $title, 1, 1, 'C');
}
$title = 'My title';
function Header()
{
$this->SetFont('Arial', 'B', 15);
$this->Cell(0, 10, $this->title, 1, 1, 'C');
}
$pdf->title = 'My title';
6. I have defined the Header and Footer methods in my PDF class but nothing shows.
You have to create an object from the PDF class, not FPDF:$pdf = new PDF();
7. I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.
You have to enclose your string with double quotes, not single ones.8. I use jQuery to generate the PDF but it doesn't show.
Don't use an AJAX request to retrieve the PDF.9. I draw a frame with very precise dimensions, but when printed I notice some differences.
To respect dimensions, select "None" for the Page Scaling setting instead of "Shrink to Printable Area" in the print dialog box.10. 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?
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.11. How can I put a background in my PDF?
For a picture, call Image() in the Header() method, before any other output. To set a background color, use Rect().12. How can I set a specific header or footer on the first page?
Just test the page number:function Header()
{
if($this->PageNo()==1)
{
//First page
...
}
else
{
//Other pages
...
}
}
13. I'd like to use extensions provided by different scripts. How can I combine them?
Use an inheritance chain. If you have two classes, say A in a.php:require('fpdf.php');
class A extends FPDF
{
...
}
require('fpdf.php');
class B extends FPDF
{
...
}
require('a.php');
class B extends A
{
...
}
require('b.php');
class PDF extends B
{
...
}
$pdf = new PDF();
14. How can I open the PDF in a new tab?
Just do the same as you would for an HTML page or anything else: add a target="_blank" to your link or form.15. How can I send the PDF by email?
As for any other file, but an easy way is to use PHPMailer and its in-memory attachment:$mail = new PHPMailer();
...
$doc = $pdf->Output('S');
$mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf');
$mail->Send();
16. What's the limit of the file sizes I can generate with FPDF?
There is no particular limit. There are some constraints, however:17. Can I modify a PDF with FPDF?
It's possible to import pages from an existing PDF document thanks to the FPDI extension. Then you can add some content to them.18. I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?
No. But a GPL C utility does exist, pdftotext, which is able to extract the textual content from a PDF. It's provided with the Xpdf package.19. Can I convert an HTML page to PDF with FPDF?
Not real-world pages. But a GPL C utility does exist, HTMLDOC, which allows to do it and gives good results.20. Can I concatenate PDF files with FPDF?
Not directly, but it's possible to use FPDI to perform that task. Some free command-line tools also exist: pdftk and mbtPdfAsm.<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
$pdf = new FPDF('P','mm','A4');
L
), other page sizes (such as Letter
and
Legal
) and units (pt
, cm
, in
).
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World !',1);
$pdf->Cell(60,10,'Powered by FPDF.',0,1,'C');
<?php
require('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Title',1,0,'C');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=40;$i++)
$pdf->Cell(0,10,'Printing line number '.$i,0,1);
$pdf->Output();
?>
{nb}
which is substituted when the document is finished
(provided you first called AliasNbPages()).
<?php
require('fpdf.php');
class PDF extends FPDF
{
function Header()
{
global $title;
// Arial bold 15
$this->SetFont('Arial','B',15);
// Calculate width of title and position
$w = $this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
// Colors of frame, background and text
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
// Thickness of frame (1 mm)
$this->SetLineWidth(1);
// Title
$this->Cell($w,9,$title,1,1,'C',true);
// Line break
$this->Ln(10);
}
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
function ChapterTitle($num, $label)
{
// Arial 12
$this->SetFont('Arial','',12);
// Background color
$this->SetFillColor(200,220,255);
// Title
$this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
// Line break
$this->Ln(4);
}
function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
// Times 12
$this->SetFont('Times','',12);
// Output justified text
$this->MultiCell(0,5,$txt);
// Line break
$this->Ln();
// Mention in italics
$this->SetFont('','I');
$this->Cell(0,5,'(end of excerpt)');
}
function PrintChapter($num, $title, $file)
{
$this->AddPage();
$this->ChapterTitle($num,$title);
$this->ChapterBody($file);
}
}
$pdf = new PDF();
$title = '20000 Leagues Under the Seas';
$pdf->SetTitle($title);
$pdf->SetAuthor('Jules Verne');
$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
$pdf->Output();
?>
true
indicates that the background must
be filled).
<?php
require('fpdf.php');
class PDF extends FPDF
{
protected $col = 0; // Current column
protected $y0; // Ordinate of column start
function Header()
{
// Page header
global $title;
$this->SetFont('Arial','B',15);
$w = $this->GetStringWidth($title)+6;
$this->SetX((210-$w)/2);
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
$this->SetLineWidth(1);
$this->Cell($w,9,$title,1,1,'C',true);
$this->Ln(10);
// Save ordinate
$this->y0 = $this->GetY();
}
function Footer()
{
// Page footer
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$this->SetTextColor(128);
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
function SetCol($col)
{
// Set position at a given column
$this->col = $col;
$x = 10+$col*65;
$this->SetLeftMargin($x);
$this->SetX($x);
}
function AcceptPageBreak()
{
// Method accepting or not automatic page break
if($this->col<2)
{
// Go to next column
$this->SetCol($this->col+1);
// Set ordinate to top
$this->SetY($this->y0);
// Keep on page
return false;
}
else
{
// Go back to first column
$this->SetCol(0);
// Page break
return true;
}
}
function ChapterTitle($num, $label)
{
// Title
$this->SetFont('Arial','',12);
$this->SetFillColor(200,220,255);
$this->Cell(0,6,"Chapter $num : $label",0,1,'L',true);
$this->Ln(4);
// Save ordinate
$this->y0 = $this->GetY();
}
function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
// Font
$this->SetFont('Times','',12);
// Output text in a 6 cm width column
$this->MultiCell(60,5,$txt);
$this->Ln();
// Mention
$this->SetFont('','I');
$this->Cell(0,5,'(end of excerpt)');
// Go back to first column
$this->SetCol(0);
}
function PrintChapter($num, $title, $file)
{
// Add chapter
$this->AddPage();
$this->ChapterTitle($num,$title);
$this->ChapterBody($file);
}
}
$pdf = new PDF();
$title = '20000 Leagues Under the Seas';
$pdf->SetTitle($title);
$pdf->SetAuthor('Jules Verne');
$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
$pdf->Output();
?>
<?php
require('fpdf.php');
class PDF extends FPDF
{
// Load data
function LoadData($file)
{
// Read file lines
$lines = file($file);
$data = array();
foreach($lines as $line)
$data[] = explode(';',trim($line));
return $data;
}
// Simple table
function BasicTable($header, $data)
{
// Header
foreach($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
// Data
foreach($data as $row)
{
foreach($row as $col)
$this->Cell(40,6,$col,1);
$this->Ln();
}
}
// Better table
function ImprovedTable($header, $data)
{
// Column widths
$w = array(40, 35, 40, 45);
// Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C');
$this->Ln();
// Data
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR');
$this->Cell($w[1],6,$row[1],'LR');
$this->Cell($w[2],6,number_format($row[2]),'LR',0,'R');
$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R');
$this->Ln();
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
// Colored table
function FancyTable($header, $data)
{
// Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
// Header
$w = array(40, 35, 40, 45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);
$this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);
$this->Ln();
$fill = !$fill;
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf = new PDF();
// Column headings
$header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)');
// Data loading
$data = $pdf->LoadData('countries.txt');
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->BasicTable($header,$data);
$pdf->AddPage();
$pdf->ImprovedTable($header,$data);
$pdf->AddPage();
$pdf->FancyTable($header,$data);
$pdf->Output();
?>
border
parameter of the Cell() method, which specifies which sides of the
cell must be drawn. Here we want the left (L
) and right (R
) ones. It remains
the problem of the horizontal line to finish the table. There are two possibilities: either
check for the last line in the loop, in which case we use LRB
for the border
parameter; or, as done here, add the line once the loop is over.
<?php
require('fpdf.php');
class PDF extends FPDF
{
protected $B = 0;
protected $I = 0;
protected $U = 0;
protected $HREF = '';
function WriteHTML($html)
{
// HTML parser
$html = str_replace("\n",' ',$html);
$a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
foreach($a as $i=>$e)
{
if($i%2==0)
{
// Text
if($this->HREF)
$this->PutLink($this->HREF,$e);
else
$this->Write(5,$e);
}
else
{
// Tag
if($e[0]=='/')
$this->CloseTag(strtoupper(substr($e,1)));
else
{
// Extract attributes
$a2 = explode(' ',$e);
$tag = strtoupper(array_shift($a2));
$attr = array();
foreach($a2 as $v)
{
if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
$attr[strtoupper($a3[1])] = $a3[2];
}
$this->OpenTag($tag,$attr);
}
}
}
}
function OpenTag($tag, $attr)
{
// Opening tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,true);
if($tag=='A')
$this->HREF = $attr['HREF'];
if($tag=='BR')
$this->Ln(5);
}
function CloseTag($tag)
{
// Closing tag
if($tag=='B' || $tag=='I' || $tag=='U')
$this->SetStyle($tag,false);
if($tag=='A')
$this->HREF = '';
}
function SetStyle($tag, $enable)
{
// Modify style and select corresponding font
$this->$tag += ($enable ? 1 : -1);
$style = '';
foreach(array('B', 'I', 'U') as $s)
{
if($this->$s>0)
$style .= $s;
}
$this->SetFont('',$style);
}
function PutLink($URL, $txt)
{
// Put a hyperlink
$this->SetTextColor(0,0,255);
$this->SetStyle('U',true);
$this->Write(5,$txt,$URL);
$this->SetStyle('U',false);
$this->SetTextColor(0);
}
}
$html = 'You can now easily print text mixing different styles: <b>bold</b>, <i>italic</i>,
<u>underlined</u>, or <b><i><u>all at once</u></i></b>!<br><br>You can also insert links on
text, such as <a href="http://www.fpdf.org">www.fpdf.org</a>, or on an image: click on the logo.';
$pdf = new PDF();
// First page
$pdf->AddPage();
$pdf->SetFont('Arial','',20);
$pdf->Write(5,"To find out what's new in this tutorial, click ");
$pdf->SetFont('','U');
$link = $pdf->AddLink();
$pdf->Write(5,'here',$link);
$pdf->SetFont('');
// Second page
$pdf->AddPage();
$pdf->SetLink($link);
$pdf->Image('logo.png',10,12,30,0,'','http://www.fpdf.org');
$pdf->SetLeftMargin(45);
$pdf->SetFontSize(14);
$pdf->WriteHTML($html);
$pdf->Output();
?>
MakeFont(string fontfile [, string enc [, boolean embed [, boolean subset]]])
fontfile
Path to the .ttf, .otf or .pfb file.
enc
Name of the encoding to use. Default value: cp1252
.
embed
Whether to embed the font or not. Default value: true
.
subset
Whether to subset the font or not. Default value: true
.
$file
in the .php file accordingly.
<?php
require('makefont/makefont.php');
MakeFont('C:\\Windows\\Fonts\\comic.ttf','cp1252');
?>
$pdf->AddFont('Comic','','comic.php');
$pdf->AddFont('Comic','B','comicbd.php');
<?php
require('makefont/makefont.php');
MakeFont('calligra.ttf','cp1252');
?>
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddFont('Calligrapher','','calligra.php');
$pdf->AddPage();
$pdf->SetFont('Calligrapher','',35);
$pdf->Write(10,'Enjoy new fonts with FPDF!');
$pdf->Output();
?>