@@ -18,444 +18,444 @@ |
||
| 18 | 18 | // |
| 19 | 19 | |
| 20 | 20 | class FPDF_TPL extends FPDF { |
| 21 | - /** |
|
| 22 | - * Array of Tpl-Data |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - var $tpls = array(); |
|
| 21 | + /** |
|
| 22 | + * Array of Tpl-Data |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + var $tpls = array(); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Current Template-ID |
|
| 29 | - * @var int |
|
| 30 | - */ |
|
| 31 | - var $tpl = 0; |
|
| 27 | + /** |
|
| 28 | + * Current Template-ID |
|
| 29 | + * @var int |
|
| 30 | + */ |
|
| 31 | + var $tpl = 0; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * "In Template"-Flag |
|
| 35 | - * @var boolean |
|
| 36 | - */ |
|
| 37 | - var $_intpl = false; |
|
| 33 | + /** |
|
| 34 | + * "In Template"-Flag |
|
| 35 | + * @var boolean |
|
| 36 | + */ |
|
| 37 | + var $_intpl = false; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Nameprefix of Templates used in Resources-Dictonary |
|
| 41 | - * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / |
|
| 42 | - */ |
|
| 43 | - var $tplprefix = "/TPL"; |
|
| 39 | + /** |
|
| 40 | + * Nameprefix of Templates used in Resources-Dictonary |
|
| 41 | + * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / |
|
| 42 | + */ |
|
| 43 | + var $tplprefix = "/TPL"; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Resources used By Templates and Pages |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 49 | - var $_res = array(); |
|
| 45 | + /** |
|
| 46 | + * Resources used By Templates and Pages |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | + var $_res = array(); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Last used Template data |
|
| 53 | - * |
|
| 54 | - * @var array |
|
| 55 | - */ |
|
| 56 | - var $lastUsedTemplateData = array(); |
|
| 51 | + /** |
|
| 52 | + * Last used Template data |
|
| 53 | + * |
|
| 54 | + * @var array |
|
| 55 | + */ |
|
| 56 | + var $lastUsedTemplateData = array(); |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Start a Template |
|
| 60 | - * |
|
| 61 | - * This method starts a template. You can give own coordinates to build an own sized |
|
| 62 | - * Template. Pay attention, that the margins are adapted to the new templatesize. |
|
| 63 | - * If you want to write outside the template, for example to build a clipped Template, |
|
| 64 | - * you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call. |
|
| 65 | - * |
|
| 66 | - * If no parameter is given, the template uses the current page-size. |
|
| 67 | - * The Method returns an ID of the current Template. This ID is used later for using this template. |
|
| 68 | - * Warning: A created Template is used in PDF at all events. Still if you don't use it after creation! |
|
| 69 | - * |
|
| 70 | - * @param int $x The x-coordinate given in user-unit |
|
| 71 | - * @param int $y The y-coordinate given in user-unit |
|
| 72 | - * @param int $w The width given in user-unit |
|
| 73 | - * @param int $h The height given in user-unit |
|
| 74 | - * @return int The ID of new created Template |
|
| 75 | - */ |
|
| 76 | - function beginTemplate($x = null, $y = null, $w = null, $h = null) { |
|
| 77 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 78 | - $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); |
|
| 79 | - return; |
|
| 80 | - } |
|
| 58 | + /** |
|
| 59 | + * Start a Template |
|
| 60 | + * |
|
| 61 | + * This method starts a template. You can give own coordinates to build an own sized |
|
| 62 | + * Template. Pay attention, that the margins are adapted to the new templatesize. |
|
| 63 | + * If you want to write outside the template, for example to build a clipped Template, |
|
| 64 | + * you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call. |
|
| 65 | + * |
|
| 66 | + * If no parameter is given, the template uses the current page-size. |
|
| 67 | + * The Method returns an ID of the current Template. This ID is used later for using this template. |
|
| 68 | + * Warning: A created Template is used in PDF at all events. Still if you don't use it after creation! |
|
| 69 | + * |
|
| 70 | + * @param int $x The x-coordinate given in user-unit |
|
| 71 | + * @param int $y The y-coordinate given in user-unit |
|
| 72 | + * @param int $w The width given in user-unit |
|
| 73 | + * @param int $h The height given in user-unit |
|
| 74 | + * @return int The ID of new created Template |
|
| 75 | + */ |
|
| 76 | + function beginTemplate($x = null, $y = null, $w = null, $h = null) { |
|
| 77 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 78 | + $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - if ($this->page <= 0) |
|
| 83 | - $this->error("You have to add a page to fpdf first!"); |
|
| 82 | + if ($this->page <= 0) |
|
| 83 | + $this->error("You have to add a page to fpdf first!"); |
|
| 84 | 84 | |
| 85 | - if ($x == null) |
|
| 86 | - $x = 0; |
|
| 87 | - if ($y == null) |
|
| 88 | - $y = 0; |
|
| 89 | - if ($w == null) |
|
| 90 | - $w = $this->w; |
|
| 91 | - if ($h == null) |
|
| 92 | - $h = $this->h; |
|
| 85 | + if ($x == null) |
|
| 86 | + $x = 0; |
|
| 87 | + if ($y == null) |
|
| 88 | + $y = 0; |
|
| 89 | + if ($w == null) |
|
| 90 | + $w = $this->w; |
|
| 91 | + if ($h == null) |
|
| 92 | + $h = $this->h; |
|
| 93 | 93 | |
| 94 | - // Save settings |
|
| 95 | - $this->tpl++; |
|
| 96 | - $tpl =& $this->tpls[$this->tpl]; |
|
| 97 | - $tpl = array( |
|
| 98 | - 'o_x' => $this->x, |
|
| 99 | - 'o_y' => $this->y, |
|
| 100 | - 'o_AutoPageBreak' => $this->AutoPageBreak, |
|
| 101 | - 'o_bMargin' => $this->bMargin, |
|
| 102 | - 'o_tMargin' => $this->tMargin, |
|
| 103 | - 'o_lMargin' => $this->lMargin, |
|
| 104 | - 'o_rMargin' => $this->rMargin, |
|
| 105 | - 'o_h' => $this->h, |
|
| 106 | - 'o_w' => $this->w, |
|
| 107 | - 'o_FontFamily' => $this->FontFamily, |
|
| 108 | - 'o_FontStyle' => $this->FontStyle, |
|
| 109 | - 'o_FontSizePt' => $this->FontSizePt, |
|
| 110 | - 'o_FontSize' => $this->FontSize, |
|
| 111 | - 'buffer' => '', |
|
| 112 | - 'x' => $x, |
|
| 113 | - 'y' => $y, |
|
| 114 | - 'w' => $w, |
|
| 115 | - 'h' => $h |
|
| 116 | - ); |
|
| 94 | + // Save settings |
|
| 95 | + $this->tpl++; |
|
| 96 | + $tpl =& $this->tpls[$this->tpl]; |
|
| 97 | + $tpl = array( |
|
| 98 | + 'o_x' => $this->x, |
|
| 99 | + 'o_y' => $this->y, |
|
| 100 | + 'o_AutoPageBreak' => $this->AutoPageBreak, |
|
| 101 | + 'o_bMargin' => $this->bMargin, |
|
| 102 | + 'o_tMargin' => $this->tMargin, |
|
| 103 | + 'o_lMargin' => $this->lMargin, |
|
| 104 | + 'o_rMargin' => $this->rMargin, |
|
| 105 | + 'o_h' => $this->h, |
|
| 106 | + 'o_w' => $this->w, |
|
| 107 | + 'o_FontFamily' => $this->FontFamily, |
|
| 108 | + 'o_FontStyle' => $this->FontStyle, |
|
| 109 | + 'o_FontSizePt' => $this->FontSizePt, |
|
| 110 | + 'o_FontSize' => $this->FontSize, |
|
| 111 | + 'buffer' => '', |
|
| 112 | + 'x' => $x, |
|
| 113 | + 'y' => $y, |
|
| 114 | + 'w' => $w, |
|
| 115 | + 'h' => $h |
|
| 116 | + ); |
|
| 117 | 117 | |
| 118 | - $this->SetAutoPageBreak(false); |
|
| 118 | + $this->SetAutoPageBreak(false); |
|
| 119 | 119 | |
| 120 | - // Define own high and width to calculate possitions correct |
|
| 121 | - $this->h = $h; |
|
| 122 | - $this->w = $w; |
|
| 120 | + // Define own high and width to calculate possitions correct |
|
| 121 | + $this->h = $h; |
|
| 122 | + $this->w = $w; |
|
| 123 | 123 | |
| 124 | - $this->_intpl = true; |
|
| 125 | - $this->SetXY($x + $this->lMargin, $y + $this->tMargin); |
|
| 126 | - $this->SetRightMargin($this->w - $w + $this->rMargin); |
|
| 124 | + $this->_intpl = true; |
|
| 125 | + $this->SetXY($x + $this->lMargin, $y + $this->tMargin); |
|
| 126 | + $this->SetRightMargin($this->w - $w + $this->rMargin); |
|
| 127 | 127 | |
| 128 | - if ($this->CurrentFont) { |
|
| 129 | - $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 130 | - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 128 | + if ($this->CurrentFont) { |
|
| 129 | + $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 130 | + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 131 | 131 | |
| 132 | - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
| 133 | - } |
|
| 132 | + $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - return $this->tpl; |
|
| 136 | - } |
|
| 135 | + return $this->tpl; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * End Template |
|
| 140 | - * |
|
| 141 | - * This method ends a template and reset initiated variables on beginTemplate. |
|
| 142 | - * |
|
| 143 | - * @return mixed If a template is opened, the ID is returned. If not a false is returned. |
|
| 144 | - */ |
|
| 145 | - function endTemplate() { |
|
| 146 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 147 | - $args = func_get_args(); |
|
| 138 | + /** |
|
| 139 | + * End Template |
|
| 140 | + * |
|
| 141 | + * This method ends a template and reset initiated variables on beginTemplate. |
|
| 142 | + * |
|
| 143 | + * @return mixed If a template is opened, the ID is returned. If not a false is returned. |
|
| 144 | + */ |
|
| 145 | + function endTemplate() { |
|
| 146 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 147 | + $args = func_get_args(); |
|
| 148 | 148 | return parent::endTemplate(...$args); |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - if ($this->_intpl) { |
|
| 152 | - $this->_intpl = false; |
|
| 153 | - $tpl =& $this->tpls[$this->tpl]; |
|
| 154 | - $this->SetXY($tpl['o_x'], $tpl['o_y']); |
|
| 155 | - $this->tMargin = $tpl['o_tMargin']; |
|
| 156 | - $this->lMargin = $tpl['o_lMargin']; |
|
| 157 | - $this->rMargin = $tpl['o_rMargin']; |
|
| 158 | - $this->h = $tpl['o_h']; |
|
| 159 | - $this->w = $tpl['o_w']; |
|
| 160 | - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); |
|
| 151 | + if ($this->_intpl) { |
|
| 152 | + $this->_intpl = false; |
|
| 153 | + $tpl =& $this->tpls[$this->tpl]; |
|
| 154 | + $this->SetXY($tpl['o_x'], $tpl['o_y']); |
|
| 155 | + $this->tMargin = $tpl['o_tMargin']; |
|
| 156 | + $this->lMargin = $tpl['o_lMargin']; |
|
| 157 | + $this->rMargin = $tpl['o_rMargin']; |
|
| 158 | + $this->h = $tpl['o_h']; |
|
| 159 | + $this->w = $tpl['o_w']; |
|
| 160 | + $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); |
|
| 161 | 161 | |
| 162 | - $this->FontFamily = $tpl['o_FontFamily']; |
|
| 163 | - $this->FontStyle = $tpl['o_FontStyle']; |
|
| 164 | - $this->FontSizePt = $tpl['o_FontSizePt']; |
|
| 165 | - $this->FontSize = $tpl['o_FontSize']; |
|
| 162 | + $this->FontFamily = $tpl['o_FontFamily']; |
|
| 163 | + $this->FontStyle = $tpl['o_FontStyle']; |
|
| 164 | + $this->FontSizePt = $tpl['o_FontSizePt']; |
|
| 165 | + $this->FontSize = $tpl['o_FontSize']; |
|
| 166 | 166 | |
| 167 | - $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 168 | - if ($fontkey) |
|
| 169 | - $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 167 | + $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 168 | + if ($fontkey) |
|
| 169 | + $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 170 | 170 | |
| 171 | - return $this->tpl; |
|
| 172 | - } else { |
|
| 173 | - return false; |
|
| 174 | - } |
|
| 175 | - } |
|
| 171 | + return $this->tpl; |
|
| 172 | + } else { |
|
| 173 | + return false; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * Use a Template in current Page or other Template |
|
| 179 | - * |
|
| 180 | - * You can use a template in a page or in another template. |
|
| 181 | - * You can give the used template a new size like you use the Image()-method. |
|
| 182 | - * All parameters are optional. The width or height is calculated automaticaly |
|
| 183 | - * if one is given. If no parameter is given the origin size as defined in |
|
| 184 | - * beginTemplate() is used. |
|
| 185 | - * The calculated or used width and height are returned as an array. |
|
| 186 | - * |
|
| 187 | - * @param int $tplidx A valid template-Id |
|
| 188 | - * @param int $_x The x-position |
|
| 189 | - * @param int $_y The y-position |
|
| 190 | - * @param int $_w The new width of the template |
|
| 191 | - * @param int $_h The new height of the template |
|
| 192 | - * @retrun array The height and width of the template |
|
| 193 | - */ |
|
| 194 | - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { |
|
| 195 | - if ($this->page <= 0) |
|
| 196 | - $this->error('You have to add a page first!'); |
|
| 177 | + /** |
|
| 178 | + * Use a Template in current Page or other Template |
|
| 179 | + * |
|
| 180 | + * You can use a template in a page or in another template. |
|
| 181 | + * You can give the used template a new size like you use the Image()-method. |
|
| 182 | + * All parameters are optional. The width or height is calculated automaticaly |
|
| 183 | + * if one is given. If no parameter is given the origin size as defined in |
|
| 184 | + * beginTemplate() is used. |
|
| 185 | + * The calculated or used width and height are returned as an array. |
|
| 186 | + * |
|
| 187 | + * @param int $tplidx A valid template-Id |
|
| 188 | + * @param int $_x The x-position |
|
| 189 | + * @param int $_y The y-position |
|
| 190 | + * @param int $_w The new width of the template |
|
| 191 | + * @param int $_h The new height of the template |
|
| 192 | + * @retrun array The height and width of the template |
|
| 193 | + */ |
|
| 194 | + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { |
|
| 195 | + if ($this->page <= 0) |
|
| 196 | + $this->error('You have to add a page first!'); |
|
| 197 | 197 | |
| 198 | - if (!isset($this->tpls[$tplidx])) |
|
| 199 | - $this->error('Template does not exist!'); |
|
| 198 | + if (!isset($this->tpls[$tplidx])) |
|
| 199 | + $this->error('Template does not exist!'); |
|
| 200 | 200 | |
| 201 | - if ($this->_intpl) { |
|
| 202 | - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; |
|
| 203 | - } |
|
| 201 | + if ($this->_intpl) { |
|
| 202 | + $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - $tpl =& $this->tpls[$tplidx]; |
|
| 206 | - $w = $tpl['w']; |
|
| 207 | - $h = $tpl['h']; |
|
| 205 | + $tpl =& $this->tpls[$tplidx]; |
|
| 206 | + $w = $tpl['w']; |
|
| 207 | + $h = $tpl['h']; |
|
| 208 | 208 | |
| 209 | - if ($_x == null) |
|
| 210 | - $_x = 0; |
|
| 211 | - if ($_y == null) |
|
| 212 | - $_y = 0; |
|
| 209 | + if ($_x == null) |
|
| 210 | + $_x = 0; |
|
| 211 | + if ($_y == null) |
|
| 212 | + $_y = 0; |
|
| 213 | 213 | |
| 214 | - $_x += $tpl['x']; |
|
| 215 | - $_y += $tpl['y']; |
|
| 214 | + $_x += $tpl['x']; |
|
| 215 | + $_y += $tpl['y']; |
|
| 216 | 216 | |
| 217 | - $wh = $this->getTemplateSize($tplidx, $_w, $_h); |
|
| 218 | - $_w = $wh['w']; |
|
| 219 | - $_h = $wh['h']; |
|
| 217 | + $wh = $this->getTemplateSize($tplidx, $_w, $_h); |
|
| 218 | + $_w = $wh['w']; |
|
| 219 | + $_h = $wh['h']; |
|
| 220 | 220 | |
| 221 | - $tData = array( |
|
| 222 | - 'x' => $this->x, |
|
| 223 | - 'y' => $this->y, |
|
| 224 | - 'w' => $_w, |
|
| 225 | - 'h' => $_h, |
|
| 226 | - 'scaleX' => ($_w / $w), |
|
| 227 | - 'scaleY' => ($_h / $h), |
|
| 228 | - 'tx' => $_x, |
|
| 229 | - 'ty' => ($this->h - $_y - $_h), |
|
| 230 | - 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) |
|
| 231 | - ); |
|
| 221 | + $tData = array( |
|
| 222 | + 'x' => $this->x, |
|
| 223 | + 'y' => $this->y, |
|
| 224 | + 'w' => $_w, |
|
| 225 | + 'h' => $_h, |
|
| 226 | + 'scaleX' => ($_w / $w), |
|
| 227 | + 'scaleY' => ($_h / $h), |
|
| 228 | + 'tx' => $_x, |
|
| 229 | + 'ty' => ($this->h - $_y - $_h), |
|
| 230 | + 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) |
|
| 231 | + ); |
|
| 232 | 232 | |
| 233 | - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate |
|
| 234 | - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); |
|
| 233 | + $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate |
|
| 234 | + $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); |
|
| 235 | 235 | |
| 236 | - $this->lastUsedTemplateData = $tData; |
|
| 236 | + $this->lastUsedTemplateData = $tData; |
|
| 237 | 237 | |
| 238 | - return array('w' => $_w, 'h' => $_h); |
|
| 239 | - } |
|
| 238 | + return array('w' => $_w, 'h' => $_h); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Get The calculated Size of a Template |
|
| 243 | - * |
|
| 244 | - * If one size is given, this method calculates the other one. |
|
| 245 | - * |
|
| 246 | - * @param int $tplidx A valid template-Id |
|
| 247 | - * @param int $_w The width of the template |
|
| 248 | - * @param int $_h The height of the template |
|
| 249 | - * @return array The height and width of the template |
|
| 250 | - */ |
|
| 251 | - function getTemplateSize($tplidx, $_w = 0, $_h = 0) { |
|
| 252 | - if (!isset($this->tpls[$tplidx])) |
|
| 253 | - return false; |
|
| 241 | + /** |
|
| 242 | + * Get The calculated Size of a Template |
|
| 243 | + * |
|
| 244 | + * If one size is given, this method calculates the other one. |
|
| 245 | + * |
|
| 246 | + * @param int $tplidx A valid template-Id |
|
| 247 | + * @param int $_w The width of the template |
|
| 248 | + * @param int $_h The height of the template |
|
| 249 | + * @return array The height and width of the template |
|
| 250 | + */ |
|
| 251 | + function getTemplateSize($tplidx, $_w = 0, $_h = 0) { |
|
| 252 | + if (!isset($this->tpls[$tplidx])) |
|
| 253 | + return false; |
|
| 254 | 254 | |
| 255 | - $tpl =& $this->tpls[$tplidx]; |
|
| 256 | - $w = $tpl['w']; |
|
| 257 | - $h = $tpl['h']; |
|
| 255 | + $tpl =& $this->tpls[$tplidx]; |
|
| 256 | + $w = $tpl['w']; |
|
| 257 | + $h = $tpl['h']; |
|
| 258 | 258 | |
| 259 | - if ($_w == 0 and $_h == 0) { |
|
| 260 | - $_w = $w; |
|
| 261 | - $_h = $h; |
|
| 262 | - } |
|
| 259 | + if ($_w == 0 and $_h == 0) { |
|
| 260 | + $_w = $w; |
|
| 261 | + $_h = $h; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - if($_w == 0) |
|
| 265 | - $_w = $_h * $w / $h; |
|
| 266 | - if($_h == 0) |
|
| 267 | - $_h = $_w * $h / $w; |
|
| 264 | + if($_w == 0) |
|
| 265 | + $_w = $_h * $w / $h; |
|
| 266 | + if($_h == 0) |
|
| 267 | + $_h = $_w * $h / $w; |
|
| 268 | 268 | |
| 269 | - return array("w" => $_w, "h" => $_h); |
|
| 270 | - } |
|
| 269 | + return array("w" => $_w, "h" => $_h); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * See FPDF/TCPDF-Documentation ;-) |
|
| 274 | - */ |
|
| 275 | - public function SetFont($family, $style = '', $size = 0, $fontfile='', $subset='default', $out=true) { |
|
| 276 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 277 | - $args = func_get_args(); |
|
| 272 | + /** |
|
| 273 | + * See FPDF/TCPDF-Documentation ;-) |
|
| 274 | + */ |
|
| 275 | + public function SetFont($family, $style = '', $size = 0, $fontfile='', $subset='default', $out=true) { |
|
| 276 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 277 | + $args = func_get_args(); |
|
| 278 | 278 | return parent::SetFont(...$args); |
| 279 | - } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - parent::SetFont($family, $style, $size); |
|
| 281 | + parent::SetFont($family, $style, $size); |
|
| 282 | 282 | |
| 283 | - $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 283 | + $fontkey = $this->FontFamily . $this->FontStyle; |
|
| 284 | 284 | |
| 285 | - if ($this->_intpl) { |
|
| 286 | - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 287 | - } else { |
|
| 288 | - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 289 | - } |
|
| 290 | - } |
|
| 285 | + if ($this->_intpl) { |
|
| 286 | + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 287 | + } else { |
|
| 288 | + $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * See FPDF/TCPDF-Documentation ;-) |
|
| 294 | - */ |
|
| 295 | - function Image( |
|
| 296 | - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, |
|
| 297 | - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, |
|
| 298 | - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() |
|
| 299 | - ) { |
|
| 300 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 301 | - $args = func_get_args(); |
|
| 292 | + /** |
|
| 293 | + * See FPDF/TCPDF-Documentation ;-) |
|
| 294 | + */ |
|
| 295 | + function Image( |
|
| 296 | + $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, |
|
| 297 | + $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, |
|
| 298 | + $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() |
|
| 299 | + ) { |
|
| 300 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 301 | + $args = func_get_args(); |
|
| 302 | 302 | return parent::Image(...$args); |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); |
|
| 306 | - if ($this->_intpl) { |
|
| 307 | - $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; |
|
| 308 | - } else { |
|
| 309 | - $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; |
|
| 310 | - } |
|
| 305 | + $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); |
|
| 306 | + if ($this->_intpl) { |
|
| 307 | + $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; |
|
| 308 | + } else { |
|
| 309 | + $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - return $ret; |
|
| 313 | - } |
|
| 312 | + return $ret; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * See FPDF-Documentation ;-) |
|
| 317 | - * |
|
| 318 | - * AddPage is not available when you're "in" a template. |
|
| 319 | - */ |
|
| 320 | - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { |
|
| 321 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 322 | - $args = func_get_args(); |
|
| 315 | + /** |
|
| 316 | + * See FPDF-Documentation ;-) |
|
| 317 | + * |
|
| 318 | + * AddPage is not available when you're "in" a template. |
|
| 319 | + */ |
|
| 320 | + function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { |
|
| 321 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 322 | + $args = func_get_args(); |
|
| 323 | 323 | return parent::AddPage(...$args); |
| 324 | - } |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if ($this->_intpl) |
|
| 327 | - $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 326 | + if ($this->_intpl) |
|
| 327 | + $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 328 | 328 | |
| 329 | - parent::AddPage($orientation, $format); |
|
| 330 | - } |
|
| 329 | + parent::AddPage($orientation, $format); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - /** |
|
| 333 | - * Preserve adding Links in Templates ...won't work |
|
| 334 | - */ |
|
| 335 | - function Link($x, $y, $w, $h, $link, $spaces = 0) { |
|
| 336 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 337 | - $args = func_get_args(); |
|
| 332 | + /** |
|
| 333 | + * Preserve adding Links in Templates ...won't work |
|
| 334 | + */ |
|
| 335 | + function Link($x, $y, $w, $h, $link, $spaces = 0) { |
|
| 336 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 337 | + $args = func_get_args(); |
|
| 338 | 338 | return parent::Link(...$args); |
| 339 | - } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - if ($this->_intpl) |
|
| 342 | - $this->Error('Using links in templates aren\'t possible!'); |
|
| 341 | + if ($this->_intpl) |
|
| 342 | + $this->Error('Using links in templates aren\'t possible!'); |
|
| 343 | 343 | |
| 344 | - parent::Link($x, $y, $w, $h, $link); |
|
| 345 | - } |
|
| 344 | + parent::Link($x, $y, $w, $h, $link); |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - function AddLink() { |
|
| 348 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 349 | - $args = func_get_args(); |
|
| 347 | + function AddLink() { |
|
| 348 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 349 | + $args = func_get_args(); |
|
| 350 | 350 | return parent::AddLink(...$args); |
| 351 | 351 | |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - if ($this->_intpl) |
|
| 355 | - $this->Error('Adding links in templates aren\'t possible!'); |
|
| 356 | - return parent::AddLink(); |
|
| 357 | - } |
|
| 354 | + if ($this->_intpl) |
|
| 355 | + $this->Error('Adding links in templates aren\'t possible!'); |
|
| 356 | + return parent::AddLink(); |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - function SetLink($link, $y = 0, $page = -1) { |
|
| 360 | - if (is_subclass_of($this, 'TCPDF')) { |
|
| 361 | - $args = func_get_args(); |
|
| 359 | + function SetLink($link, $y = 0, $page = -1) { |
|
| 360 | + if (is_subclass_of($this, 'TCPDF')) { |
|
| 361 | + $args = func_get_args(); |
|
| 362 | 362 | return parent::SetLink(...$args); |
| 363 | - } |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - if ($this->_intpl) |
|
| 366 | - $this->Error('Setting links in templates aren\'t possible!'); |
|
| 367 | - parent::SetLink($link, $y, $page); |
|
| 368 | - } |
|
| 365 | + if ($this->_intpl) |
|
| 366 | + $this->Error('Setting links in templates aren\'t possible!'); |
|
| 367 | + parent::SetLink($link, $y, $page); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - /** |
|
| 371 | - * Private Method that writes the form xobjects |
|
| 372 | - */ |
|
| 373 | - function _putformxobjects() { |
|
| 374 | - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 375 | - reset($this->tpls); |
|
| 376 | - foreach($this->tpls AS $tplidx => $tpl) { |
|
| 370 | + /** |
|
| 371 | + * Private Method that writes the form xobjects |
|
| 372 | + */ |
|
| 373 | + function _putformxobjects() { |
|
| 374 | + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|
| 375 | + reset($this->tpls); |
|
| 376 | + foreach($this->tpls AS $tplidx => $tpl) { |
|
| 377 | 377 | |
| 378 | - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; |
|
| 379 | - $this->_newobj(); |
|
| 380 | - $this->tpls[$tplidx]['n'] = $this->n; |
|
| 381 | - $this->_out('<<'.$filter.'/Type /XObject'); |
|
| 382 | - $this->_out('/Subtype /Form'); |
|
| 383 | - $this->_out('/FormType 1'); |
|
| 384 | - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', |
|
| 385 | - // llx |
|
| 386 | - $tpl['x'] * $this->k, |
|
| 387 | - // lly |
|
| 388 | - -$tpl['y'] * $this->k, |
|
| 389 | - // urx |
|
| 390 | - ($tpl['w'] + $tpl['x']) * $this->k, |
|
| 391 | - // ury |
|
| 392 | - ($tpl['h'] - $tpl['y']) * $this->k |
|
| 393 | - )); |
|
| 378 | + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; |
|
| 379 | + $this->_newobj(); |
|
| 380 | + $this->tpls[$tplidx]['n'] = $this->n; |
|
| 381 | + $this->_out('<<'.$filter.'/Type /XObject'); |
|
| 382 | + $this->_out('/Subtype /Form'); |
|
| 383 | + $this->_out('/FormType 1'); |
|
| 384 | + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', |
|
| 385 | + // llx |
|
| 386 | + $tpl['x'] * $this->k, |
|
| 387 | + // lly |
|
| 388 | + -$tpl['y'] * $this->k, |
|
| 389 | + // urx |
|
| 390 | + ($tpl['w'] + $tpl['x']) * $this->k, |
|
| 391 | + // ury |
|
| 392 | + ($tpl['h'] - $tpl['y']) * $this->k |
|
| 393 | + )); |
|
| 394 | 394 | |
| 395 | - if ($tpl['x'] != 0 || $tpl['y'] != 0) { |
|
| 396 | - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', |
|
| 397 | - -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 |
|
| 398 | - )); |
|
| 399 | - } |
|
| 395 | + if ($tpl['x'] != 0 || $tpl['y'] != 0) { |
|
| 396 | + $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', |
|
| 397 | + -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 |
|
| 398 | + )); |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - $this->_out('/Resources '); |
|
| 401 | + $this->_out('/Resources '); |
|
| 402 | 402 | |
| 403 | - $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
|
| 404 | - if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { |
|
| 405 | - $this->_out('/Font <<'); |
|
| 406 | - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|
| 407 | - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 408 | - $this->_out('>>'); |
|
| 409 | - } |
|
| 410 | - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
|
| 411 | - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) |
|
| 412 | - { |
|
| 413 | - $this->_out('/XObject <<'); |
|
| 414 | - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { |
|
| 415 | - foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|
| 416 | - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 417 | - } |
|
| 418 | - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { |
|
| 419 | - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|
| 420 | - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 421 | - } |
|
| 422 | - $this->_out('>>'); |
|
| 423 | - } |
|
| 424 | - $this->_out('>>'); |
|
| 403 | + $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
|
| 404 | + if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { |
|
| 405 | + $this->_out('/Font <<'); |
|
| 406 | + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|
| 407 | + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 408 | + $this->_out('>>'); |
|
| 409 | + } |
|
| 410 | + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
|
| 411 | + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) |
|
| 412 | + { |
|
| 413 | + $this->_out('/XObject <<'); |
|
| 414 | + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { |
|
| 415 | + foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|
| 416 | + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 417 | + } |
|
| 418 | + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { |
|
| 419 | + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|
| 420 | + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 421 | + } |
|
| 422 | + $this->_out('>>'); |
|
| 423 | + } |
|
| 424 | + $this->_out('>>'); |
|
| 425 | 425 | |
| 426 | - $this->_out('/Length ' . strlen($p) . ' >>'); |
|
| 427 | - $this->_putstream($p); |
|
| 428 | - $this->_out('endobj'); |
|
| 429 | - } |
|
| 430 | - } |
|
| 426 | + $this->_out('/Length ' . strlen($p) . ' >>'); |
|
| 427 | + $this->_putstream($p); |
|
| 428 | + $this->_out('endobj'); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * Overwritten to add _putformxobjects() after _putimages() |
|
| 434 | - * |
|
| 435 | - */ |
|
| 436 | - function _putimages() { |
|
| 437 | - parent::_putimages(); |
|
| 438 | - $this->_putformxobjects(); |
|
| 439 | - } |
|
| 432 | + /** |
|
| 433 | + * Overwritten to add _putformxobjects() after _putimages() |
|
| 434 | + * |
|
| 435 | + */ |
|
| 436 | + function _putimages() { |
|
| 437 | + parent::_putimages(); |
|
| 438 | + $this->_putformxobjects(); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - function _putxobjectdict() { |
|
| 442 | - parent::_putxobjectdict(); |
|
| 441 | + function _putxobjectdict() { |
|
| 442 | + parent::_putxobjectdict(); |
|
| 443 | 443 | |
| 444 | - if (count($this->tpls)) { |
|
| 445 | - foreach($this->tpls as $tplidx => $tpl) { |
|
| 446 | - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 444 | + if (count($this->tpls)) { |
|
| 445 | + foreach($this->tpls as $tplidx => $tpl) { |
|
| 446 | + $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - /** |
|
| 452 | - * Private Method |
|
| 453 | - */ |
|
| 454 | - function _out($s) { |
|
| 455 | - if ($this->state == 2 && $this->_intpl) { |
|
| 456 | - $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; |
|
| 457 | - } else { |
|
| 458 | - parent::_out($s); |
|
| 459 | - } |
|
| 460 | - } |
|
| 451 | + /** |
|
| 452 | + * Private Method |
|
| 453 | + */ |
|
| 454 | + function _out($s) { |
|
| 455 | + if ($this->state == 2 && $this->_intpl) { |
|
| 456 | + $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; |
|
| 457 | + } else { |
|
| 458 | + parent::_out($s); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | 461 | } |
@@ -79,17 +79,22 @@ discard block |
||
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ($this->page <= 0) |
|
| 83 | - $this->error("You have to add a page to fpdf first!"); |
|
| 82 | + if ($this->page <= 0) { |
|
| 83 | + $this->error("You have to add a page to fpdf first!"); |
|
| 84 | + } |
|
| 84 | 85 | |
| 85 | - if ($x == null) |
|
| 86 | - $x = 0; |
|
| 87 | - if ($y == null) |
|
| 88 | - $y = 0; |
|
| 89 | - if ($w == null) |
|
| 90 | - $w = $this->w; |
|
| 91 | - if ($h == null) |
|
| 92 | - $h = $this->h; |
|
| 86 | + if ($x == null) { |
|
| 87 | + $x = 0; |
|
| 88 | + } |
|
| 89 | + if ($y == null) { |
|
| 90 | + $y = 0; |
|
| 91 | + } |
|
| 92 | + if ($w == null) { |
|
| 93 | + $w = $this->w; |
|
| 94 | + } |
|
| 95 | + if ($h == null) { |
|
| 96 | + $h = $this->h; |
|
| 97 | + } |
|
| 93 | 98 | |
| 94 | 99 | // Save settings |
| 95 | 100 | $this->tpl++; |
@@ -165,8 +170,9 @@ discard block |
||
| 165 | 170 | $this->FontSize = $tpl['o_FontSize']; |
| 166 | 171 | |
| 167 | 172 | $fontkey = $this->FontFamily . $this->FontStyle; |
| 168 | - if ($fontkey) |
|
| 169 | - $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 173 | + if ($fontkey) { |
|
| 174 | + $this->CurrentFont =& $this->fonts[$fontkey]; |
|
| 175 | + } |
|
| 170 | 176 | |
| 171 | 177 | return $this->tpl; |
| 172 | 178 | } else { |
@@ -192,11 +198,13 @@ discard block |
||
| 192 | 198 | * @retrun array The height and width of the template |
| 193 | 199 | */ |
| 194 | 200 | function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { |
| 195 | - if ($this->page <= 0) |
|
| 196 | - $this->error('You have to add a page first!'); |
|
| 201 | + if ($this->page <= 0) { |
|
| 202 | + $this->error('You have to add a page first!'); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | - if (!isset($this->tpls[$tplidx])) |
|
| 199 | - $this->error('Template does not exist!'); |
|
| 205 | + if (!isset($this->tpls[$tplidx])) { |
|
| 206 | + $this->error('Template does not exist!'); |
|
| 207 | + } |
|
| 200 | 208 | |
| 201 | 209 | if ($this->_intpl) { |
| 202 | 210 | $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; |
@@ -206,10 +214,12 @@ discard block |
||
| 206 | 214 | $w = $tpl['w']; |
| 207 | 215 | $h = $tpl['h']; |
| 208 | 216 | |
| 209 | - if ($_x == null) |
|
| 210 | - $_x = 0; |
|
| 211 | - if ($_y == null) |
|
| 212 | - $_y = 0; |
|
| 217 | + if ($_x == null) { |
|
| 218 | + $_x = 0; |
|
| 219 | + } |
|
| 220 | + if ($_y == null) { |
|
| 221 | + $_y = 0; |
|
| 222 | + } |
|
| 213 | 223 | |
| 214 | 224 | $_x += $tpl['x']; |
| 215 | 225 | $_y += $tpl['y']; |
@@ -249,8 +259,9 @@ discard block |
||
| 249 | 259 | * @return array The height and width of the template |
| 250 | 260 | */ |
| 251 | 261 | function getTemplateSize($tplidx, $_w = 0, $_h = 0) { |
| 252 | - if (!isset($this->tpls[$tplidx])) |
|
| 253 | - return false; |
|
| 262 | + if (!isset($this->tpls[$tplidx])) { |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 254 | 265 | |
| 255 | 266 | $tpl =& $this->tpls[$tplidx]; |
| 256 | 267 | $w = $tpl['w']; |
@@ -261,10 +272,12 @@ discard block |
||
| 261 | 272 | $_h = $h; |
| 262 | 273 | } |
| 263 | 274 | |
| 264 | - if($_w == 0) |
|
| 265 | - $_w = $_h * $w / $h; |
|
| 266 | - if($_h == 0) |
|
| 267 | - $_h = $_w * $h / $w; |
|
| 275 | + if($_w == 0) { |
|
| 276 | + $_w = $_h * $w / $h; |
|
| 277 | + } |
|
| 278 | + if($_h == 0) { |
|
| 279 | + $_h = $_w * $h / $w; |
|
| 280 | + } |
|
| 268 | 281 | |
| 269 | 282 | return array("w" => $_w, "h" => $_h); |
| 270 | 283 | } |
@@ -323,8 +336,9 @@ discard block |
||
| 323 | 336 | return parent::AddPage(...$args); |
| 324 | 337 | } |
| 325 | 338 | |
| 326 | - if ($this->_intpl) |
|
| 327 | - $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 339 | + if ($this->_intpl) { |
|
| 340 | + $this->Error('Adding pages in templates isn\'t possible!'); |
|
| 341 | + } |
|
| 328 | 342 | |
| 329 | 343 | parent::AddPage($orientation, $format); |
| 330 | 344 | } |
@@ -338,8 +352,9 @@ discard block |
||
| 338 | 352 | return parent::Link(...$args); |
| 339 | 353 | } |
| 340 | 354 | |
| 341 | - if ($this->_intpl) |
|
| 342 | - $this->Error('Using links in templates aren\'t possible!'); |
|
| 355 | + if ($this->_intpl) { |
|
| 356 | + $this->Error('Using links in templates aren\'t possible!'); |
|
| 357 | + } |
|
| 343 | 358 | |
| 344 | 359 | parent::Link($x, $y, $w, $h, $link); |
| 345 | 360 | } |
@@ -351,8 +366,9 @@ discard block |
||
| 351 | 366 | |
| 352 | 367 | } |
| 353 | 368 | |
| 354 | - if ($this->_intpl) |
|
| 355 | - $this->Error('Adding links in templates aren\'t possible!'); |
|
| 369 | + if ($this->_intpl) { |
|
| 370 | + $this->Error('Adding links in templates aren\'t possible!'); |
|
| 371 | + } |
|
| 356 | 372 | return parent::AddLink(); |
| 357 | 373 | } |
| 358 | 374 | |
@@ -362,8 +378,9 @@ discard block |
||
| 362 | 378 | return parent::SetLink(...$args); |
| 363 | 379 | } |
| 364 | 380 | |
| 365 | - if ($this->_intpl) |
|
| 366 | - $this->Error('Setting links in templates aren\'t possible!'); |
|
| 381 | + if ($this->_intpl) { |
|
| 382 | + $this->Error('Setting links in templates aren\'t possible!'); |
|
| 383 | + } |
|
| 367 | 384 | parent::SetLink($link, $y, $page); |
| 368 | 385 | } |
| 369 | 386 | |
@@ -403,8 +420,9 @@ discard block |
||
| 403 | 420 | $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 404 | 421 | if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { |
| 405 | 422 | $this->_out('/Font <<'); |
| 406 | - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|
| 407 | - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 423 | + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) { |
|
| 424 | + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); |
|
| 425 | + } |
|
| 408 | 426 | $this->_out('>>'); |
| 409 | 427 | } |
| 410 | 428 | if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
@@ -412,12 +430,14 @@ discard block |
||
| 412 | 430 | { |
| 413 | 431 | $this->_out('/XObject <<'); |
| 414 | 432 | if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { |
| 415 | - foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|
| 416 | - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 433 | + foreach($this->_res['tpl'][$tplidx]['images'] as $image) { |
|
| 434 | + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); |
|
| 435 | + } |
|
| 417 | 436 | } |
| 418 | 437 | if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { |
| 419 | - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|
| 420 | - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 438 | + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) { |
|
| 439 | + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); |
|
| 440 | + } |
|
| 421 | 441 | } |
| 422 | 442 | $this->_out('>>'); |
| 423 | 443 | } |