Skip to content

Commit 413b570

Browse files
authored
Merge pull request #113 from mansoorkhan96/master
Upgrade Fpdf to v1.84
2 parents d733f2f + 66ec9bc commit 413b570

11 files changed

+200
-73
lines changed

src/Fpdf/FAQ.htm

+7-8
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@ <h1>FAQ</h1>
4646
<p><b>2.</b> <span class='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>
4747
You must send nothing to the browser except the PDF itself: no HTML, no space, no carriage return. A common
4848
case is having extra blank at the end of an included script file.<br>
49-
If you can't figure out where the problem comes from, this other message appearing just before can help you:<br>
49+
If you can't figure out where the problem comes from, this other message appearing just before will help you:<br>
5050
<br>
5151
<b>Warning:</b> Cannot modify header information - headers already sent by (output started at script.php:X)<br>
5252
<br>
53-
It means that script.php outputs something at line X. Go to this line and fix it.
54-
In case the message doesn't show, first check that you didn't disable warnings, then add this at the very
55-
beginning of your script:
53+
It means that script.php outputs something at line X. Go to that line and fix it.
54+
In case the message doesn't show, check if PHP warnings are enabled. If they are not, enable them. If they are,
55+
try adding this at the very beginning of your script:
5656
<div class="doc-source">
5757
<pre><code>ob_end_clean();</code></pre>
5858
</div>
59-
If you still don't see it, disable zlib.output_compression in your php.ini and it should appear.
6059
</li>
6160

6261
<li id='q3'>
@@ -213,7 +212,7 @@ <h1>FAQ</h1>
213212

214213
<li id='q15'>
215214
<p><b>15.</b> <span class='question'>How can I send the PDF by email?</span></p>
216-
As for any other file, but an easy way is to use <a href="http://phpmailer.codeworxtech.com" target="_blank">PHPMailer</a> and
215+
As for any other file, but an easy way is to use <a href="https://github.com/PHPMailer/PHPMailer" target="_blank">PHPMailer</a> and
217216
its in-memory attachment:
218217
<div class="doc-source">
219218
<pre><code>$mail = new PHPMailer();
@@ -251,12 +250,12 @@ <h1>FAQ</h1>
251250
<li id='q18'>
252251
<p><b>18.</b> <span class='question'>I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?</span></p>
253252
No. But a GPL C utility does exist, pdftotext, which is able to extract the textual content from a PDF.
254-
It's provided with the <a href="http://www.foolabs.com/xpdf/" target="_blank">Xpdf</a> package.
253+
It's provided with the <a href="https://www.xpdfreader.com" target="_blank">Xpdf</a> package.
255254
</li>
256255

257256
<li id='q19'>
258257
<p><b>19.</b> <span class='question'>Can I convert an HTML page to PDF with FPDF?</span></p>
259-
Not real-world pages. But a GPL C utility does exist, <a href="https://www.msweet.org/projects.php?Z1" target="_blank">HTMLDOC</a>,
258+
Not real-world pages. But a GPL C utility does exist, <a href="https://www.msweet.org/htmldoc/" target="_blank">HTMLDOC</a>,
260259
which allows to do it and gives good results.
261260
</li>
262261

src/Fpdf/Fpdf.php

+44-29
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
/*******************************************************************************
33
* FPDF *
44
* *
5-
* Version: 1.82 *
6-
* Date: 2019-12-07 *
5+
* Version: 1.84 *
6+
* Date: 2021-08-28 *
77
* Author: Olivier PLATHEY *
88
*******************************************************************************/
99

10-
define('FPDF_VERSION','1.82');
10+
define('FPDF_VERSION','1.84');
1111

