update fpdf to 1.86

This commit is contained in:
Sebijk 2023-08-06 13:22:54 +02:00
parent e86c54a7cb
commit 4206e26ccb
3 changed files with 30 additions and 26 deletions

6
src/serverlib/3rdparty/fpdf/FAQ.htm vendored Normal file → Executable file
View file

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FAQ</title> <title>FAQ</title>
<link type="text/css" rel="stylesheet" href="fpdf.css"> <link type="text/css" rel="stylesheet" href="fpdf.css">
<style type="text/css"> <style type="text/css">
@ -15,7 +15,7 @@ ul#answers li {margin-top:1.8em}
<ul> <ul>
<li><b>1.</b> <a href='#q1'>What's exactly the license of FPDF? Are there any usage restrictions?</a></li> <li><b>1.</b> <a href='#q1'>What's exactly the license of FPDF? Are there any usage restrictions?</a></li>
<li><b>2.</b> <a href='#q2'>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>2.</b> <a href='#q2'>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>3.</b> <a href='#q3'>Accented letters are replaced with some strange characters like é.</a></li> <li><b>3.</b> <a href='#q3'>Accented letters are replaced by some strange characters like é.</a></li>
<li><b>4.</b> <a href='#q4'>I try to display the Euro symbol but it doesn't work.</a></li> <li><b>4.</b> <a href='#q4'>I try to display the Euro symbol but it doesn't work.</a></li>
<li><b>5.</b> <a href='#q5'>I try to display a variable in the Header method but nothing prints.</a></li> <li><b>5.</b> <a href='#q5'>I try to display a variable in the Header method but nothing prints.</a></li>
<li><b>6.</b> <a href='#q6'>I have defined the Header and Footer methods in my PDF class but nothing shows.</a></li> <li><b>6.</b> <a href='#q6'>I have defined the Header and Footer methods in my PDF class but nothing shows.</a></li>
@ -59,7 +59,7 @@ try adding this line at the very beginning of your script:
</li> </li>
<li id='q3'> <li id='q3'>
<p><b>3.</b> <span class='question'>Accented letters are replaced with some strange characters like é.</span></p> <p><b>3.</b> <span class='question'>Accented letters are replaced by some strange characters like é.</span></p>
Don't use UTF-8 with the standard fonts; they expect text encoded in windows-1252. Don't use UTF-8 with the standard fonts; they expect text encoded in windows-1252.
You can perform a conversion with iconv: You can perform a conversion with iconv:
<div class="doc-source"> <div class="doc-source">

7
src/serverlib/3rdparty/fpdf/changelog.htm vendored Normal file → Executable file
View file

@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Changelog</title> <title>Changelog</title>
<link type="text/css" rel="stylesheet" href="fpdf.css"> <link type="text/css" rel="stylesheet" href="fpdf.css">
<style type="text/css"> <style type="text/css">
@ -11,6 +11,11 @@ dd {margin:1em 0 1em 1em}
<body> <body>
<h1>Changelog</h1> <h1>Changelog</h1>
<dl> <dl>
<dt><strong>v1.86</strong> (2023-06-25)</dt>
<dd>
- Added a parameter to AddFont() to specify the directory where to load the font definition file.<br>
- Fixed a bug related to the PDF creation date.<br>
</dd>
<dt><strong>v1.85</strong> (2022-11-10)</dt> <dt><strong>v1.85</strong> (2022-11-10)</dt>
<dd> <dd>
- Removed deprecation notices on PHP 8.2.<br> - Removed deprecation notices on PHP 8.2.<br>

43
src/serverlib/3rdparty/fpdf/fpdf.php vendored Normal file → Executable file
View file

