FIX #4207
This commit is contained in:
parent
bf15ff56e7
commit
40963f2f2a
@ -74,10 +74,10 @@ class FPDF_TPL extends FPDF {
|
|||||||
* @return int The ID of new created Template
|
* @return int The ID of new created Template
|
||||||
*/
|
*/
|
||||||
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
|
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
|
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->page <= 0)
|
if ($this->page <= 0)
|
||||||
$this->error("You have to add a page to fpdf first!");
|
$this->error("You have to add a page to fpdf first!");
|
||||||
@ -127,9 +127,9 @@ class FPDF_TPL extends FPDF {
|
|||||||
|
|
||||||
if ($this->CurrentFont) {
|
if ($this->CurrentFont) {
|
||||||
$fontkey = $this->FontFamily . $this->FontStyle;
|
$fontkey = $this->FontFamily . $this->FontStyle;
|
||||||
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
|
||||||
|
|
||||||
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
|
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
@ -143,9 +143,9 @@ class FPDF_TPL extends FPDF {
|
|||||||
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
|
||||||
*/
|
*/
|
||||||
function endTemplate() {
|
function endTemplate() {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
|
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl) {
|
if ($this->_intpl) {
|
||||||
@ -160,13 +160,13 @@ class FPDF_TPL extends FPDF {
|
|||||||
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
|
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
|
||||||
|
|
||||||
$this->FontFamily = $tpl['o_FontFamily'];
|
$this->FontFamily = $tpl['o_FontFamily'];
|
||||||
$this->FontStyle = $tpl['o_FontStyle'];
|
$this->FontStyle = $tpl['o_FontStyle'];
|
||||||
$this->FontSizePt = $tpl['o_FontSizePt'];
|
$this->FontSizePt = $tpl['o_FontSizePt'];
|
||||||
$this->FontSize = $tpl['o_FontSize'];
|
$this->FontSize = $tpl['o_FontSize'];
|
||||||
|
|
||||||
$fontkey = $this->FontFamily . $this->FontStyle;
|
$fontkey = $this->FontFamily . $this->FontStyle;
|
||||||
if ($fontkey)
|
if ($fontkey)
|
||||||
$this->CurrentFont =& $this->fonts[$fontkey];
|
$this->CurrentFont =& $this->fonts[$fontkey];
|
||||||
|
|
||||||
return $this->tpl;
|
return $this->tpl;
|
||||||
} else {
|
} else {
|
||||||
@ -193,7 +193,7 @@ class FPDF_TPL extends FPDF {
|
|||||||
*/
|
*/
|
||||||
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
|
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
|
||||||
if ($this->page <= 0)
|
if ($this->page <= 0)
|
||||||
$this->error('You have to add a page first!');
|
$this->error('You have to add a page first!');
|
||||||
|
|
||||||
if (!isset($this->tpls[$tplidx]))
|
if (!isset($this->tpls[$tplidx]))
|
||||||
$this->error('Template does not exist!');
|
$this->error('Template does not exist!');
|
||||||
@ -261,10 +261,10 @@ class FPDF_TPL extends FPDF {
|
|||||||
$_h = $h;
|
$_h = $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_w == 0)
|
if($_w == 0)
|
||||||
$_w = $_h * $w / $h;
|
$_w = $_h * $w / $h;
|
||||||
if($_h == 0)
|
if($_h == 0)
|
||||||
$_h = $_w * $h / $w;
|
$_h = $_w * $h / $w;
|
||||||
|
|
||||||
return array("w" => $_w, "h" => $_h);
|
return array("w" => $_w, "h" => $_h);
|
||||||
}
|
}
|
||||||
@ -272,10 +272,10 @@ class FPDF_TPL extends FPDF {
|
|||||||
/**
|
/**
|
||||||
* See FPDF/TCPDF-Documentation ;-)
|
* See FPDF/TCPDF-Documentation ;-)
|
||||||
*/
|
*/
|
||||||
public function SetFont($family, $style = '', $size = 0) {
|
public function SetFont($family, $style = '', $size = 0, $fontfile='', $subset='default', $out=true) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
|
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::SetFont($family, $style, $size);
|
parent::SetFont($family, $style, $size);
|
||||||
@ -293,13 +293,13 @@ class FPDF_TPL extends FPDF {
|
|||||||
* See FPDF/TCPDF-Documentation ;-)
|
* See FPDF/TCPDF-Documentation ;-)
|
||||||
*/
|
*/
|
||||||
function Image(
|
function Image(
|
||||||
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
|
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
|
||||||
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
|
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
|
||||||
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
|
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
|
||||||
) {
|
) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
|
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
|
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
|
||||||
@ -318,9 +318,9 @@ class FPDF_TPL extends FPDF {
|
|||||||
* AddPage is not available when you're "in" a template.
|
* AddPage is not available when you're "in" a template.
|
||||||
*/
|
*/
|
||||||
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
|
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
|
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
@ -334,8 +334,8 @@ class FPDF_TPL extends FPDF {
|
|||||||
*/
|
*/
|
||||||
function Link($x, $y, $w, $h, $link, $spaces = 0) {
|
function Link($x, $y, $w, $h, $link, $spaces = 0) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
|
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
@ -345,9 +345,9 @@ class FPDF_TPL extends FPDF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AddLink() {
|
function AddLink() {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
|
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
@ -356,9 +356,9 @@ class FPDF_TPL extends FPDF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SetLink($link, $y = 0, $page = -1) {
|
function SetLink($link, $y = 0, $page = -1) {
|
||||||
if (is_subclass_of($this, 'TCPDF')) {
|
if (is_subclass_of($this, 'TCPDF')) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
|
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_intpl)
|
if ($this->_intpl)
|
||||||
@ -371,13 +371,13 @@ class FPDF_TPL extends FPDF {
|
|||||||
*/
|
*/
|
||||||
function _putformxobjects() {
|
function _putformxobjects() {
|
||||||
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
|
||||||
reset($this->tpls);
|
reset($this->tpls);
|
||||||
foreach($this->tpls AS $tplidx => $tpl) {
|
foreach($this->tpls AS $tplidx => $tpl) {
|
||||||
|
|
||||||
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
|
||||||
$this->_newobj();
|
$this->_newobj();
|
||||||
$this->tpls[$tplidx]['n'] = $this->n;
|
$this->tpls[$tplidx]['n'] = $this->n;
|
||||||
$this->_out('<<'.$filter.'/Type /XObject');
|
$this->_out('<<'.$filter.'/Type /XObject');
|
||||||
$this->_out('/Subtype /Form');
|
$this->_out('/Subtype /Form');
|
||||||
$this->_out('/FormType 1');
|
$this->_out('/FormType 1');
|
||||||
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
|
||||||
@ -400,31 +400,31 @@ class FPDF_TPL extends FPDF {
|
|||||||
$this->_out('/Resources ');
|
$this->_out('/Resources ');
|
||||||
|
|
||||||
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
||||||
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
||||||
$this->_out('/Font <<');
|
$this->_out('/Font <<');
|
||||||
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
|
||||||
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
|
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
|
||||||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
|
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
|
||||||
{
|
{
|
||||||
$this->_out('/XObject <<');
|
$this->_out('/XObject <<');
|
||||||
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
|
||||||
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
|
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
||||||
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
|
||||||
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
|
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
}
|
}
|
||||||
$this->_out('>>');
|
$this->_out('>>');
|
||||||
|
|
||||||
$this->_out('/Length ' . strlen($p) . ' >>');
|
$this->_out('/Length ' . strlen($p) . ' >>');
|
||||||
$this->_putstream($p);
|
$this->_putstream($p);
|
||||||
$this->_out('endobj');
|
$this->_out('endobj');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user