1212
class Fpdf
1313
{
@@ -1090,6 +1090,7 @@ protected function _beginpage($orientation, $size, $rotation)
10901090
{
10911091
$this->page++;
10921092
$this->pages[$this->page] = '';
1093+
$this->PageLinks[$this->page] = array();
10931094
$this->state = 2;
10941095
$this->x = $this->lMargin;
10951096
$this->y = $this->tMargin;
@@ -1507,27 +1508,13 @@ protected function _putpage($n)
15071508
if(isset($this->PageInfo[$n]['rotation']))
15081509
$this->_put('/Rotate '.$this->PageInfo[$n]['rotation']);
15091510
$this->_put('/Resources 2 0 R');
1510-
if(isset($this->PageLinks[$n]))
1511+
if(!empty($this->PageLinks[$n]))
15111512
{
1512-
// Links
1513-
$annots = '/Annots [';
1513+
$s = '/Annots [';
15141514
foreach($this->PageLinks[$n] as $pl)
1515-
{
1516-
$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1517-
$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1518-
if(is_string($pl[4]))
1519-
$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1520-
else
1521-
{
1522-
$l = $this->links[$pl[4]];
1523-
if(isset($this->PageInfo[$l[0]]['size']))
1524-
$h = $this->PageInfo[$l[0]]['size'][1];
1525-
else
1526-
$h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k;
1527-
$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k);
1528-
}
1529-
}
1530-
$this->_put($annots.']');
1515+
$s .= $pl[5].' 0 R ';
1516+
$s .= ']';
1517+
$this->_put($s);
15311518
}
15321519
if($this->WithAlpha)
15331520
$this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
@@ -1537,22 +1524,50 @@ protected function _putpage($n)
15371524
if(!empty($this->AliasNbPages))
15381525
$this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]);
15391526
$this->_putstreamobject($this->pages[$n]);
1527+
// Annotations
1528+
foreach($this->PageLinks[$n] as $pl)
1529+
{
1530+
$this->_newobj();
1531+
$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
1532+
$s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
1533+
if(is_string($pl[4]))
1534+
$s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
1535+
else
1536+
{
1537+
$l = $this->links[$pl[4]];
1538+
if(isset($this->PageInfo[$l[0]]['size']))
1539+
$h = $this->PageInfo[$l[0]]['size'][1];
1540+
else
1541+
$h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k;
1542+
$s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k);
1543+
}
1544+
$this->_put($s);
1545+
$this->_put('endobj');
1546+
}
15401547
}
15411548

15421549
protected function _putpages()
15431550
{
15441551
$nb = $this->page;
1545-
for($n=1;$n<=$nb;$n++)
1546-
$this->PageInfo[$n]['n'] = $this->n+1+2*($n-1);
1547-
for($n=1;$n<=$nb;$n++)
1548-
$this->_putpage($n);
1552+
$n = $this->n;
1553+
for($i=1;$i<=$nb;$i++)
1554+
{
1555+
$this->PageInfo[$i]['n'] = ++$n;
1556+
$n++;
1557+
foreach($this->PageLinks[$i] as &$pl)
1558+
$pl[5] = ++$n;
1559+
unset($pl);
1560+
}
1561+
for($i=1;$i<=$nb;$i++)
1562+
$this->_putpage($i);
15491563
// Pages root
15501564
$this->_newobj(1);
15511565
$this->_put('<</Type /Pages');
15521566
$kids = '/Kids [';
1553-
for($n=1;$n<=$nb;$n++)
1554-
$kids .= $this->PageInfo[$n]['n'].' 0 R ';
1555-
$this->_put($kids.']');
1567+
for($i=1;$i<=$nb;$i++)
1568+
$kids .= $this->PageInfo[$i]['n'].' 0 R ';
1569+
$kids .= ']';
1570+
$this->_put($kids);
15561571
$this->_put('/Count '.$nb);
15571572
if($this->DefOrientation=='P')
15581573
{

src/Fpdf/changelog.htm

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
<body>
1212
<h1>Changelog</h1>
1313
<dl>
14+
<dt><strong>v1.84</strong> (2021-08-28)</dt>
15+
<dd>
16+
- Fixed an issue related to annotations.<br>
17+
</dd>
18+
<dt><strong>v1.83</strong> (2021-04-18)</dt>
19+
<dd>
20+
- Fixed an issue related to annotations.<br>
21+
</dd>
22+
<dt><strong>v1.82</strong> (2019-12-07)</dt>
23+
<dd>
24+
- Removed a deprecation notice under PHP 7.4.<br>
25+
</dd>
1426
<dt><strong>v1.81</strong> (2015-12-20)</dt>
1527
<dd>
1628
- Added GetPageWidth() and GetPageHeight().<br>

src/Fpdf/makefont/makefont.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/*******************************************************************************
33
* Utility to generate font definition files *
44
* *
5-
* Version: 1.3 *
6-
* Date: 2015-11-29 *
5+
* Version: 1.31 *
6+
* Date: 2019-12-07 *
77
* Author: Olivier PLATHEY *
88
*******************************************************************************/
99

@@ -67,7 +67,7 @@ function GetInfoFromTrueType($file, $embed, $subset, $map)
6767
$ttf = new TTFParser($file);
6868
$ttf->Parse();
6969
}
70-
catch(\Exception $e)
70+
catch(Exception $e)
7171
{
7272
Error($e->getMessage());
7373
}
@@ -384,10 +384,6 @@ function MakeDefinitionFile($file, $type, $enc, $embed, $subset, $map, $info)
384384
function MakeFont($fontfile, $enc='cp1252', $embed=true, $subset=true)
385385
{
386386
// Generate a font definition file
387-
if(get_magic_quotes_runtime())
388-
@set_magic_quotes_runtime(false);
389-
ini_set('auto_detect_line_endings', '1');
390-
391387
if(!file_exists($fontfile))
392388
Error('Font file not found: '.$fontfile);
393389
$ext = strtolower(substr($fontfile,-3));

src/Fpdf/makefont/ttfparser.php

+5-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/*******************************************************************************
33
* Class to parse and subset TrueType fonts *
44
* *
5-
* Version: 1.1 *
6-
* Date: 2015-11-29 *
5+
* Version: 1.11 *
6+
* Date: 2021-04-18 *
77
* Author: Olivier PLATHEY *
88
*******************************************************************************/
99

@@ -75,10 +75,10 @@ function ParseOffsetTable()
7575
$tag = $this->Read(4);
7676
$checkSum = $this->Read(4);
7777
$offset = $this->ReadULong();
78-
$length = $this->ReadULong(4);
78+
$length = $this->ReadULong();
7979
$this->tables[$tag] = array('offset'=>$offset, 'length'=>$length, 'checkSum'=>$checkSum);
8080
}
81-
}
81+
}
8282