@ -2,14 +2,14 @@
/******************************************************************************* /*******************************************************************************
* FPDF * * FPDF *
* * * *
* Version: 1.85 * * Version: 1.86 *
* Date: 2022-11-10 * * Date: 2023-06-25 *
* Author: Olivier PLATHEY * * Author: Olivier PLATHEY *
*******************************************************************************/ *******************************************************************************/
class FPDF class FPDF
{ {
const VERSION = '1.85'; const VERSION = '1.86';
protected $page; // current page number protected $page; // current page number
protected $n; // current object number protected $n; // current object number
protected $offsets; // array of object offsets protected $offsets; // array of object offsets
@ -36,7 +36,7 @@ protected $cMargin; // cell margin
protected $x, $y; // current position in user unit protected $x, $y; // current position in user unit
protected $lasth; // height of last printed cell protected $lasth; // height of last printed cell
protected $LineWidth; // line width in user unit protected $LineWidth; // line width in user unit
protected $fontpath; // path containing fonts protected $fontpath; // directory containing fonts
protected $CoreFonts; // array of core font names protected $CoreFonts; // array of core font names
protected $fonts; // array of used fonts protected $fonts; // array of used fonts
protected $FontFiles; // array of font files protected $FontFiles; // array of font files
@ -103,15 +103,9 @@ function __construct($orientation='P', $unit='mm', $size='A4')
$this->iconv = function_exists('iconv'); $this->iconv = function_exists('iconv');
// Font path // Font path
if(defined('FPDF_FONTPATH')) if(defined('FPDF_FONTPATH'))
{
$this->fontpath = FPDF_FONTPATH; $this->fontpath = FPDF_FONTPATH;
if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
$this->fontpath .= '/';
}
elseif(is_dir(dirname(__FILE__).'/font'))
$this->fontpath = dirname(__FILE__).'/font/';
else else
$this->fontpath = ''; $this->fontpath = dirname(__FILE__).'/font/';
// Core fonts // Core fonts
$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
// Scale factor // Scale factor
@ -446,7 +440,7 @@ function Rect($x, $y, $w, $h, $style='')
$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
} }
function AddFont($family, $style='', $file='') function AddFont($family, $style='', $file='', $dir='')
{ {
// Add a TrueType, OpenType or Type1 font // Add a TrueType, OpenType or Type1 font
$family = strtolower($family); $family = strtolower($family);
@ -458,11 +452,18 @@ function AddFont($family, $style='', $file='')
$fontkey = $family.$style; $fontkey = $family.$style;
if(isset($this->fonts[$fontkey])) if(isset($this->fonts[$fontkey]))
return; return;
$info = $this->_loadfont($file); if(strpos($file,'/')!==false || strpos($file,"\\")!==false)
$this->Error('Incorrect font definition file name: '.$file);
if($dir=='')
$dir = $this->fontpath;
if(substr($dir,-1)!='/' && substr($dir,-1)!='\\')
$dir .= '/';
$info = $this->_loadfont($dir.$file);
$info['i'] = count($this->fonts)+1; $info['i'] = count($this->fonts)+1;
if(!empty($info['file'])) if(!empty($info['file']))
{ {
// Embedded font // Embedded font
$info['file'] = $dir.$info['file'];
if($info['type']=='TrueType') if($info['type']=='TrueType')
$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
else else
@ -1130,14 +1131,12 @@ protected function _endpage()
$this->state = 1; $this->state = 1;
} }
protected function _loadfont($font) protected function _loadfont($path)
{ {
// Load a font definition file from the font directory // Load a font definition file
if(strpos($font,'/')!==false || strpos($font,"\\")!==false) include($path);
$this->Error('Incorrect font definition file name: '.$font);
include($this->fontpath.$font);
if(!isset($name)) if(!isset($name))
$this->Error('Could not include font definition file'); $this->Error('Could not include font definition file: '.$path);
if(isset($enc)) if(isset($enc))
$enc = strtolower($enc); $enc = strtolower($enc);
if(!isset($subsetted)) if(!isset($subsetted))
@ -1609,7 +1608,7 @@ protected function _putfonts()
// Font file embedding // Font file embedding
$this->_newobj(); $this->_newobj();
$this->FontFiles[$file]['n'] = $this->n; $this->FontFiles[$file]['n'] = $this->n;
$font = file_get_contents($this->fontpath.$file,true); $font = file_get_contents($file);
if(!$font) if(!$font)
$this->Error('Font file not found: '.$file); $this->Error('Font file not found: '.$file);
$compressed = (substr($file,-2)=='.z'); $compressed = (substr($file,-2)=='.z');
@ -1857,7 +1856,7 @@ protected function _putresources()
protected function _putinfo() protected function _putinfo()
{ {
$date = @date('YmdHisO', $this->CreationDate); $date = @date('YmdHisO',$this->CreationDate);
$this->metadata['CreationDate'] = 'D:'.substr($date,0,-2)."'".substr($date,-2)."'"; $this->metadata['CreationDate'] = 'D:'.substr($date,0,-2)."'".substr($date,-2)."'";
foreach($this->metadata as $key=>$value) foreach($this->metadata as $key=>$value)
$this->_put('/'.$key.' '.$this->_textstring($value)); $this->_put('/'.$key.' '.$this->_textstring($value));
@ -1898,6 +1897,7 @@ protected function _puttrailer()
protected function _enddoc() protected function _enddoc()
{ {
$this->CreationDate = time();
$this->_putheader(); $this->_putheader();
$this->_putpages(); $this->_putpages();
$this->_putresources(); $this->_putresources();
@ -1929,7 +1929,6 @@ protected function _enddoc()
$this->_put($offset); $this->_put($offset);
$this->_put('%%EOF'); $this->_put('%%EOF');
$this->state = 3; $this->state = 3;
$this->CreationDate = time();
} }
} }
?> ?>