diff --git a/fpdf/FAQ.htm b/fpdf/FAQ.htm index cb2c3d3..a4abc2c 100644 --- a/fpdf/FAQ.htm +++ b/fpdf/FAQ.htm @@ -46,17 +46,16 @@

FAQ

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.
-If you can't figure out where the problem comes from, this other message appearing just before can help you:
+If you can't figure out where the problem comes from, this other message appearing just before will help you:

Warning: Cannot modify header information - headers already sent by (output started at script.php:X)

-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: +It means that script.php outputs something at line X. Go to that line and fix it. +In case the message doesn't show, check if PHP warnings are enabled. If they are not, enable them. If they are, +try adding this at the very beginning of your script:
ob_end_clean();
-If you still don't see it, disable zlib.output_compression in your php.ini and it should appear.
  • diff --git a/fpdf/changelog.htm b/fpdf/changelog.htm index 1f6e494..7a9913b 100644 --- a/fpdf/changelog.htm +++ b/fpdf/changelog.htm @@ -11,6 +11,10 @@

    Changelog

    +
    v1.83 (2021-04-18)
    +
    +- Fixed an issue related to annotations.
    +
    v1.82 (2019-12-07)
    - Removed a deprecation notice under PHP 7.4.
    diff --git a/fpdf/doc/index.htm b/fpdf/doc/index.htm index c517567..36521c4 100644 --- a/fpdf/doc/index.htm +++ b/fpdf/doc/index.htm @@ -2,11 +2,11 @@ -FPDF 1.82 Reference Manual +FPDF 1.83 Reference Manual -

    FPDF 1.82 Reference Manual

    +

    FPDF 1.83 Reference Manual

    __construct - constructor
    AcceptPageBreak - accept or not automatic page break
    AddFont - add a new font
    diff --git a/fpdf/fpdf.php b/fpdf/fpdf.php index 60f8d41..5e46cde 100644 --- a/fpdf/fpdf.php +++ b/fpdf/fpdf.php @@ -2,12 +2,12 @@ /******************************************************************************* * FPDF * * * -* Version: 1.82 * -* Date: 2019-12-07 * +* Version: 1.83 * +* Date: 2021-04-18 * * Author: Olivier PLATHEY * *******************************************************************************/ -define('FPDF_VERSION','1.82'); +define('FPDF_VERSION','1.83'); class FPDF { @@ -1084,6 +1084,7 @@ protected function _beginpage($orientation, $size, $rotation) { $this->page++; $this->pages[$this->page] = ''; + $this->PageLinks[$this->page] = array(); $this->state = 2; $this->x = $this->lMargin; $this->y = $this->tMargin; @@ -1501,27 +1502,13 @@ protected function _putpage($n) if(isset($this->PageInfo[$n]['rotation'])) $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); $this->_put('/Resources 2 0 R'); - if(isset($this->PageLinks[$n])) + if(!empty($this->PageLinks[$n])) { - // Links - $annots = '/Annots ['; + $s = '/Annots ['; foreach($this->PageLinks[$n] as $pl) - { - $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); - $annots .= '<_textstring($pl[4]).'>>>>'; - else - { - $l = $this->links[$pl[4]]; - if(isset($this->PageInfo[$l[0]]['size'])) - $h = $this->PageInfo[$l[0]]['size'][1]; - else - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; - $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); - } - } - $this->_put($annots.']'); + $s .= $pl[5].' 0 R '; + $s .= ']'; + $this->_put($s); } if($this->WithAlpha) $this->_put('/Group <>'); @@ -1531,22 +1518,50 @@ protected function _putpage($n) if(!empty($this->AliasNbPages)) $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); $this->_putstreamobject($this->pages[$n]); + // Annotations + foreach($this->PageLinks[$n] as $pl) + { + $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); + $s = '<_textstring($pl[4]).'>>>>'; + else + { + $l = $this->links[$pl[4]]; + if(isset($this->PageInfo[$l[0]]['size'])) + $h = $this->PageInfo[$l[0]]['size'][1]; + else + $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; + $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); + } + $this->_newobj(); + $this->_put($s); + $this->_put('endobj'); + } } protected function _putpages() { $nb = $this->page; - for($n=1;$n<=$nb;$n++) - $this->PageInfo[$n]['n'] = $this->n+1+2*($n-1); - for($n=1;$n<=$nb;$n++) - $this->_putpage($n); + $n = $this->n; + for($i=1;$i<=$nb;$i++) + { + $this->PageInfo[$i]['n'] = ++$n; + $n++; + foreach($this->PageLinks[$i] as &$pl) + $pl[5] = ++$n; + unset($pl); + } + for($i=1;$i<=$nb;$i++) + $this->_putpage($i); // Pages root $this->_newobj(1); $this->_put('<PageInfo[$n]['n'].' 0 R '; - $this->_put($kids.']'); + for($i=1;$i<=$nb;$i++) + $kids .= $this->PageInfo[$i]['n'].' 0 R '; + $kids .= ']'; + $this->_put($kids); $this->_put('/Count '.$nb); if($this->DefOrientation=='P') { diff --git a/fpdf/makefont/ttfparser.php b/fpdf/makefont/ttfparser.php index 56c46a4..1ec1276 100644 --- a/fpdf/makefont/ttfparser.php +++ b/fpdf/makefont/ttfparser.php @@ -2,8 +2,8 @@ /******************************************************************************* * Class to parse and subset TrueType fonts * * * -* Version: 1.1 * -* Date: 2015-11-29 * +* Version: 1.11 * +* Date: 2021-04-18 * * Author: Olivier PLATHEY * *******************************************************************************/ @@ -75,7 +75,7 @@ function ParseOffsetTable() $tag = $this->Read(4); $checkSum = $this->Read(4); $offset = $this->ReadULong(); - $length = $this->ReadULong(4); + $length = $this->ReadULong(); $this->tables[$tag] = array('offset'=>$offset, 'length'=>$length, 'checkSum'=>$checkSum); } } @@ -354,15 +354,7 @@ function ParsePost() function Subset($chars) { -/* $chars = array_keys($this->chars); - $this->subsettedChars = $chars; $this->subsettedGlyphs = array(); - for($i=0;$i<$this->numGlyphs;$i++) - { - $this->subsettedGlyphs[] = $i; - $this->glyphs[$i]['ssid'] = $i; - }*/ - $this->AddGlyph(0); $this->subsettedChars = array(); foreach($chars as $char) @@ -607,7 +599,6 @@ function BuildFont() $this->tables[$tag]['offset'] = $offset; $offset += strlen($this->tables[$tag]['data']); } -// $this->tables['head']['data'] = substr_replace($this->tables['head']['data'], "\x00\x00\x00\x00", 8, 4); // Build offset table $entrySelector = 0;