8383
function ParseHead()
8484
{
@@ -354,15 +354,7 @@ function ParsePost()
354354

355355
function Subset($chars)
356356
{
357-
/* $chars = array_keys($this->chars);
358-
$this->subsettedChars = $chars;
359357
$this->subsettedGlyphs = array();
360-
for($i=0;$i<$this->numGlyphs;$i++)
361-
{
362-
$this->subsettedGlyphs[] = $i;
363-
$this->glyphs[$i]['ssid'] = $i;
364-
}*/
365-
366358
$this->AddGlyph(0);
367359
$this->subsettedChars = array();
368360
foreach($chars as $char)
@@ -607,7 +599,6 @@ function BuildFont()
607599
$this->tables[$tag]['offset'] = $offset;
608600
$offset += strlen($this->tables[$tag]['data']);
609601
}
610-
// $this->tables['head']['data'] = substr_replace($this->tables['head']['data'], "\x00\x00\x00\x00", 8, 4);
611602

612603
// Build offset table
613604
$entrySelector = 0;
@@ -717,7 +708,7 @@ function CheckSum($s)
717708

718709
function Error($msg)
719710
{
720-
throw new \Exception($msg);
711+
throw new Exception($msg);
721712
}
722713
}
723714
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Copyright (c) 2011 by LatinoType Limitada ([email protected]),
2+
with Reserved Font Names "Cecivhe" and "Ceviche One"
3+
4+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
5+
This license is copied below, and is also available with a FAQ at:
6+
http://scripts.sil.org/OFL
7+
8+
9+
-----------------------------------------------------------
10+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11+
-----------------------------------------------------------
12+
13+
PREAMBLE
14+
The goals of the Open Font License (OFL) are to stimulate worldwide
15+
development of collaborative font projects, to support the font creation
16+
efforts of academic and linguistic communities, and to provide a free and
17+
open framework in which fonts may be shared and improved in partnership
18+
with others.
19+
20+
The OFL allows the licensed fonts to be used, studied, modified and
21+
redistributed freely as long as they are not sold by themselves. The
22+
fonts, including any derivative works, can be bundled, embedded,
23+
redistributed and/or sold with any software provided that any reserved
24+
names are not used by derivative works. The fonts and derivatives,
25+
however, cannot be released under any other type of license. The
26+
requirement for fonts to remain under this license does not apply
27+
to any document created using the fonts or their derivatives.
28+
29+
DEFINITIONS
30+
"Font Software" refers to the set of files released by the Copyright
31+
Holder(s) under this license and clearly marked as such. This may
32+
include source files, build scripts and documentation.
33+
34+
"Reserved Font Name" refers to any names specified as such after the
35+
copyright statement(s).
36+
37+
"Original Version" refers to the collection of Font Software components as
38+
distributed by the Copyright Holder(s).
39+
40+
"Modified Version" refers to any derivative made by adding to, deleting,
41+
or substituting -- in part or in whole -- any of the components of the
42+
Original Version, by changing formats or by porting the Font Software to a
43+
new environment.
44+
45+
"Author" refers to any designer, engineer, programmer, technical
46+
writer or other person who contributed to the Font Software.
47+
48+
PERMISSION & CONDITIONS
49+
Permission is hereby granted, free of charge, to any person obtaining
50+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
51+
redistribute, and sell modified and unmodified copies of the Font
52+
Software, subject to the following conditions:
53+
54+
1) Neither the Font Software nor any of its individual components,
55+
in Original or Modified Versions, may be sold by itself.
56+
57+
2) Original or Modified Versions of the Font Software may be bundled,
58+
redistributed and/or sold with any software, provided that each copy
59+
contains the above copyright notice and this license. These can be
60+
included either as stand-alone text files, human-readable headers or
61+
in the appropriate machine-readable metadata fields within text or
62+
binary files as long as those fields can be easily viewed by the user.
63+
64+
3) No Modified Version of the Font Software may use the Reserved Font
65+
Name(s) unless explicit written permission is granted by the corresponding
66+
Copyright Holder. This restriction only applies to the primary font name as
67+
presented to the users.
68+
69+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70+
Software shall not be used to promote, endorse or advertise any
71+
Modified Version, except to acknowledge the contribution(s) of the
72+
Copyright Holder(s) and the Author(s) or with their explicit written
73+
permission.
74+
75+
5) The Font Software, modified or unmodified, in part or in whole,
76+
must be distributed entirely under this license, and must not be
77+
distributed under any other license. The requirement for fonts to
78+
remain under this license does not apply to any document created
79+
using the Font Software.
80+
81+
TERMINATION
82+
This license becomes null and void if any of the above conditions are
83+
not met.
84+
85+
DISCLAIMER
86+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94+
OTHER DEALINGS IN THE FONT SOFTWARE.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
$type = 'TrueType';
3+
$name = 'CevicheOne-Regular';
4+
$desc = array('Ascent'=>806,'Descent'=>-237,'CapHeight'=>425,'Flags'=>32,'FontBBox'=>'[-42 -237 1427 806]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>294);
5+
$up = -75;
6+
$ut = 50;
7+
$cw = array(
8+
chr(0)=>294,chr(1)=>294,chr(2)=>294,chr(3)=>294,chr(4)=>294,chr(5)=>294,chr(6)=>294,chr(7)=>294,chr(8)=>294,chr(9)=>294,chr(10)=>294,chr(11)=>294,chr(12)=>294,chr(13)=>294,chr(14)=>294,chr(15)=>294,chr(16)=>294,chr(17)=>294,chr(18)=>294,chr(19)=>294,chr(20)=>294,chr(21)=>294,
9+
chr(22)=>294,chr(23)=>294,chr(24)=>294,chr(25)=>294,chr(26)=>294,chr(27)=>294,chr(28)=>294,chr(29)=>294,chr(30)=>294,chr(31)=>294,' '=>130,'!'=>254,'"'=>334,'#'=>496,'$'=>469,'%'=>765,'&'=>761,'\''=>148,'('=>268,')'=>269,'*'=>435,'+'=>442,
10+
','=>235,'-'=>339,'.'=>233,'/'=>301,'0'=>512,'1'=>252,'2'=>501,'3'=>471,'4'=>537,'5'=>471,'6'=>501,'7'=>424,'8'=>506,'9'=>502,':'=>292,';'=>299,'<'=>463,'='=>483,'>'=>459,'?'=>453,'@'=>672,'A'=>511,
11+
'B'=>573,'C'=>480,'D'=>541,'E'=>507,'F'=>490,'G'=>515,'H'=>517,'I'=>250,'J'=>270,'K'=>570,'L'=>368,'M'=>620,'N'=>548,'O'=>507,'P'=>540,'Q'=>532,'R'=>552,'S'=>490,'T'=>434,'U'=>527,'V'=>514,'W'=>670,
12+
'X'=>541,'Y'=>497,'Z'=>499,'['=>288,'\\'=>472,']'=>288,'^'=>448,'_'=>350,'`'=>449,'a'=>446,'b'=>454,'c'=>394,'d'=>462,'e'=>404,'f'=>332,'g'=>458,'h'=>446,'i'=>234,'j'=>232,'k'=>457,'l'=>231,'m'=>659,
13+
'n'=>450,'o'=>412,'p'=>436,'q'=>468,'r'=>389,'s'=>394,'t'=>318,'u'=>458,'v'=>421,'w'=>612,'x'=>450,'y'=>429,'z'=>423,'{'=>312,'|'=>231,'}'=>312,'~'=>504,chr(127)=>294,chr(128)=>586,chr(129)=>294,chr(130)=>176,chr(131)=>377,
14+
chr(132)=>361,chr(133)=>761,chr(134)=>422,chr(135)=>425,chr(136)=>448,chr(137)=>1050,chr(138)=>490,chr(139)=>377,chr(140)=>787,chr(141)=>294,chr(142)=>499,chr(143)=>294,chr(144)=>294,chr(145)=>171,chr(146)=>148,chr(147)=>357,chr(148)=>334,chr(149)=>266,chr(150)=>444,chr(151)=>554,chr(152)=>416,chr(153)=>608,
15+
chr(154)=>394,chr(155)=>378,chr(156)=>674,chr(157)=>294,chr(158)=>423,chr(159)=>497,chr(160)=>130,chr(161)=>253,chr(162)=>424,chr(163)=>510,chr(164)=>665,chr(165)=>551,chr(166)=>252,chr(167)=>413,chr(168)=>505,chr(169)=>675,chr(170)=>361,chr(171)=>668,chr(172)=>548,chr(173)=>440,chr(174)=>676,chr(175)=>413,
16+
chr(176)=>278,chr(177)=>438,chr(178)=>328,chr(179)=>318,chr(180)=>449,chr(181)=>463,chr(182)=>535,chr(183)=>234,chr(184)=>535,chr(185)=>176,chr(186)=>322,chr(187)=>669,chr(188)=>761,chr(189)=>710,chr(190)=>904,chr(191)=>452,chr(192)=>511,chr(193)=>511,chr(194)=>514,chr(195)=>511,chr(196)=>511,chr(197)=>511,
17+
chr(198)=>787,chr(199)=>480,chr(200)=>507,chr(201)=>507,chr(202)=>507,chr(203)=>507,chr(204)=>250,chr(205)=>250,chr(206)=>271,chr(207)=>272,chr(208)=>542,chr(209)=>548,chr(210)=>507,chr(211)=>507,chr(212)=>507,chr(213)=>507,chr(214)=>507,chr(215)=>496,chr(216)=>507,chr(217)=>527,chr(218)=>527,chr(219)=>526,
18+
chr(220)=>527,chr(221)=>497,chr(222)=>522,chr(223)=>457,chr(224)=>446,chr(225)=>446,chr(226)=>446,chr(227)=>446,chr(228)=>446,chr(229)=>446,chr(230)=>635,chr(231)=>394,chr(232)=>404,chr(233)=>404,chr(234)=>412,chr(235)=>401,chr(236)=>235,chr(237)=>235,chr(238)=>256,chr(239)=>249,chr(240)=>475,chr(241)=>450,
19+
chr(242)=>412,chr(243)=>412,chr(244)=>412,chr(245)=>413,chr(246)=>412,chr(247)=>444,chr(248)=>412,chr(249)=>458,chr(250)=>458,chr(251)=>458,chr(252)=>458,chr(253)=>429,chr(254)=>452,chr(255)=>429);
20+
$enc = 'cp1252';
21+
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
22+
$file = 'CevicheOne-Regular.z';
23+
$originalsize = 25916;
24+
$subsetted = true;
25+
?>
34.7 KB
Binary file not shown.
15.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)