| @@ -1,1550 +1,1746 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -class mpdfform { | |
| 4 | - | |
| 5 | -var $mpdf = null; | |
| 6 | - | |
| 7 | -var $forms; | |
| 8 | -var $formn; | |
| 9 | - | |
| 10 | -//Active Forms | |
| 11 | -var $formSubmitNoValueFields; | |
| 12 | -var $formExportType; | |
| 13 | -var $formSelectDefaultOption; | |
| 14 | -var $formUseZapD; | |
| 15 | -/* Form Styles */ | |
| 16 | -var $form_border_color; | |
| 17 | -var $form_background_color; | |
| 18 | -var $form_border_width; | |
| 19 | -var $form_border_style; | |
| 20 | -var $form_button_border_color; | |
| 21 | -var $form_button_background_color; | |
| 22 | -var $form_button_border_width; | |
| 23 | -var $form_button_border_style; | |
| 24 | -var $form_radio_color; | |
| 25 | -var $form_radio_background_color; | |
| 26 | - | |
| 27 | -var $form_element_spacing; | |
| 28 | - | |
| 29 | -// Active forms | |
| 30 | -var $formMethod; | |
| 31 | -var $formAction; | |
| 32 | -var $form_fonts; | |
| 33 | -var $form_radio_groups; | |
| 34 | -var $form_checkboxes; | |
| 35 | -var $pdf_acro_array; | |
| 36 | - | |
| 37 | -var $pdf_array_co; | |
| 38 | -var $array_form_button_js; | |
| 39 | -var $array_form_choice_js; | |
| 40 | -var $array_form_text_js; | |
| 41 | - | |
| 42 | -/* Button Text */ | |
| 43 | -var $form_button_text; | |
| 44 | -var $form_button_text_over; | |
| 45 | -var $form_button_text_click; | |
| 46 | -var $form_button_icon; | |
| 47 | - | |
| 48 | - | |
| 49 | -// FORMS | |
| 50 | -var $textarea_lineheight; | |
| 51 | - | |
| 52 | -function mpdfform(&$mpdf) { | |
| 53 | - $this->mpdf = $mpdf; | |
| 54 | - | |
| 55 | - // ACTIVE FORMS | |
| 56 | - $this->formExportType = 'xfdf'; // 'xfdf' or 'html' | |
| 57 | - $this->formSubmitNoValueFields = true; // Whether to include blank fields when submitting data | |
| 58 | - $this->formSelectDefaultOption = true; // for Select drop down box; if no option is explicitly maked as selected, | |
| 59 | - // this determines whether to select 1st option (as per browser) | |
| 60 | - // - affects whether "required" attribute is relevant | |
| 61 | - $this->formUseZapD = true; // Determine whether to use ZapfDingbat icons for radio/checkboxes | |
| 62 | - | |
| 63 | - // FORM STYLES | |
| 64 | - // These can alternatively use a 4 number string to represent CMYK colours | |
| 65 | - $this->form_border_color = '0.6 0.6 0.72'; // RGB | |
| 66 | - $this->form_background_color = '0.975 0.975 0.975'; // RGB | |
| 67 | - $this->form_border_width = '1'; // 0 doesn't seem to work as it should | |
| 68 | - $this->form_border_style = 'S'; // B - Bevelled; D - Double | |
| 69 | - $this->form_button_border_color = '0.2 0.2 0.55'; | |
| 70 | - $this->form_button_background_color = '0.941 0.941 0.941'; | |
| 71 | - $this->form_button_border_width = '1'; | |
| 72 | - $this->form_button_border_style = 'S'; | |
| 73 | - $this->form_radio_color = '0.0 0.0 0.4'; // radio and checkbox | |
| 74 | - $this->form_radio_background_color = '0.9 0.9 0.9'; | |
| 75 | - | |
| 76 | - // FORMS | |
| 77 | - $this->textarea_lineheight = 1.25; | |
| 78 | - | |
| 79 | - // FORM ELEMENT SPACING | |
| 80 | - $this->form_element_spacing['select']['outer']['h'] = 0.5; // Horizontal spacing around SELECT | |
| 81 | - $this->form_element_spacing['select']['outer']['v'] = 0.5; // Vertical spacing around SELECT | |
| 82 | - $this->form_element_spacing['select']['inner']['h'] = 0.7; // Horizontal padding around SELECT | |
| 83 | - $this->form_element_spacing['select']['inner']['v'] = 0.7; // Vertical padding around SELECT | |
| 84 | - $this->form_element_spacing['input']['outer']['h'] = 0.5; | |
| 85 | - $this->form_element_spacing['input']['outer']['v'] = 0.5; | |
| 86 | - $this->form_element_spacing['input']['inner']['h'] = 0.7; | |
| 87 | - $this->form_element_spacing['input']['inner']['v'] = 0.7; | |
| 88 | - $this->form_element_spacing['textarea']['outer']['h'] = 0.5; | |
| 89 | - $this->form_element_spacing['textarea']['outer']['v'] = 0.5; | |
| 90 | - $this->form_element_spacing['textarea']['inner']['h'] = 1; | |
| 91 | - $this->form_element_spacing['textarea']['inner']['v'] = 0.5; | |
| 92 | - $this->form_element_spacing['button']['outer']['h'] = 0.5; | |
| 93 | - $this->form_element_spacing['button']['outer']['v'] = 0.5; | |
| 94 | - $this->form_element_spacing['button']['inner']['h'] = 2; | |
| 95 | - $this->form_element_spacing['button']['inner']['v'] = 1; | |
| 96 | - | |
| 97 | - // INITIALISE non-configurable | |
| 98 | - $this->formMethod = 'POST'; | |
| 99 | - $this->formAction = ''; | |
| 100 | - $this->form_fonts = array(); | |
| 101 | - $this->form_radio_groups = array(); | |
| 102 | - $this->form_checkboxes = false; | |
| 103 | - $this->forms = array(); | |
| 104 | - $this->pdf_array_co = ''; | |
| 105 | - | |
| 106 | - | |
| 107 | -} | |
| 108 | - | |
| 109 | - | |
| 110 | -function print_ob_text($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) { | |
| 111 | - // TEXT/PASSWORD INPUT | |
| 112 | - if ($this->mpdf->useActiveForms) { | |
| 113 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 114 | - $flags = array(); | |
| 115 | - if ((isset($objattr['disabled']) && $objattr['disabled']) || (isset($objattr['readonly']) && $objattr['readonly'])) { $flags[] = 1; } // readonly | |
| 116 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 117 | - $flags[] = 3; // no export | |
| 118 | - $objattr['color'] = array(3,128,128,128); // gray out disabled | |
| 119 | - } | |
| 120 | - if (isset($objattr['required']) && $objattr['required']) { $flags[] = 2; } // required | |
| 121 | - if (!isset($objattr['spellcheck']) || !$objattr['spellcheck']) { $flags[] = 23; } // DoNotSpellCheck | |
| 122 | - if (isset($objattr['subtype']) && $objattr['subtype']=='PASSWORD') { | |
| 123 | - $flags[] = 14; | |
| 124 | - $val = $objattr['value']; | |
| 125 | - } | |
| 126 | - if (isset($objattr['color'])) { | |
| 127 | - $this->mpdf->SetTColor($objattr['color']); | |
| 128 | - } | |
| 129 | - else { | |
| 130 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 131 | - } | |
| 132 | - $fieldalign = $rtlalign; | |
| 133 | - if (isset($objattr['text_align']) && $objattr['text_align']) { $fieldalign = $objattr['text_align']; } | |
| 134 | - else { $val = $objattr['text']; } | |
| 135 | - // mPDF 5.3.25 | |
| 136 | - $js = array(); | |
| 137 | - if (isset($objattr['onCalculate']) && $objattr['onCalculate']) { $js[] = array('C', $objattr['onCalculate']); } | |
| 138 | - if (isset($objattr['onValidate']) && $objattr['onValidate']) { $js[] = array('V', $objattr['onValidate']); } | |
| 139 | - if (isset($objattr['onFormat']) && $objattr['onFormat']) { $js[] = array('F', $objattr['onFormat']); } | |
| 140 | - if (isset($objattr['onKeystroke']) && $objattr['onKeystroke']) { $js[] = array('K', $objattr['onKeystroke']); } | |
| 141 | - $this->SetFormText( $w, $h, $objattr['fieldname'], $val, $val, $objattr['title'], $flags, $fieldalign, false, (isset($objattr['maxlength']) ? $objattr['maxlength'] : false), $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false) ); | |
| 142 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 143 | - } | |
| 144 | - else { | |
| 145 | - $w -= $this->form_element_spacing['input']['outer']['h']*2 /$k; | |
| 146 | - $h -= $this->form_element_spacing['input']['outer']['v']*2 /$k; | |
| 147 | - $this->mpdf->x += $this->form_element_spacing['input']['outer']['h'] /$k; | |
| 148 | - $this->mpdf->y += $this->form_element_spacing['input']['outer']['v'] /$k; | |
| 149 | - // Chop texto to max length $w-inner-padding | |
| 150 | - while ($this->mpdf->GetStringWidth($texto) > $w-($this->form_element_spacing['input']['inner']['h']*2)) { | |
| 151 | - $texto = mb_substr($texto,0,mb_strlen($texto,$this->mpdf->mb_enc)-1,$this->mpdf->mb_enc); | |
| 152 | - } | |
| 153 | - | |
| 154 | - // DIRECTIONALITY | |
| 155 | - if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; } // *RTL* | |
| 156 | - | |
| 157 | - // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 158 | - if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 159 | - $texto = $this->mpdf->otl->applyOTL($texto, $this->mpdf->CurrentFont['useOTL']); | |
| 160 | - $OTLdata = $this->mpdf->otl->OTLdata; | |
| 161 | - } | |
| 162 | - | |
| 163 | - $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $OTLdata); | |
| 164 | - | |
| 165 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 166 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 167 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 168 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 169 | - } | |
| 170 | - else if (isset($objattr['readonly']) && $objattr['readonly']) { | |
| 171 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 172 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 173 | - } | |
| 174 | - else { | |
| 175 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 176 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 177 | - } | |
| 178 | - $this->mpdf->Cell($w,$h,$texto,1,0,$rtlalign,1,'',0,$this->form_element_spacing['input']['inner']['h'] /$k ,$this->form_element_spacing['input']['inner']['h'] /$k , 'M', 0, false, $OTLdata); | |
| 179 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 180 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 181 | - } | |
| 182 | -} | |
| 183 | - | |
| 184 | -function print_ob_textarea($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) { | |
| 185 | - // TEXTAREA | |
| 186 | - if ($this->mpdf->useActiveForms) { | |
| 187 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 188 | - $flags = array(); | |
| 189 | - $flags = array(13); // textarea | |
| 190 | - if ((isset($objattr['disabled']) && $objattr['disabled']) || (isset($objattr['readonly']) && $objattr['readonly'])) { $flags[] = 1; } // readonly | |
| 191 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 192 | - $flags[] = 3; // no export | |
| 193 | - $objattr['color'] = array(3,128,128,128); // gray out disabled | |
| 194 | - } | |
| 195 | - if (isset($objattr['required']) && $objattr['required']) { $flags[] = 2; } // required | |
| 196 | - if (!isset($objattr['spellcheck']) || !$objattr['spellcheck']) { $flags[] = 23; } // DoNotSpellCheck | |
| 197 | - if (isset($objattr['donotscroll']) && $objattr['donotscroll']) { $flags[] = 24; } // DoNotScroll | |
| 198 | - if (isset($objattr['color'])) { | |
| 199 | - $this->mpdf->SetTColor($objattr['color']); | |
| 200 | - } | |
| 201 | - else { | |
| 202 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 203 | - } | |
| 204 | - $fieldalign = $rtlalign; | |
| 205 | - if ($texto == ' ') { $texto = ''; } // mPDF 5.3.24 | |
| 206 | - if (isset($objattr['text_align']) && $objattr['text_align']) { $fieldalign = $objattr['text_align']; } | |
| 207 | - // mPDF 5.3.25 | |
| 208 | - $js = array(); | |
| 209 | - if (isset($objattr['onCalculate']) && $objattr['onCalculate']) { $js[] = array('C', $objattr['onCalculate']); } | |
| 210 | - if (isset($objattr['onValidate']) && $objattr['onValidate']) { $js[] = array('V', $objattr['onValidate']); } | |
| 211 | - if (isset($objattr['onFormat']) && $objattr['onFormat']) { $js[] = array('F', $objattr['onFormat']); } | |
| 212 | - if (isset($objattr['onKeystroke']) && $objattr['onKeystroke']) { $js[] = array('K', $objattr['onKeystroke']); } | |
| 213 | - $this->SetFormText( $w, $h, $objattr['fieldname'], $texto, $texto, (isset($objattr['title']) ? $objattr['title'] : ''), $flags, $fieldalign , false, -1, $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false)); | |
| 214 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 215 | - } | |
| 216 | - else { | |
| 217 | - $w -= $this->form_element_spacing['textarea']['outer']['h']*2 /$k ; | |
| 218 | - $h -= $this->form_element_spacing['textarea']['outer']['v']*2 /$k ; | |
| 219 | - $this->mpdf->x += $this->form_element_spacing['textarea']['outer']['h'] /$k ; | |
| 220 | - $this->mpdf->y += $this->form_element_spacing['textarea']['outer']['v'] /$k ; | |
| 221 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 222 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 223 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 224 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 225 | - } | |
| 226 | - else if (isset($objattr['readonly']) && $objattr['readonly']) { | |
| 227 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 228 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 229 | - } | |
| 230 | - else { | |
| 231 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 232 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 233 | - } | |
| 234 | - $this->mpdf->Rect($this->mpdf->x,$this->mpdf->y,$w,$h,'DF'); | |
| 235 | - $ClipPath = sprintf('q %.3F %.3F %.3F %.3F re W n ',$this->mpdf->x*_MPDFK,($this->mpdf->h-$this->mpdf->y)*_MPDFK,$w*_MPDFK,-$h*_MPDFK); | |
| 236 | - $this->mpdf->_out($ClipPath); | |
| 237 | - | |
| 238 | - $w -= $this->form_element_spacing['textarea']['inner']['h']*2 /$k ; | |
| 239 | - $this->mpdf->x += $this->form_element_spacing['textarea']['inner']['h'] /$k ; | |
| 240 | - $this->mpdf->y += $this->form_element_spacing['textarea']['inner']['v'] /$k ; | |
| 241 | - | |
| 242 | - if ($texto != '') $this->mpdf->MultiCell($w,$this->mpdf->FontSize*$this->textarea_lineheight,$texto,0,'',0,'',$blockdir,true,$objattr['OTLdata'], $objattr['rows']); | |
| 243 | - $this->mpdf->_out('Q'); | |
| 244 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 245 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 246 | - } | |
| 247 | -} | |
| 248 | - | |
| 249 | -function print_ob_select($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) { | |
| 250 | - // SELECT | |
| 251 | - if ($this->mpdf->useActiveForms) { | |
| 252 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; 19 - edit (only if combo) | |
| 253 | - $flags = array(); | |
| 254 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 255 | - $flags[] = 1; // readonly | |
| 256 | - $flags[] = 3; // no export | |
| 257 | - $objattr['color'] = array(3,128,128,128); // gray out disabled | |
| 258 | - } | |
| 259 | - if (isset($objattr['required']) && $objattr['required']) { $flags[] = 2; } // required | |
| 260 | - if (isset($objattr['multiple']) && $objattr['multiple'] && isset($objattr['size']) && $objattr['size']>1) { $flags[] = 22; } //flag 22 = multiselect (listbox) | |
| 261 | - if (isset($objattr['size']) && $objattr['size']<2) { | |
| 262 | - $flags[] = 18; //flag 18 = combobox (else a listbox) | |
| 263 | - if (isset($objattr['editable']) && $objattr['editable']) { $flags[] = 19; } // editable | |
| 264 | - } | |
| 265 | - // only allow spellcheck if combo and editable | |
| 266 | - if ((!isset($objattr['spellcheck']) || !$objattr['spellcheck']) || (isset($objattr['size']) && $objattr['size']>1) || (!isset($objattr['editable']) || !$objattr['editable'])) { $flags[] = 23; } // DoNotSpellCheck | |
| 267 | - if (isset($objattr['subtype']) && $objattr['subtype']=='PASSWORD') { $flags[] = 14; } | |
| 268 | - if (isset($objattr['onChange']) && $objattr['onChange']) { $js = $objattr['onChange']; } | |
| 269 | - else { $js = ''; } // mPDF 5.3.37 | |
| 270 | - $data = array('VAL' => array(), 'OPT' => array(), 'SEL' => array(), ); | |
| 271 | - if (isset($objattr['items'])) { | |
| 272 | - for($i=0; $i<count($objattr['items']); $i++) { | |
| 273 | - $item = $objattr['items'][$i]; | |
| 274 | - $data['VAL'][] = (isset($item['exportValue']) ? $item['exportValue'] : ''); | |
| 275 | - $data['OPT'][] = (isset($item['content']) ? $item['content'] : ''); | |
| 276 | - if (isset($item['selected']) && $item['selected']) { $data['SEL'][] = $i; } | |
| 277 | - } | |
| 278 | - } | |
| 279 | - if (count($data['SEL'])==0 && $this->formSelectDefaultOption) {$data['SEL'][] = 0; } | |
| 280 | - if (isset($objattr['color'])) { | |
| 281 | - $this->mpdf->SetTColor($objattr['color']); | |
| 282 | - } | |
| 283 | - else { | |
| 284 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 285 | - } | |
| 286 | - $this->SetFormChoice( $w, $h, $objattr['fieldname'], $flags, $data, $rtlalign, $js ); | |
| 287 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 288 | - } | |
| 289 | - else { | |
| 290 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 291 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 292 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 293 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 294 | - } | |
| 295 | - else { | |
| 296 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 297 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 298 | - } | |
| 299 | - $w -= $this->form_element_spacing['select']['outer']['h']*2 /$k ; | |
| 300 | - $h -= $this->form_element_spacing['select']['outer']['v']*2 /$k ; | |
| 301 | - $this->mpdf->x += $this->form_element_spacing['select']['outer']['h'] /$k ; | |
| 302 | - $this->mpdf->y += $this->form_element_spacing['select']['outer']['v'] /$k ; | |
| 303 | - | |
| 304 | - // DIRECTIONALITY | |
| 305 | - if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; } // *RTL* | |
| 306 | - | |
| 307 | - $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $objattr['OTLdata']); | |
| 308 | - | |
| 309 | - $this->mpdf->Cell($w-($this->mpdf->FontSize*1.4),$h,$texto,1,0,$rtlalign,1,'',0,$this->form_element_spacing['select']['inner']['h'] /$k,$this->form_element_spacing['select']['inner']['h'] /$k , 'M', 0, false, $objattr['OTLdata']) ; | |
| 310 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(190)); | |
| 311 | - $save_font = $this->mpdf->FontFamily; | |
| 312 | - $save_currentfont = $this->mpdf->currentfontfamily; | |
| 313 | - if ($this->mpdf->PDFA || $this->mpdf->PDFX) { | |
| 314 | - if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $this->mpdf->PDFAXwarnings[] = "Core Adobe font Zapfdingbats cannot be embedded in mPDF - used in Form element: Select - which is required for PDFA1-b or PDFX/1-a. (Different character/font will be substituted.)"; } | |
| 315 | - $this->mpdf->SetFont('sans'); | |
| 316 | - if ($this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9660)) { $down = "\xe2\x96\xbc"; } | |
| 317 | - else { $down = '='; } | |
| 318 | - $this->mpdf->Cell(($this->mpdf->FontSize*1.4),$h,$down,1,0,'C',1,'',0,0,0, 'M') ; | |
| 319 | - } | |
| 320 | - else { | |
| 321 | - $this->mpdf->SetFont('czapfdingbats','',0); | |
| 322 | - $this->mpdf->Cell(($this->mpdf->FontSize*1.4),$h,chr(116),1,0,'C',1,'',0,0,0, 'M') ; | |
| 323 | - } | |
| 324 | - $this->mpdf->SetFont($save_font,'',0); | |
| 325 | - $this->mpdf->currentfontfamily = $save_currentfont; | |
| 326 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 327 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 328 | - } | |
| 329 | -} | |
| 330 | - | |
| 331 | -function print_ob_imageinput($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) { | |
| 332 | - // INPUT/BUTTON as IMAGE | |
| 333 | - if ($this->mpdf->useActiveForms) { | |
| 334 | - // Flags: 1 - Readonly; 3 - No export; | |
| 335 | - $flags = array(); | |
| 336 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 337 | - $flags[] = 1; // readonly | |
| 338 | - $flags[] = 3; // no export | |
| 339 | - } | |
| 340 | - if (isset($objattr['onClick']) && $objattr['onClick']) { $js = $objattr['onClick']; } | |
| 341 | - else { $js = ''; } | |
| 342 | - $this->SetJSButton( $w, $h, $objattr['fieldname'], (isset($objattr['value']) ? $objattr['value'] : ''), $js, $objattr['ID'], $objattr['title'], $flags, (isset($objattr['Indexed']) ? $objattr['Indexed'] : false)); | |
| 343 | - } | |
| 344 | - else { | |
| 345 | - $this->mpdf->y = $objattr['INNER-Y']; | |
| 346 | - $this->mpdf->_out( sprintf("q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q",$objattr['INNER-WIDTH'] *_MPDFK,$objattr['INNER-HEIGHT'] *_MPDFK,$objattr['INNER-X'] *_MPDFK,($this->mpdf->h-($objattr['INNER-Y'] +$objattr['INNER-HEIGHT'] ))*_MPDFK,$objattr['ID'] ) ); | |
| 347 | - if (isset($objattr['BORDER-WIDTH']) && $objattr['BORDER-WIDTH']) { $this->mpdf->PaintImgBorder($objattr,$is_table); } | |
| 348 | - } | |
| 349 | -} | |
| 350 | - | |
| 351 | -function print_ob_button($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) { | |
| 352 | - // BUTTON | |
| 353 | - if ($this->mpdf->useActiveForms) { | |
| 354 | - // Flags: 1 - Readonly; 3 - No export; | |
| 355 | - $flags = array(); | |
| 356 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 357 | - $flags[] = 1; // readonly | |
| 358 | - $flags[] = 3; // no export | |
| 359 | - $objattr['color'] = array(3,128,128,128); | |
| 360 | - } | |
| 361 | - if (isset($objattr['color'])) { | |
| 362 | - $this->mpdf->SetTColor($objattr['color']); | |
| 363 | - } | |
| 364 | - else { | |
| 365 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 366 | - } | |
| 367 | - if (isset($objattr['subtype']) && $objattr['subtype'] == 'RESET') { | |
| 368 | - $this->SetFormButtonText( $objattr['value'] ); | |
| 369 | - $this->SetFormReset( $w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $flags, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false) ); | |
| 370 | - } | |
| 371 | - else if (isset($objattr['subtype']) && $objattr['subtype'] == 'SUBMIT') { | |
| 372 | - $url = $this->formAction; | |
| 373 | - $type = $this->formExportType; | |
| 374 | - $method = $this->formMethod; | |
| 375 | - $this->SetFormButtonText( $objattr['value'] ); | |
| 376 | - $this->SetFormSubmit( $w, $h, $objattr['fieldname'], $objattr['value'], $url, $objattr['title'], $type, $method, $flags, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false) ); | |
| 377 | - } | |
| 378 | - else if (isset($objattr['subtype']) && $objattr['subtype'] == 'BUTTON') { | |
| 379 | - $this->SetFormButtonText( $objattr['value'] ); | |
| 380 | - if (isset($objattr['onClick']) && $objattr['onClick']) { $js = $objattr['onClick']; } | |
| 381 | - else { $js = ''; } | |
| 382 | - $this->SetJSButton( $w, $h, $objattr['fieldname'], $objattr['value'], $js, 0, $objattr['title'], $flags, false, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false) ); | |
| 383 | - } | |
| 384 | - $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 385 | - } | |
| 386 | - else { | |
| 387 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 388 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(190)); | |
| 389 | - $w -= $this->form_element_spacing['button']['outer']['h']*2 /$k ; | |
| 390 | - $h -= $this->form_element_spacing['button']['outer']['v']*2 /$k ; | |
| 391 | - $this->mpdf->x += $this->form_element_spacing['button']['outer']['h'] /$k ; | |
| 392 | - $this->mpdf->y += $this->form_element_spacing['button']['outer']['v'] /$k ; | |
| 393 | - $this->mpdf->RoundedRect($this->mpdf->x, $this->mpdf->y, $w, $h, 0.5 /$k , 'DF'); | |
| 394 | - $w -= $this->form_element_spacing['button']['inner']['h']*2 /$k ; | |
| 395 | - $h -= $this->form_element_spacing['button']['inner']['v']*2 /$k ; | |
| 396 | - $this->mpdf->x += $this->form_element_spacing['button']['inner']['h'] /$k ; | |
| 397 | - $this->mpdf->y += $this->form_element_spacing['button']['inner']['v'] /$k ; | |
| 398 | - | |
| 399 | - // DIRECTIONALITY | |
| 400 | - if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $texto)) { $this->mpdf->biDirectional = true; } // *RTL* | |
| 401 | - | |
| 402 | - // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 403 | - if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 404 | - $texto = $this->mpdf->otl->applyOTL($texto, $this->mpdf->CurrentFont['useOTL']); | |
| 405 | - $OTLdata = $this->mpdf->otl->OTLdata; | |
| 406 | - } | |
| 407 | - | |
| 408 | - $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $OTLdata); | |
| 409 | - | |
| 410 | - $this->mpdf->Cell($w,$h,$texto,'',0,'C',0,'',0,0,0, 'M', 0, false, $OTLdata ) ; | |
| 411 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(0)); | |
| 412 | - } | |
| 413 | -} | |
| 414 | - | |
| 415 | -function print_ob_checkbox($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) { | |
| 416 | - // CHECKBOX | |
| 417 | - if ($this->mpdf->useActiveForms) { | |
| 418 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; | |
| 419 | - $flags = array(); | |
| 420 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 421 | - $flags[] = 1; // readonly | |
| 422 | - $flags[] = 3; // no export | |
| 423 | - } | |
| 424 | - $checked = false; | |
| 425 | - if (isset($objattr['checked']) && $objattr['checked']) { $checked = true; } | |
| 426 | - if ($this->formUseZapD) { | |
| 427 | - $save_font = $this->mpdf->FontFamily; | |
| 428 | - $save_currentfont = $this->mpdf->currentfontfamily; | |
| 429 | - $this->mpdf->SetFont('czapfdingbats','',0); | |
| 430 | - } | |
| 431 | - $this->SetCheckBox( $w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $checked, $flags, (isset($objattr['disabled']) ? $objattr['disabled'] : false)); | |
| 432 | - if ($this->formUseZapD) { | |
| 433 | - $this->mpdf->SetFont($save_font,'',0); | |
| 434 | - $this->mpdf->currentfontfamily = $save_currentfont; | |
| 435 | - } | |
| 436 | - } | |
| 437 | - else { | |
| 438 | - $iw = $w * 0.7; | |
| 439 | - $ih = $h * 0.7; | |
| 440 | - $lx = $x + (($w-$iw)/2); | |
| 441 | - $ty = $y + (($h-$ih)/2); | |
| 442 | - $rx = $lx + $iw; | |
| 443 | - $by = $ty + $ih; | |
| 444 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 445 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 446 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 447 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(127)); | |
| 448 | - } | |
| 449 | - else { | |
| 450 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 451 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 452 | - } | |
| 453 | - $this->mpdf->Rect($lx,$ty,$iw,$ih,'DF'); | |
| 454 | - if (isset($objattr['checked']) && $objattr['checked']) { | |
| 455 | - //Round join and cap | |
| 456 | - $this->mpdf->SetLineCap(1); | |
| 457 | - $this->mpdf->Line($lx,$ty,$rx,$by); | |
| 458 | - $this->mpdf->Line($lx,$by,$rx,$ty); | |
| 459 | - //Set line cap style back to square | |
| 460 | - $this->mpdf->SetLineCap(2); | |
| 461 | - } | |
| 462 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 463 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 464 | - } | |
| 465 | -} | |
| 466 | - | |
| 467 | -function print_ob_radio($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) { | |
| 468 | - // RADIO | |
| 469 | - if ($this->mpdf->useActiveForms) { | |
| 470 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; | |
| 471 | - $flags = array(); | |
| 472 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 473 | - $flags[] = 1; // readonly | |
| 474 | - $flags[] = 3; // no export | |
| 475 | - } | |
| 476 | - $checked = false; | |
| 477 | - if (isset($objattr['checked']) && $objattr['checked']) { $checked = true; } | |
| 478 | - if ($this->formUseZapD) { | |
| 479 | - $save_font = $this->mpdf->FontFamily; | |
| 480 | - $save_currentfont = $this->mpdf->currentfontfamily; | |
| 481 | - $this->mpdf->SetFont('czapfdingbats','',0); | |
| 482 | - } | |
| 483 | - $this->SetRadio( $w, $h, $objattr['fieldname'], $objattr['value'], (isset($objattr['title']) ? $objattr['title'] : ''), $checked, $flags, (isset($objattr['disabled']) ? $objattr['disabled'] : false) ); | |
| 484 | - if ($this->formUseZapD) { | |
| 485 | - $this->mpdf->SetFont($save_font,'',0); | |
| 486 | - $this->mpdf->currentfontfamily = $save_currentfont; | |
| 487 | - } | |
| 488 | - } | |
| 489 | - else { | |
| 490 | - $this->mpdf->SetLineWidth(0.2 /$k ); | |
| 491 | - $radius = $this->mpdf->FontSize *0.35; | |
| 492 | - $cx = $x + ($w/2); | |
| 493 | - $cy = $y + ($h/2); | |
| 494 | - if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 495 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(127)); | |
| 496 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(127)); | |
| 497 | - } | |
| 498 | - else { | |
| 499 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(0)); | |
| 500 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 501 | - } | |
| 502 | - $this->mpdf->Circle($cx,$cy,$radius,'D'); | |
| 503 | - if (isset($objattr['checked']) && $objattr['checked']) { | |
| 504 | - $this->mpdf->Circle($cx,$cy,$radius*0.4,'DF'); | |
| 505 | - } | |
| 506 | - $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 507 | - $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 508 | - | |
| 509 | - } | |
| 510 | -} | |
| 511 | - | |
| 512 | - | |
| 513 | - | |
| 514 | -// In _putpages | |
| 515 | -function countPageForms($n, &$totaladdnum) { | |
| 516 | - foreach( $this->forms as $form ) { | |
| 517 | - if ( $form['page'] == $n ) { | |
| 518 | - $totaladdnum++; | |
| 519 | - if ( $form['typ'] == 'Tx' ) { | |
| 520 | - if ( isset($this->array_form_text_js[$form['T']]) ) { | |
| 521 | - if ( isset($this->array_form_text_js[$form['T']]['F']) ) { $totaladdnum++; } | |
| 522 | - if ( isset($this->array_form_text_js[$form['T']]['K']) ) { $totaladdnum++; } | |
| 523 | - if ( isset($this->array_form_text_js[$form['T']]['V']) ) { $totaladdnum++; } | |
| 524 | - if ( isset($this->array_form_text_js[$form['T']]['C']) ) { $totaladdnum++; } | |
| 525 | - } | |
| 526 | - } | |
| 527 | - if ( $form['typ'] == 'Bt' ) { | |
| 528 | - if ( isset($this->array_form_button_js[$form['T']]) ) { $totaladdnum++; } | |
| 529 | - if ( isset($this->form_button_icon[$form['T']]) ) { | |
| 530 | - $totaladdnum++; | |
| 531 | - if ( $this->form_button_icon[$form['T']]['Indexed'] ) { $totaladdnum++; } | |
| 532 | - } | |
| 533 | - if ( $form['subtype'] == 'radio' ) { $totaladdnum+=2; } | |
| 534 | - else if ( $form['subtype'] == 'checkbox' && $this->formUseZapD ) { $totaladdnum++; } | |
| 535 | - else if ( $form['subtype'] == 'checkbox' && !$this->formUseZapD ) { $totaladdnum+=2; } | |
| 536 | - } | |
| 537 | - if ( $form['typ'] == 'Ch' ) { | |
| 538 | - if ( isset($this->array_form_choice_js[$form['T']]) ) { $totaladdnum++; } | |
| 539 | - } | |
| 540 | - } | |
| 541 | - } | |
| 542 | -} | |
| 543 | - | |
| 544 | -// In _putpages | |
| 545 | -function addFormIds($n, &$s, &$annotid) { | |
| 546 | - foreach( $this->forms as $form ) { | |
| 547 | - if ( $form['page'] == $n ) { | |
| 548 | - $s .= ($annotid) . ' 0 R '; | |
| 549 | - $annotid++; | |
| 550 | - if ( $form['typ'] == 'Tx' ) { | |
| 551 | - if ( isset($this->array_form_text_js[$form['T']]) ) { | |
| 552 | - if ( isset($this->array_form_text_js[$form['T']]['F']) ) { $annotid++; } | |
| 553 | - if ( isset($this->array_form_text_js[$form['T']]['K']) ) { $annotid++; } | |
| 554 | - if ( isset($this->array_form_text_js[$form['T']]['V']) ) { $annotid++; } | |
| 555 | - if ( isset($this->array_form_text_js[$form['T']]['C']) ) { $annotid++; } | |
| 556 | - } | |
| 557 | - } | |
| 558 | - if ( $form['typ'] == 'Bt' ) { | |
| 559 | - if ( isset($this->array_form_button_js[$form['T']]) ) { $annotid++; } | |
| 560 | - if ( isset($this->form_button_icon[$form['T']]) ) { | |
| 561 | - $annotid++; | |
| 562 | - if ( $this->form_button_icon[$form['T']]['Indexed'] ) { $annotid++; } | |
| 563 | - } | |
| 564 | - if ( $form['subtype'] == 'radio' ) { $annotid+=2; } | |
| 565 | - else if ( $form['subtype'] == 'checkbox' && $this->formUseZapD ) { $annotid++; } | |
| 566 | - else if ( $form['subtype'] == 'checkbox' && !$this->formUseZapD ) { $annotid+=2; } | |
| 567 | - } | |
| 568 | - if ( $form['typ'] == 'Ch' ) { | |
| 569 | - if ( isset($this->array_form_choice_js[$form['T']]) ) { $annotid++; } | |
| 570 | - } | |
| 571 | - } | |
| 572 | - } | |
| 573 | -} | |
| 574 | - | |
| 575 | -// In _putannots | |
| 576 | -function _putFormItems($n, $hPt) { | |
| 577 | - foreach( $this->forms as $val) { | |
| 578 | - if ( $val['page'] == $n ) { | |
| 579 | - if ( $val['typ'] == 'Tx' ) $this->_putform_tx( $val, $hPt ); | |
| 580 | - if ( $val['typ'] == 'Ch' ) $this->_putform_ch( $val, $hPt ); | |
| 581 | - if ( $val['typ'] == 'Bt' ) $this->_putform_bt( $val, $hPt ); | |
| 582 | - } | |
| 583 | - } | |
| 584 | -} | |
| 585 | - | |
| 586 | -// In _putannots | |
| 587 | -function _putRadioItems($n) { | |
| 588 | - // Output Radio Groups | |
| 589 | - $key = 1; | |
| 590 | - foreach($this->form_radio_groups AS $name=>$frg) { | |
| 591 | - $this->mpdf->_newobj(); | |
| 592 | - $this->pdf_acro_array .= $this->mpdf->n.' 0 R '; | |
| 593 | - $this->mpdf->_out('<<'); | |
| 594 | - $this->mpdf->_out('/Type /Annot '); | |
| 595 | - $this->mpdf->_out('/Subtype /Widget'); | |
| 596 | - $this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (3000 + $key++)))); | |
| 597 | - $this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis'))); | |
| 598 | - $this->mpdf->_out('/Rect [0 0 0 0] '); | |
| 599 | - $this->mpdf->_out('/FT /Btn '); | |
| 600 | - if (isset($frg['disabled']) && $frg['disabled']) { $flags=array(1,3,15,16); } // NoExport and readonly | |
| 601 | - else { $flags=array(15,16); } // Flags for Radiobutton, and NoToggleToOff | |
| 602 | - $this->mpdf->_out('/Ff '.$this->_setflag($flags) ); | |
| 603 | - $kstr = ''; | |
| 604 | - $optstr = ''; | |
| 605 | - foreach($frg['kids'] AS $kid) { | |
| 606 | - $kstr .= $this->forms[$kid['n']]['obj'].' 0 R '; | |
| 607 | - // $optstr .= ' '.$this->mpdf->_textstring($kid['OPT']).' '; | |
| 608 | - } | |
| 609 | - $this->mpdf->_out('/Kids [ '.$kstr.' ] '); // 11 0 R 12 0 R etc. | |
| 610 | - // $this->mpdf->_out('/Opt [ '.$optstr.' ] '); | |
| 611 | - | |
| 612 | - //V entry holds index corresponding to the appearance state of | |
| 613 | - //whichever child field is currently in the on state = or Off | |
| 614 | - if (isset($frg['on'])) { $state = $frg['on']; } | |
| 615 | - else { $state = 'Off'; } | |
| 616 | - $this->mpdf->_out('/V /'.$state.' '); | |
| 617 | - $this->mpdf->_out('/DV /'.$state.' '); | |
| 618 | - $this->mpdf->_out('/T '.$this->mpdf->_textstring($name).' '); | |
| 619 | - $this->mpdf->_out('>>'); | |
| 620 | - $this->mpdf->_out('endobj'); | |
| 621 | - } | |
| 622 | -} | |
| 623 | - | |
| 624 | -function _putFormsCatalog() { | |
| 625 | - if (isset($this->pdf_acro_array) ) { | |
| 626 | - $this->mpdf->_out('/AcroForm << /DA (/F1 0 Tf 0 g )'); | |
| 627 | - $this->mpdf->_out('/Q 0'); | |
| 628 | - $this->mpdf->_out('/Fields ['.$this->pdf_acro_array.']'); | |
| 629 | - $f = ''; | |
| 630 | - foreach($this->form_fonts AS $fn) { | |
| 631 | - if (is_array($this->mpdf->fonts[$fn]['n'])) { $this->mpdf->Error("Cannot use fonts with SMP or SIP characters for interactive Form elements"); } | |
| 632 | - $f .= '/F'.$this->mpdf->fonts[$fn]['i'].' '.$this->mpdf->fonts[$fn]['n'].' 0 R '; | |
| 633 | - } | |
| 634 | - $this->mpdf->_out('/DR << /Font << '.$f.' >> >>'); | |
| 635 | - // CO Calculation Order | |
| 636 | - if ( $this->pdf_array_co ) { | |
| 637 | - $this->mpdf->_out('/CO ['.$this->pdf_array_co.']'); | |
| 638 | - } | |
| 639 | - $this->mpdf->_out('/NeedAppearances true'); | |
| 640 | - $this->mpdf->_out('>>'); | |
| 641 | - } | |
| 642 | -} | |
| 643 | - | |
| 644 | - | |
| 645 | - | |
| 646 | -function SetFormButtonJS( $name, $js ) { | |
| 647 | - $js = str_replace("\t",' ', trim($js) ); | |
| 648 | - if ( isset($name) && isset($js) ) { | |
| 649 | - $this->array_form_button_js[$this->mpdf->_escape($name)] = array( | |
| 650 | - 'js' => $js | |
| 651 | - ); | |
| 652 | - } | |
| 653 | -} | |
| 654 | - | |
| 655 | -function SetFormChoiceJS( $name, $js ) { | |
| 656 | - $js = str_replace("\t",' ', trim($js) ); | |
| 657 | - if ( isset($name) && isset($js) ) { | |
| 658 | - $this->array_form_choice_js[$this->mpdf->_escape($name)] = array( | |
| 659 | - 'js' => $js | |
| 660 | - ); | |
| 661 | - } | |
| 662 | -} | |
| 663 | - | |
| 664 | -function SetFormTextJS( $name, $js) { | |
| 665 | - for ($i=0; $i<count($js); $i++) { | |
| 666 | - $j = str_replace("\t",' ', trim($js[$i][1]) ); | |
| 667 | - $format = $js[$i][0]; | |
| 668 | - if ($name) { | |
| 669 | - $this->array_form_text_js[$this->mpdf->_escape($name)][$format] = array('js' => $j); | |
| 670 | - } | |
| 671 | - } | |
| 672 | -} | |
| 673 | - | |
| 674 | - | |
| 675 | -function Win1252ToPDFDocEncoding($txt) { | |
| 676 | - $Win1252ToPDFDocEncoding = array( | |
| 677 | - chr(0200) => chr(0240), chr(0214) => chr(0226), chr(0212) => chr(0227), chr(0237) => chr(0230), | |
| 678 | - chr(0225) => chr(0200), chr(0210) => chr(0032), chr(0206) => chr(0201), chr(0207) => chr(0202), | |
| 679 | - chr(0205) => chr(0203), chr(0227) => chr(0204), chr(0226) => chr(0205), chr(0203) => chr(0206), | |
| 680 | - chr(0213) => chr(0210), chr(0233) => chr(0211), chr(0211) => chr(0213), chr(0204) => chr(0214), | |
| 681 | - chr(0223) => chr(0215), chr(0224) => chr(0216), chr(0221) => chr(0217), chr(0222) => chr(0220), | |
| 682 | - chr(0202) => chr(0221), chr(0232) => chr(0235), chr(0230) => chr(0037), chr(0231) => chr(0222), | |
| 683 | - chr(0216) => chr(0231), chr(0240) => chr(0040) | |
| 684 | - ); // mPDF 5.3.46 | |
| 685 | - return strtr($txt, $Win1252ToPDFDocEncoding ); | |
| 686 | -} | |
| 687 | - | |
| 688 | - | |
| 689 | -function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $flags = array(), $align='L', $hidden = false, $maxlen=-1, $js='', $background_col=false, $border_col=false ) { | |
| 690 | - // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 691 | - $this->formn++; | |
| 692 | - if( $align == 'C' ) { $align = '1'; } | |
| 693 | - else if( $align == 'R' ) { $align = '2'; } | |
| 694 | - else { $align = '0'; } | |
| 695 | - if ($maxlen < 1) { $maxlen = false; } | |
| 696 | - if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 697 | - $this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 698 | - } | |
| 699 | - if ($this->mpdf->onlyCoreFonts) { | |
| 700 | - $value = $this->Win1252ToPDFDocEncoding($value); | |
| 701 | - $default = $this->Win1252ToPDFDocEncoding($default); | |
| 702 | - $title = $this->Win1252ToPDFDocEncoding($title); | |
| 703 | - } | |
| 704 | - else { | |
| 705 | - if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 706 | - $this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset | |
| 707 | - $this->mpdf->UTF8StringToArray($default, true); // Add characters to font subset | |
| 708 | - $this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset | |
| 709 | - } | |
| 710 | - if ($value) $value = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 711 | - if ($default ) $default = $this->mpdf->UTF8ToUTF16BE($default, true); | |
| 712 | - $title = $this->mpdf->UTF8ToUTF16BE($title, true); | |
| 713 | - } | |
| 714 | - if ($background_col) { $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); } | |
| 715 | - else { $bg_c = $this->form_background_color; } | |
| 716 | - if ($border_col) { $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); } | |
| 717 | - else { $bc_c = $this->form_border_color; } | |
| 718 | - $f = array( 'n' => $this->formn, | |
| 719 | - 'typ' => 'Tx', | |
| 720 | - 'page' => $this->mpdf->page, | |
| 721 | - 'x' => $this->mpdf->x, | |
| 722 | - 'y' => $this->mpdf->y, | |
| 723 | - 'w' => $w, | |
| 724 | - 'h' => $h, | |
| 725 | - 'T' => $name, | |
| 726 | - 'FF' => $flags, | |
| 727 | - 'V' => $value, | |
| 728 | - 'DV' => $default, | |
| 729 | - 'TU' => $title, | |
| 730 | - 'hidden' => $hidden, | |
| 731 | - 'Q' => $align, | |
| 732 | - 'maxlen' => $maxlen, | |
| 733 | - 'BS_W' => $this->form_border_width, | |
| 734 | - 'BS_S' => $this->form_border_style, | |
| 735 | - 'BC_C' => $bc_c, | |
| 736 | - 'BG_C' => $bg_c, | |
| 737 | - 'style' => array( | |
| 738 | - 'font' => $this->mpdf->FontFamily, | |
| 739 | - 'fontsize' => $this->mpdf->FontSizePt, | |
| 740 | - 'fontcolor' => $this->mpdf->TextColor, | |
| 741 | - ) | |
| 742 | - ); | |
| 743 | - if (is_array($js) && count($js)>0) { $this->SetFormTextJS( $name, $js); } // mPDF 5.3.25 | |
| 744 | - if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; } | |
| 745 | - else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; } | |
| 746 | - else { | |
| 747 | - if ($this->mpdf->ColActive) { | |
| 748 | - $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 749 | - 'h' => $h); | |
| 750 | - $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 751 | - } | |
| 752 | - $this->forms[$this->formn] = $f; | |
| 753 | - } | |
| 754 | - if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 755 | - $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 756 | - $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 757 | - } | |
| 758 | - if ( !$hidden ) $this->mpdf->x += $w; | |
| 759 | - | |
| 760 | -} | |
| 761 | - | |
| 762 | - | |
| 763 | - function SetFormChoice( $w, $h, $name, $flags, $array, $align='L', $js = '' ) { | |
| 764 | - $this->formn++; | |
| 765 | - if( $this->mpdf->blk[$this->mpdf->blklvl]['direction'] == 'rtl' ) { $align = '2'; } | |
| 766 | - else { $align = '0'; } | |
| 767 | - if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 768 | - $this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 769 | - } | |
| 770 | - if ($this->mpdf->onlyCoreFonts) { | |
| 771 | - for($i=0;$i<count($array['VAL']);$i++) { | |
| 772 | - $array['VAL'][$i] = $this->Win1252ToPDFDocEncoding($array['VAL'][$i]); | |
| 773 | - $array['OPT'][$i] = $this->Win1252ToPDFDocEncoding($array['OPT'][$i]); | |
| 774 | - } | |
| 775 | - } | |
| 776 | - else { | |
| 777 | - for($i=0;$i<count($array['VAL']);$i++) { | |
| 778 | - if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 779 | - $this->mpdf->UTF8StringToArray($array['VAL'][$i], true); // Add characters to font subset | |
| 780 | - $this->mpdf->UTF8StringToArray($array['OPT'][$i], true); // Add characters to font subset | |
| 781 | - } | |
| 782 | - if ($array['VAL'][$i] ) $array['VAL'][$i] = $this->mpdf->UTF8ToUTF16BE($array['VAL'][$i], true); | |
| 783 | - if ($array['OPT'][$i] ) $array['OPT'][$i] = $this->mpdf->UTF8ToUTF16BE($array['OPT'][$i], true); | |
| 784 | - } | |
| 785 | - } | |
| 786 | - $f = array( 'n' => $this->formn, | |
| 787 | - 'typ' => 'Ch', | |
| 788 | - 'page' => $this->mpdf->page, | |
| 789 | - 'x' => $this->mpdf->x, | |
| 790 | - 'y' => $this->mpdf->y, | |
| 791 | - 'w' => $w, | |
| 792 | - 'h' => $h, | |
| 793 | - 'T' => $name, | |
| 794 | - 'OPT' => $array, | |
| 795 | - 'FF' => $flags, | |
| 796 | - 'Q' => $align, | |
| 797 | - 'BS_W' => $this->form_border_width, | |
| 798 | - 'BS_S' => $this->form_border_style, | |
| 799 | - 'BC_C' => $this->form_border_color, | |
| 800 | - 'BG_C' => $this->form_background_color, | |
| 801 | - 'style' => array( | |
| 802 | - 'font' => $this->mpdf->FontFamily, | |
| 803 | - 'fontsize' => $this->mpdf->FontSizePt, | |
| 804 | - 'fontcolor' => $this->mpdf->TextColor, | |
| 805 | - ) | |
| 806 | - ); | |
| 807 | - if ($js) { $this->SetFormChoiceJS( $name, $js ); } | |
| 808 | - if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; } | |
| 809 | - else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; } | |
| 810 | - else { | |
| 811 | - if ($this->mpdf->ColActive) { | |
| 812 | - $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 813 | - 'h' => $h); | |
| 814 | - $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 815 | - } | |
| 816 | - $this->forms[$this->formn] = $f; | |
| 817 | - } | |
| 818 | - if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 819 | - $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 820 | - $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 821 | - } | |
| 822 | - $this->mpdf->x += $w; | |
| 823 | - } | |
| 824 | - | |
| 825 | - // CHECKBOX | |
| 826 | - function SetCheckBox( $w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled=false ) { | |
| 827 | - $this->SetFormButton( $w, $h, $name, $value, 'checkbox', $title, $flags, $checked, $disabled ); | |
| 828 | - $this->mpdf->x += $w; | |
| 829 | - } | |
| 830 | - | |
| 831 | - | |
| 832 | - // RADIO | |
| 833 | - function SetRadio( $w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled=false ) { | |
| 834 | - $this->SetFormButton( $w, $h, $name, $value, 'radio', $title, $flags, $checked, $disabled ); | |
| 835 | - $this->mpdf->x += $w; | |
| 836 | - } | |
| 837 | - | |
| 838 | - | |
| 839 | - function SetFormReset( $w, $h, $name, $value = 'Reset', $title = '', $flags = array(), $background_col=false, $border_col=false, $noprint=false ) { | |
| 840 | - if (!$name) { $name = 'Reset'; } | |
| 841 | - $this->SetFormButton( $w, $h, $name, $value, 'reset', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 842 | - $this->mpdf->x += $w; | |
| 843 | - } | |
| 844 | - | |
| 845 | - | |
| 846 | - function SetJSButton( $w, $h, $name, $value, $js, $image_id = 0, $title = '', $flags = array(), $indexed=false , $background_col=false, $border_col=false, $noprint=false ) { | |
| 847 | - $this->SetFormButton( $w, $h, $name, $value, 'js_button', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 848 | - // pos => 1 = no caption, icon only; 0 = caption only | |
| 849 | - if ($image_id) { | |
| 850 | - $this->form_button_icon[$this->mpdf->_escape($name)] = array( | |
| 851 | - 'pos' => 1, | |
| 852 | - 'image_id' => $image_id, | |
| 853 | - 'Indexed' => $indexed, | |
| 854 | - ); | |
| 855 | - } | |
| 856 | - if ($js) { $this->SetFormButtonJS( $name, $js ); } | |
| 857 | - $this->mpdf->x += $w; | |
| 858 | - } | |
| 859 | - | |
| 860 | - | |
| 861 | - function SetFormSubmit( $w, $h, $name, $value = 'Submit', $url, $title = '', $typ = 'html', $method = 'POST', $flags = array(), $background_col=false, $border_col=false, $noprint=false) { | |
| 862 | - if (!$name) { $name = 'Submit'; } | |
| 863 | - $this->SetFormButton( $w, $h, $name, $value, 'submit', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 864 | - $this->forms[$this->formn]['URL'] = $url; | |
| 865 | - $this->forms[$this->formn]['method'] = $method; | |
| 866 | - $this->forms[$this->formn]['exporttype'] = $typ; | |
| 867 | - $this->mpdf->x += $w; | |
| 868 | - } | |
| 869 | - | |
| 870 | - | |
| 871 | - function SetFormButtonText( $ca, $rc = '', $ac = '' ) { | |
| 872 | - if ($this->mpdf->onlyCoreFonts) { | |
| 873 | - $ca = $this->Win1252ToPDFDocEncoding($ca); | |
| 874 | - if ($rc) $rc = $this->Win1252ToPDFDocEncoding($rc); | |
| 875 | - if ($ac) $ac = $this->Win1252ToPDFDocEncoding($ac); | |
| 876 | - } | |
| 877 | - else { | |
| 878 | - if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 879 | - $this->mpdf->UTF8StringToArray($ca, true); // Add characters to font subset | |
| 880 | - } | |
| 881 | - $ca = $this->mpdf->UTF8ToUTF16BE($ca, true); | |
| 882 | - if ($rc) { | |
| 883 | - if (isset($this->mpdf->CurrentFont['subset'])) { $this->mpdf->UTF8StringToArray($rc, true); } | |
| 884 | - $rc = $this->mpdf->UTF8ToUTF16BE($rc, true); | |
| 885 | - } | |
| 886 | - if ($ac) { | |
| 887 | - if (isset($this->mpdf->CurrentFont['subset'])) { $this->mpdf->UTF8StringToArray($ac, true); } | |
| 888 | - $ac = $this->mpdf->UTF8ToUTF16BE($ac, true); | |
| 889 | - } | |
| 890 | - } | |
| 891 | - $this->form_button_text = $ca; | |
| 892 | - $this->form_button_text_over = $rc ? $rc : $ca; | |
| 893 | - $this->form_button_text_click = $ac ? $ac : $ca; | |
| 894 | - } | |
| 895 | - | |
| 896 | - | |
| 897 | - function SetFormButton( $bb, $hh, $name, $value, $type, $title = '', $flags = array(), $checked=false, $disabled=false, $background_col=false, $border_col=false, $noprint=false ) { | |
| 898 | - $this->formn++; | |
| 899 | - if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 900 | - $this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 901 | - } | |
| 902 | - if (!$this->mpdf->onlyCoreFonts) { | |
| 903 | - if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 904 | - $this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset | |
| 905 | - $this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset | |
| 906 | - } | |
| 907 | - $title = $this->mpdf->UTF8ToUTF16BE($title, true); | |
| 908 | - if ($type == 'checkbox') { | |
| 909 | - $uvalue = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 910 | - } | |
| 911 | - else if ($type == 'radio') { | |
| 912 | - $uvalue = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 913 | - $value = mb_convert_encoding($value, 'Windows-1252', 'UTF-8'); | |
| 914 | - } | |
| 915 | - else { | |
| 916 | - $value = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 917 | - $uvalue = $value; | |
| 918 | - } | |
| 919 | - } | |
| 920 | - else { | |
| 921 | - $title = $this->Win1252ToPDFDocEncoding($title); | |
| 922 | - $value = $this->Win1252ToPDFDocEncoding($value); //// ??? not needed | |
| 923 | - $uvalue = mb_convert_encoding($value, 'UTF-8', 'Windows-1252'); | |
| 924 | - $uvalue = $this->mpdf->UTF8ToUTF16BE($uvalue, true); | |
| 925 | - } | |
| 926 | - if ($type == 'radio' || $type == 'checkbox') { | |
| 927 | - if (!preg_match('/^[a-zA-Z0-9_:\-\.]+$/', $value)) { | |
| 928 | - $this->mpdf->Error("Field '".$name."' must have a value, which can only contain letters, numbers, colon(:), undersore(_), hyphen(-) or period(.)"); | |
| 929 | - } | |
| 930 | - } | |
| 931 | - if ($type == 'radio') { | |
| 932 | - if (!isset($this->form_radio_groups[$name])) { | |
| 933 | - $this->form_radio_groups[$name] = array( | |
| 934 | - 'page' => $this->mpdf->page, | |
| 935 | - 'kids' => array(), | |
| 936 | - ); | |
| 937 | - } | |
| 938 | - $this->form_radio_groups[$name]['kids'][] = array( | |
| 939 | - 'n' => $this->formn, 'V'=> $value, 'OPT'=>$uvalue, 'disabled'=>$disabled | |
| 940 | - ); | |
| 941 | - if ( $checked ) { $this->form_radio_groups[$name]['on'] = $value; } | |
| 942 | - // Disable the whole radio group if one is disabled, because of inconsistency in PDF readers | |
| 943 | - if ( $disabled ) { $this->form_radio_groups[$name]['disabled'] = true; } | |
| 944 | - } | |
| 945 | - if ($type == 'checkbox') { | |
| 946 | - $this->form_checkboxes = true; | |
| 947 | - } | |
| 948 | - if ( $checked ) { $activ = 1; } | |
| 949 | - else { $activ = 0; } | |
| 950 | - if ($background_col) { $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); } | |
| 951 | - else { $bg_c = $this->form_button_background_color; } | |
| 952 | - if ($border_col) { $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); } | |
| 953 | - else { $bc_c = $this->form_button_border_color; } | |
| 954 | - $f = array( 'n' => $this->formn, | |
| 955 | - 'typ' => 'Bt', | |
| 956 | - 'page' => $this->mpdf->page, | |
| 957 | - 'subtype' => $type, | |
| 958 | - 'x' => $this->mpdf->x, | |
| 959 | - 'y' => $this->mpdf->y, | |
| 960 | - 'w' => $bb, | |
| 961 | - 'h' => $hh, | |
| 962 | - 'T' => $name, | |
| 963 | - 'V' => $value, | |
| 964 | - 'OPT' => $uvalue, | |
| 965 | - 'TU' => $title, | |
| 966 | - 'FF' => $flags, | |
| 967 | - 'CA' => $this->form_button_text, | |
| 968 | - 'RC' => $this->form_button_text_over, | |
| 969 | - 'AC' => $this->form_button_text_click, | |
| 970 | - 'BS_W' => $this->form_button_border_width, | |
| 971 | - 'BS_S' => $this->form_button_border_style, | |
| 972 | - 'BC_C' => $bc_c, | |
| 973 | - 'BG_C' => $bg_c, | |
| 974 | - 'activ' => $activ, | |
| 975 | - 'disabled' => $disabled, | |
| 976 | - 'noprint' => $noprint, | |
| 977 | - 'style' => array( | |
| 978 | - 'font' => $this->mpdf->FontFamily, | |
| 979 | - 'fontsize' => $this->mpdf->FontSizePt, | |
| 980 | - 'fontcolor' => $this->mpdf->TextColor, | |
| 981 | - ) | |
| 982 | - ); | |
| 983 | - if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; } | |
| 984 | - else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; } | |
| 985 | - else { | |
| 986 | - if ($this->mpdf->ColActive) { | |
| 987 | - $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 988 | - 'h' => $hh); | |
| 989 | - $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 990 | - } | |
| 991 | - $this->forms[$this->formn] = $f; | |
| 992 | - } | |
| 993 | - if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 994 | - $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 995 | - $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 996 | - } | |
| 997 | - | |
| 998 | - $this->form_button_text = NULL; | |
| 999 | - $this->form_button_text_over = NULL; | |
| 1000 | - $this->form_button_text_click = NULL; | |
| 1001 | - } | |
| 1002 | - | |
| 1003 | - | |
| 1004 | - | |
| 1005 | -function SetFormBorderWidth ( $string ) { | |
| 1006 | - switch( $string ) { | |
| 1007 | - case 'S': $this->form_border_width = '1'; | |
| 1008 | - break; | |
| 1009 | - case 'M': $this->form_border_width = '2'; | |
| 1010 | - break; | |
| 1011 | - case 'B': $this->form_border_width = '3'; | |
| 1012 | - break; | |
| 1013 | - case '0': $this->form_border_width = '0'; | |
| 1014 | - break; | |
| 1015 | - default: $this->form_border_width = '0'; | |
| 1016 | - break; | |
| 1017 | - } | |
| 1018 | -} | |
| 1019 | - | |
| 1020 | - | |
| 1021 | -function SetFormBorderStyle ( $string ) { | |
| 1022 | - switch( $string ) { | |
| 1023 | - case 'S': $this->form_border_style = 'S'; | |
| 1024 | - break; | |
| 1025 | - case 'D': $this->form_border_style = 'D /D [3]'; | |
| 1026 | - break; | |
| 1027 | - case 'B': $this->form_border_style = 'B'; | |
| 1028 | - break; | |
| 1029 | - case 'I': $this->form_border_style = 'I'; | |
| 1030 | - break; | |
| 1031 | - case 'U': $this->form_border_style = 'U'; | |
| 1032 | - break; | |
| 1033 | - default: $this->form_border_style = 'B'; | |
| 1034 | - break; | |
| 1035 | - } | |
| 1036 | -} | |
| 1037 | - | |
| 1038 | -function SetFormBorderColor ( $r, $g=-1, $b=-1 ) { | |
| 1039 | - if ( ($r==0 and $g==0 and $b==0) || $g==-1 ) | |
| 1040 | - $this->form_border_color = sprintf('%.3F', $r/255); | |
| 1041 | - else | |
| 1042 | - $this->form_border_color = sprintf('%.3F %.3F %.3F', $r/255, $g/255, $b/255); | |
| 1043 | -} | |
| 1044 | - | |
| 1045 | -function SetFormBackgroundColor ( $r, $g=-1, $b=-1 ) { | |
| 1046 | - if ( ($r==0 and $g==0 and $b==0) || $g==-1 ) | |
| 1047 | - $this->form_background_color = sprintf('%.3F', $r/255); | |
| 1048 | - else | |
| 1049 | - $this->form_background_color = sprintf('%.3F %.3F %.3F', $r/255, $g/255, $b/255); | |
| 1050 | -} | |
| 1051 | - | |
| 1052 | -function SetFormD ( $W, $S, $BC, $BG ) { | |
| 1053 | - $this->SetFormBorderWidth ( $W ); | |
| 1054 | - $this->SetFormBorderStyle ( $S ); | |
| 1055 | - $this->SetFormBorderColor ( $BC ); | |
| 1056 | - $this->SetFormBackgroundColor ( $BG ); | |
| 1057 | -} | |
| 1058 | - | |
| 1059 | -function _setflag( $array ) { | |
| 1060 | - $flag = 0; | |
| 1061 | - foreach($array as $val) { $flag += 1 << ($val-1); } | |
| 1062 | - return $flag; | |
| 1063 | -} | |
| 1064 | - | |
| 1065 | -function _form_rect( $x, $y, $w, $h, $hPt ) { | |
| 1066 | - $x = $x * _MPDFK; | |
| 1067 | - $y = $hPt - ($y * _MPDFK); | |
| 1068 | - $x2 = $x + ($w * _MPDFK); | |
| 1069 | - $y2 = $y - ($h * _MPDFK); | |
| 1070 | - $rect = sprintf('%.3F %.3F %.3F %.3F', $x, $y2, $x2, $y ); | |
| 1071 | - return $rect; | |
| 1072 | -} | |
| 1073 | - | |
| 1074 | - | |
| 1075 | -function _put_button_icon( $array , $w, $h ) { | |
| 1076 | - if (isset($array['image_id'])) { | |
| 1077 | - $info = false; | |
| 1078 | - foreach($this->mpdf->images AS $iid=>$img) { | |
| 1079 | - if ($img['i'] == $array['image_id']) { | |
| 1080 | - $info = $this->mpdf->images[$iid]; | |
| 1081 | - break; | |
| 1082 | - } | |
| 1083 | - } | |
| 1084 | - } | |
| 1085 | - if (!$info) { die("Cannot find Button image"); } | |
| 1086 | - $this->mpdf->_newobj(); | |
| 1087 | - $this->mpdf->_out('<<'); | |
| 1088 | - $this->mpdf->_out('/Type /XObject'); | |
| 1089 | - $this->mpdf->_out('/Subtype /Image'); | |
| 1090 | - $this->mpdf->_out('/BBox [0 0 1 1]'); | |
| 1091 | - $this->mpdf->_out('/Length '.strlen($info['data'])); | |
| 1092 | - $this->mpdf->_out('/BitsPerComponent '.$info['bpc']); | |
| 1093 | - if ($info['cs']=='Indexed') { | |
| 1094 | - $this->mpdf->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->mpdf->n+1).' 0 R]'); | |
| 1095 | - } | |
| 1096 | - else { | |
| 1097 | - $this->mpdf->_out('/ColorSpace /'.$info['cs']); | |
| 1098 | - if ($info['cs']=='DeviceCMYK') | |
| 1099 | - if($info['type']=='jpg') { $this->mpdf->_out('/Decode [1 0 1 0 1 0 1 0]'); } | |
| 1100 | - } | |
| 1101 | - if ( isset($info['f']) ) | |
| 1102 | - $this->mpdf->_out('/Filter /'.$info['f']); | |
| 1103 | - if ( isset($info['parms']) ) | |
| 1104 | - $this->mpdf->_out($info['parms']); | |
| 1105 | - $this->mpdf->_out('/Width '.$info['w']); | |
| 1106 | - $this->mpdf->_out('/Height '.$info['h']); | |
| 1107 | - $this->mpdf->_out('>>'); | |
| 1108 | - $this->mpdf->_putstream($info['data']); | |
| 1109 | - $this->mpdf->_out('endobj'); | |
| 1110 | - unset($array); | |
| 1111 | - //Palette | |
| 1112 | - if($info['cs']=='Indexed') { | |
| 1113 | - $filter=($this->mpdf->compress) ? '/Filter /FlateDecode ' : ''; | |
| 1114 | - $this->mpdf->_newobj(); | |
| 1115 | - $pal=($this->mpdf->compress) ? gzcompress($info['pal']) : $info['pal']; | |
| 1116 | - $this->mpdf->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); | |
| 1117 | - $this->mpdf->_putstream($pal); | |
| 1118 | - $this->mpdf->_out('endobj'); | |
| 1119 | - } | |
| 1120 | - | |
| 1121 | -} | |
| 1122 | - | |
| 1123 | - | |
| 1124 | -function _putform_bt( $form, $hPt ) { | |
| 1125 | - $cc = 0; | |
| 1126 | - $put_xobject = 0; | |
| 1127 | - $put_js = 0; | |
| 1128 | - $put_icon = 0; | |
| 1129 | - $this->mpdf->_newobj(); | |
| 1130 | - $n = $this->mpdf->n; | |
| 1131 | - if ($form['subtype'] != 'radio') $this->pdf_acro_array .= $n.' 0 R '; // Add to /Field element | |
| 1132 | - $this->forms[ $form['n'] ]['obj'] = $n; | |
| 1133 | - $this->mpdf->_out('<<'); | |
| 1134 | - $this->mpdf->_out('/Type /Annot '); | |
| 1135 | - $this->mpdf->_out('/Subtype /Widget'); | |
| 1136 | - $this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (7000 + $form['n'])))); | |
| 1137 | - $this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis'))); | |
| 1138 | - $this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ]'); | |
| 1139 | - $form['noprint'] ? $this->mpdf->_out('/F 0 ') : $this->mpdf->_out('/F 4 '); | |
| 1140 | - $this->mpdf->_out('/FT /Btn '); | |
| 1141 | - $this->mpdf->_out('/H /P '); | |
| 1142 | - if ( $form['subtype'] != 'radio' ) // mPDF 5.3.23 | |
| 1143 | - $this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) ); | |
| 1144 | - $this->mpdf->_out('/TU '.$this->mpdf->_textstring($form['TU']) ); | |
| 1145 | - if ( isset( $this->form_button_icon[ $form['T'] ] ) ) { $form['BS_W'] = 0; } | |
| 1146 | - if ($form['BS_W'] == 0) { $form['BC_C'] = $form['BG_C']; } | |
| 1147 | - $bstemp = ''; | |
| 1148 | - $bstemp .= '/W '.$form['BS_W'].' '; | |
| 1149 | - $bstemp .= '/S /'.$form['BS_S'].' '; | |
| 1150 | - $temp = ''; | |
| 1151 | - $temp .= '/BC [ '.$form['BC_C']." ] "; | |
| 1152 | - $temp .= '/BG [ '.$form['BG_C']." ] "; | |
| 1153 | - if ( $form['subtype'] == 'checkbox' ) { | |
| 1154 | - if ($form['disabled']) { | |
| 1155 | - $radio_color = '0.5 0.5 0.5'; | |
| 1156 | - $radio_background_color = '0.9 0.9 0.9'; | |
| 1157 | - } | |
| 1158 | - else { | |
| 1159 | - $radio_color = $this->form_radio_color; | |
| 1160 | - $radio_background_color = $this->form_radio_background_color; | |
| 1161 | - } | |
| 1162 | - $temp = ''; | |
| 1163 | - $temp .= '/BC [ '.$radio_color." ] "; | |
| 1164 | - $temp .= '/BG [ '.$radio_background_color." ] "; | |
| 1165 | - $this->mpdf->_out("/BS << /W 1 /S /S >>"); | |
| 1166 | - $this->mpdf->_out("/MK << $temp >>"); | |
| 1167 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) ); | |
| 1168 | - if ( $form['activ'] ) { | |
| 1169 | - $this->mpdf->_out('/V /'.$this->mpdf->_escape($form['V']).' '); | |
| 1170 | - $this->mpdf->_out('/DV /'.$this->mpdf->_escape($form['V']).' '); | |
| 1171 | - $this->mpdf->_out('/AS /'.$this->mpdf->_escape($form['V']).' '); | |
| 1172 | - } else { | |
| 1173 | - $this->mpdf->_out('/AS /Off '); | |
| 1174 | - } | |
| 1175 | - if ($this->formUseZapD) { | |
| 1176 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts['czapfdingbats']['i'].' 0 Tf '.$radio_color.' rg)'); | |
| 1177 | - $this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off /Off >> >>"); | |
| 1178 | - } | |
| 1179 | - else { | |
| 1180 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'].' 0 Tf '.$radio_color.' rg)'); | |
| 1181 | - $this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>"); | |
| 1182 | - } | |
| 1183 | - $this->mpdf->_out('/Opt [ '.$this->mpdf->_textstring($form['OPT']).' '.$this->mpdf->_textstring($form['OPT']).' ]'); | |
| 1184 | - } | |
| 1185 | - | |
| 1186 | - | |
| 1187 | - if ( $form['subtype'] == 'radio' ) { | |
| 1188 | - if ((isset($form['disabled']) && $form['disabled']) || (isset($this->form_radio_groups[$form['T']]['disabled']) && $this->form_radio_groups[$form['T']]['disabled'])) { | |
| 1189 | - $radio_color = '0.5 0.5 0.5'; | |
| 1190 | - $radio_background_color = '0.9 0.9 0.9'; | |
| 1191 | - } | |
| 1192 | - else { | |
| 1193 | - $radio_color = $this->form_radio_color; | |
| 1194 | - $radio_background_color = $this->form_radio_background_color; | |
| 1195 | - } | |
| 1196 | - $this->mpdf->_out('/Parent '.$this->form_radio_groups[$form['T']]['obj_id'].' 0 R '); | |
| 1197 | - $temp = ''; | |
| 1198 | - $temp .= '/BC [ '.$radio_color." ] "; | |
| 1199 | - $temp .= '/BG [ '.$radio_background_color." ] "; | |
| 1200 | - $this->mpdf->_out("/BS << /W 1 /S /S >>"); | |
| 1201 | - $this->mpdf->_out('/MK << '.$temp.' >> '); | |
| 1202 | - $form['FF'][] = 16; // Radiobutton | |
| 1203 | - $form['FF'][] = 15; // NoToggleOff - must be same as radio button group setting? | |
| 1204 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) ); | |
| 1205 | - if ($this->formUseZapD) | |
| 1206 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts['czapfdingbats']['i'].' 0 Tf '.$radio_color.' rg)'); | |
| 1207 | - else | |
| 1208 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'].' 0 Tf '.$radio_color.' rg)'); | |
| 1209 | - $this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>"); | |
| 1210 | - if ( $form['activ'] ) { | |
| 1211 | - $this->mpdf->_out('/V /'.$this->mpdf->_escape($form['V']).' '); | |
| 1212 | - $this->mpdf->_out('/DV /'.$this->mpdf->_escape($form['V']).' '); | |
| 1213 | - $this->mpdf->_out('/AS /'.$this->mpdf->_escape($form['V']).' '); | |
| 1214 | - } | |
| 1215 | - else { | |
| 1216 | - $this->mpdf->_out('/AS /Off '); | |
| 1217 | - } | |
| 1218 | - $this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>"); | |
| 1219 | - // $this->mpdf->_out('/Opt [ '.$this->mpdf->_textstring($form['OPT']).' '.$this->mpdf->_textstring($form['OPT']).' ]'); | |
| 1220 | - } | |
| 1221 | - | |
| 1222 | - if ( $form['subtype'] == 'reset' ) { | |
| 1223 | - $temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' '; | |
| 1224 | - $temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1225 | - $temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1226 | - $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1227 | - $this->mpdf->_out('/MK << '.$temp.' >>'); | |
| 1228 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')'); | |
| 1229 | - $this->mpdf->_out('/AA << /D << /S /ResetForm /Flags 1 >> >>'); | |
| 1230 | - $form['FF'][] = 17; | |
| 1231 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) ); | |
| 1232 | - } | |
| 1233 | - | |
| 1234 | - | |
| 1235 | - if ( $form['subtype'] == 'submit' ) { | |
| 1236 | - $temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' '; | |
| 1237 | - $temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1238 | - $temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1239 | - $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1240 | - $this->mpdf->_out("/MK << $temp >>"); | |
| 1241 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')'); | |
| 1242 | - // Bit 4 (8) = useGETmethod else use POST | |
| 1243 | - // Bit 3 (4) = HTML export format (charset chosen by Adobe)--- OR --- | |
| 1244 | - // Bit 6 (32) = XFDF export format (form of XML in UTF-8) | |
| 1245 | - if ($form['exporttype'] == 'xfdf') { $flag = 32; } // 'xfdf' or 'html' | |
| 1246 | - else { | |
| 1247 | - if ($form['method'] == 'GET') { $flag = 12; } | |
| 1248 | - else { $flag = 4; } | |
| 1249 | - } | |
| 1250 | - // Bit 2 (2) = IncludeNoValueFields | |
| 1251 | - if ($this->formSubmitNoValueFields) $flag += 2; | |
| 1252 | - // To submit a value, needs to be in /AP dictionary, AND this object must contain a /Fields entry | |
| 1253 | - // listing all fields to output | |
| 1254 | - $this->mpdf->_out('/AA << /D << /S /SubmitForm /F ('.$form['URL'].') /Flags '.$flag.' >> >>'); | |
| 1255 | - $form['FF'][] = 17; | |
| 1256 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) ); | |
| 1257 | - } | |
| 1258 | - | |
| 1259 | - if ( $form['subtype'] == 'js_button' ) { | |
| 1260 | - // Icon / image | |
| 1261 | - if ( isset( $this->form_button_icon[ $form['T'] ] ) ) { | |
| 1262 | - $cc++; | |
| 1263 | - $temp .= '/TP '.$this->form_button_icon[$form['T']]['pos'].' '; | |
| 1264 | - $temp .= '/I '.($cc + $this->mpdf->n).' 0 R '; // Normal icon | |
| 1265 | - $temp .= '/RI '.($cc + $this->mpdf->n).' 0 R '; // onMouseOver | |
| 1266 | - $temp .= '/IX '.($cc + $this->mpdf->n).' 0 R '; // onClick / onMouseDown | |
| 1267 | - $temp .= '/IF << /SW /A /S /A /A [0.0 0.0] >> '; // Icon fit dictionary | |
| 1268 | - if ($this->form_button_icon[ $form['T'] ]['Indexed']) { $cc++; } | |
| 1269 | - $put_icon = 1; | |
| 1270 | - } | |
| 1271 | - $temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' '; | |
| 1272 | - $temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1273 | - $temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' '; | |
| 1274 | - $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1275 | - $this->mpdf->_out("/MK << $temp >>"); | |
| 1276 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')'); | |
| 1277 | - $form['FF'][] = 17; | |
| 1278 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) ); | |
| 1279 | - // Javascript | |
| 1280 | - if ( isset($this->array_form_button_js[$form['T']]) ) { | |
| 1281 | - $cc++; | |
| 1282 | - $this->mpdf->_out("/AA << /D ".($cc + $this->mpdf->n)." 0 R >>"); | |
| 1283 | - $put_js = 1; | |
| 1284 | - } | |
| 1285 | - } | |
| 1286 | - | |
| 1287 | - $this->mpdf->_out('>>'); | |
| 1288 | - $this->mpdf->_out('endobj'); | |
| 1289 | - | |
| 1290 | - // additional objects | |
| 1291 | - // obj icon | |
| 1292 | - if ( $put_icon == 1 ) { | |
| 1293 | - $this->_put_button_icon( $this->form_button_icon[ $form['T'] ], $form['w'], $form['h'] ); | |
| 1294 | - $put_icon = NULL; | |
| 1295 | - } | |
| 1296 | - // obj + 1 | |
| 1297 | - if ( $put_js == 1 ) { | |
| 1298 | - $this->mpdf->_set_object_javascript( $this->array_form_button_js[$form['T']]['js'] ); | |
| 1299 | - unset( $this->array_form_button_js[$form['T']] ); | |
| 1300 | - $put_js = NULL; | |
| 1301 | - } | |
| 1302 | - | |
| 1303 | - // RADIO and CHECK BOX appearance streams | |
| 1304 | - $filter=($this->mpdf->compress) ? '/Filter /FlateDecode ' : ''; | |
| 1305 | - if ( $form['subtype'] == 'radio' ) { | |
| 1306 | - // output 2 appearance streams for radio buttons on/off | |
| 1307 | - if ($this->formUseZapD) { | |
| 1308 | - $fs = sprintf('%.3F', $form['style']['fontsize']*1.25); | |
| 1309 | - $fi = 'czapfdingbats'; | |
| 1310 | - $r_on = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (4) Tj ET Q'; | |
| 1311 | - $r_off = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (8) Tj ET Q'; | |
| 1312 | - } | |
| 1313 | - else { | |
| 1314 | - $matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize']*1.33/10, $form['style']['fontsize']*1.25/10, $form['style']['fontsize']); | |
| 1315 | - $fill = $radio_background_color.' rg 3.778 -7.410 m 2.800 -7.410 1.947 -7.047 1.225 -6.322 c 0.500 -5.600 0.138 -4.747 0.138 -3.769 c 0.138 -2.788 0.500 -1.938 1.225 -1.213 c 1.947 -0.491 2.800 -0.128 3.778 -0.128 c 4.757 -0.128 5.610 -0.491 6.334 -1.213 c 7.056 -1.938 7.419 -2.788 7.419 -3.769 c 7.419 -4.747 7.056 -5.600 6.334 -6.322 c 5.610 -7.047 4.757 -7.410 3.778 -7.410 c h f '; | |
| 1316 | - $circle = '3.778 -6.963 m 4.631 -6.963 5.375 -6.641 6.013 -6.004 c 6.653 -5.366 6.972 -4.619 6.972 -3.769 c 6.972 -2.916 6.653 -2.172 6.013 -1.532 c 5.375 -0.894 4.631 -0.576 3.778 -0.576 c 2.928 -0.576 2.182 -0.894 1.544 -1.532 c 0.904 -2.172 0.585 -2.916 0.585 -3.769 c 0.585 -4.619 0.904 -5.366 1.544 -6.004 c 2.182 -6.641 2.928 -6.963 3.778 -6.963 c h 3.778 -7.410 m 2.800 -7.410 1.947 -7.047 1.225 -6.322 c 0.500 -5.600 0.138 -4.747 0.138 -3.769 c 0.138 -2.788 0.500 -1.938 1.225 -1.213 c 1.947 -0.491 2.800 -0.128 3.778 -0.128 c 4.757 -0.128 5.610 -0.491 6.334 -1.213 c 7.056 -1.938 7.419 -2.788 7.419 -3.769 c 7.419 -4.747 7.056 -5.600 6.334 -6.322 c 5.610 -7.047 4.757 -7.410 3.778 -7.410 c h f '; | |
| 1317 | - $r_on = 'q '.$matrix.' cm '.$fill .$radio_color.' rg '.$circle.' '.$radio_color.' rg | |
| 1318 | -5.184 -5.110 m 4.800 -5.494 4.354 -5.685 3.841 -5.685 c 3.331 -5.685 2.885 -5.494 2.501 -5.110 c 2.119 -4.725 1.925 -4.279 1.925 -3.769 c 1.925 -3.257 2.119 -2.810 2.501 -2.429 c 2.885 -2.044 3.331 -1.853 3.841 -1.853 c 4.354 -1.853 4.800 -2.044 5.184 -2.429 c 5.566 -2.810 5.760 -3.257 5.760 -3.769 c 5.760 -4.279 5.566 -4.725 5.184 -5.110 c h | |
| 1319 | -f Q '; | |
| 1320 | - $r_off = 'q '.$matrix.' cm '.$fill .$radio_color.' rg '.$circle.' Q '; | |
| 1321 | - } | |
| 1322 | - | |
| 1323 | - $this->mpdf->_newobj(); | |
| 1324 | - $p=($this->mpdf->compress) ? gzcompress($r_on) : $r_on; | |
| 1325 | - $this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>'); | |
| 1326 | - $this->mpdf->_putstream($p); | |
| 1327 | - $this->mpdf->_out('endobj'); | |
| 1328 | - | |
| 1329 | - $this->mpdf->_newobj(); | |
| 1330 | - $p=($this->mpdf->compress) ? gzcompress($r_off) : $r_off; | |
| 1331 | - $this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>'); | |
| 1332 | - $this->mpdf->_putstream($p); | |
| 1333 | - $this->mpdf->_out('endobj'); | |
| 1334 | - } | |
| 1335 | - if ( $form['subtype'] == 'checkbox' ) { | |
| 1336 | - // First output appearance stream for check box on | |
| 1337 | - if ($this->formUseZapD) { | |
| 1338 | - $fs = sprintf('%.3F', $form['style']['fontsize']*1.25); | |
| 1339 | - $fi = 'czapfdingbats'; | |
| 1340 | - $cb_on = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (4) Tj ET Q'; | |
| 1341 | - $cb_off = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (8) Tj ET Q'; | |
| 1342 | - } | |
| 1343 | - else { | |
| 1344 | - $matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize']*1.33/10, $form['style']['fontsize']*1.25/10, $form['style']['fontsize']); | |
| 1345 | - $fill = $radio_background_color.' rg 7.395 -0.070 m 7.395 -7.344 l 0.121 -7.344 l 0.121 -0.070 l 7.395 -0.070 l h f '; | |
| 1346 | - $square = '0.508 -6.880 m 6.969 -6.880 l 6.969 -0.534 l 0.508 -0.534 l 0.508 -6.880 l h 7.395 -0.070 m 7.395 -7.344 l 0.121 -7.344 l 0.121 -0.070 l 7.395 -0.070 l h '; | |
| 1347 | - $cb_on = 'q '.$matrix.' cm '.$fill. $radio_color.' rg '.$square.' f '.$radio_color.' rg | |
| 1348 | -6.321 -1.352 m 5.669 -2.075 5.070 -2.801 4.525 -3.532 c 3.979 -4.262 3.508 -4.967 3.112 -5.649 c 3.080 -5.706 3.039 -5.779 2.993 -5.868 c 2.858 -6.118 2.638 -6.243 2.334 -6.243 c 2.194 -6.243 2.100 -6.231 2.052 -6.205 c 2.003 -6.180 1.954 -6.118 1.904 -6.020 c 1.787 -5.788 1.688 -5.523 1.604 -5.226 c 1.521 -4.930 1.480 -4.721 1.480 -4.600 c 1.480 -4.535 1.491 -4.484 1.512 -4.447 c 1.535 -4.410 1.579 -4.367 1.647 -4.319 c 1.733 -4.259 1.828 -4.210 1.935 -4.172 c 2.040 -4.134 2.131 -4.115 2.205 -4.115 c 2.267 -4.115 2.341 -4.232 2.429 -4.469 c 2.437 -4.494 2.444 -4.511 2.448 -4.522 c 2.451 -4.531 2.456 -4.546 2.465 -4.568 c 2.546 -4.795 2.614 -4.910 2.668 -4.910 c 2.714 -4.910 2.898 -4.652 3.219 -4.136 c 3.539 -3.620 3.866 -3.136 4.197 -2.683 c 4.426 -2.367 4.633 -2.103 4.816 -1.889 c 4.998 -1.676 5.131 -1.544 5.211 -1.493 c 5.329 -1.426 5.483 -1.368 5.670 -1.319 c 5.856 -1.271 6.066 -1.238 6.296 -1.217 c 6.321 -1.352 l h f Q '; | |
| 1349 | - $cb_off = 'q '.$matrix.' cm '.$fill. $radio_color.' rg '.$square.' f Q '; | |
| 1350 | - | |
| 1351 | - } | |
| 1352 | - $this->mpdf->_newobj(); | |
| 1353 | - $p=($this->mpdf->compress) ? gzcompress($cb_on) : $cb_on; | |
| 1354 | - $this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>'); | |
| 1355 | - $this->mpdf->_putstream($p); | |
| 1356 | - $this->mpdf->_out('endobj'); | |
| 1357 | - | |
| 1358 | - // output appearance stream for check box off (only if not using ZapfDingbats) | |
| 1359 | - if (!$this->formUseZapD) { | |
| 1360 | - $this->mpdf->_newobj(); | |
| 1361 | - $p=($this->mpdf->compress) ? gzcompress($cb_off) : $cb_off; | |
| 1362 | - $this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>'); | |
| 1363 | - $this->mpdf->_putstream($p); | |
| 1364 | - $this->mpdf->_out('endobj'); | |
| 1365 | - } | |
| 1366 | - | |
| 1367 | - } | |
| 1368 | - return $n; | |
| 1369 | -} | |
| 1370 | - | |
| 1371 | - | |
| 1372 | -function _putform_ch( $form, $hPt ) { | |
| 1373 | - $put_js = 0; | |
| 1374 | - $this->mpdf->_newobj(); | |
| 1375 | - $n = $this->mpdf->n; | |
| 1376 | - $this->pdf_acro_array .= $n.' 0 R '; | |
| 1377 | - $this->forms[ $form['n'] ]['obj'] = $n; | |
| 1378 | - | |
| 1379 | - $this->mpdf->_out('<<'); | |
| 1380 | - $this->mpdf->_out('/Type /Annot '); | |
| 1381 | - $this->mpdf->_out('/Subtype /Widget'); | |
| 1382 | - $this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ]'); | |
| 1383 | - $this->mpdf->_out('/F 4'); | |
| 1384 | - $this->mpdf->_out('/FT /Ch'); | |
| 1385 | - if ($form['Q']) $this->mpdf->_out('/Q '.$form['Q'].''); | |
| 1386 | - $temp = ''; | |
| 1387 | - $temp .= '/W '.$form['BS_W'].' '; | |
| 1388 | - $temp .= '/S /'.$form['BS_S'].' '; | |
| 1389 | - $this->mpdf->_out("/BS << $temp >>"); | |
| 1390 | - | |
| 1391 | - $temp = ''; | |
| 1392 | - $temp .= '/BC [ '.$form['BC_C']." ] "; | |
| 1393 | - $temp .= '/BG [ '.$form['BG_C']." ] "; | |
| 1394 | - $this->mpdf->_out('/MK << '.$temp.' >>'); | |
| 1395 | - | |
| 1396 | - $this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (6000 + $form['n'])))); | |
| 1397 | - $this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis'))); | |
| 1398 | - | |
| 1399 | - $this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) ); | |
| 1400 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')'); | |
| 1401 | - | |
| 1402 | - $opt = ''; | |
| 1403 | - for( $i = 0; $i < count($form['OPT']['VAL']) ; $i++ ) { | |
| 1404 | - $opt .= '[ '.$this->mpdf->_textstring($form['OPT']['VAL'][$i]).' '.$this->mpdf->_textstring($form['OPT']['OPT'][$i]).' ] '; | |
| 1405 | - } | |
| 1406 | - $this->mpdf->_out('/Opt [ '.$opt.']'); | |
| 1407 | - | |
| 1408 | - // selected | |
| 1409 | - $selectItem = false; | |
| 1410 | - $selectIndex = false; | |
| 1411 | - foreach ( $form['OPT']['SEL'] as $selectKey => $selectVal ) { | |
| 1412 | - $selectName = $this->mpdf->_textstring($form['OPT']['VAL'][$selectVal]); | |
| 1413 | - $selectItem .= ' '.$selectName.' '; | |
| 1414 | - $selectIndex .= ' '.$selectVal.' '; | |
| 1415 | - } | |
| 1416 | - if ( $selectItem ) { | |
| 1417 | - if (count($form['OPT']['SEL']) < 2) { | |
| 1418 | - $this->mpdf->_out('/V '.$selectItem.' '); | |
| 1419 | - $this->mpdf->_out('/DV '.$selectItem.' '); | |
| 1420 | - } | |
| 1421 | - else { | |
| 1422 | - $this->mpdf->_out('/V ['.$selectItem.'] '); | |
| 1423 | - $this->mpdf->_out('/DV ['.$selectItem.'] '); | |
| 1424 | - } | |
| 1425 | - $this->mpdf->_out('/I ['.$selectIndex.'] '); | |
| 1426 | - } | |
| 1427 | - | |
| 1428 | - if ( is_array($form['FF']) && count($form['FF'])>0 ) { | |
| 1429 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' '); | |
| 1430 | - } | |
| 1431 | - // Javascript | |
| 1432 | - if ( isset($this->array_form_choice_js[$form['T']]) ) { | |
| 1433 | - $this->mpdf->_out("/AA << /V ".($this->mpdf->n+1)." 0 R >>"); | |
| 1434 | - $put_js = 1; | |
| 1435 | - } | |
| 1436 | - | |
| 1437 | - $this->mpdf->_out('>>'); | |
| 1438 | - $this->mpdf->_out('endobj'); | |
| 1439 | - // obj + 1 | |
| 1440 | - if ( $put_js == 1 ) { | |
| 1441 | - $this->mpdf->_set_object_javascript( $this->array_form_choice_js[$form['T']]['js'] ); | |
| 1442 | - unset( $this->array_form_choice_js[$form['T']] ); | |
| 1443 | - $put_js = NULL; | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - return $n; | |
| 1447 | -} | |
| 1448 | - | |
| 1449 | - | |
| 1450 | -function _putform_tx( $form, $hPt ) { | |
| 1451 | - $put_js = 0; | |
| 1452 | - $this->mpdf->_newobj(); | |
| 1453 | - $n = $this->mpdf->n; | |
| 1454 | - $this->pdf_acro_array .= $n.' 0 R '; | |
| 1455 | - $this->forms[ $form['n'] ]['obj'] = $n; | |
| 1456 | - | |
| 1457 | - $this->mpdf->_out('<<'); | |
| 1458 | - $this->mpdf->_out('/Type /Annot '); | |
| 1459 | - $this->mpdf->_out('/Subtype /Widget '); | |
| 1460 | - | |
| 1461 | - $this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ] '); | |
| 1462 | - $form['hidden'] ? $this->mpdf->_out('/F 2 ') : $this->mpdf->_out('/F 4 '); | |
| 1463 | - $this->mpdf->_out('/FT /Tx '); | |
| 1464 | - | |
| 1465 | - $this->mpdf->_out('/H /N '); | |
| 1466 | - $this->mpdf->_out('/R 0 '); | |
| 1467 | - | |
| 1468 | - if ( is_array($form['FF']) && count($form['FF'])>0 ) { | |
| 1469 | - $this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' '); | |
| 1470 | - } | |
| 1471 | - if ( isset($form['maxlen']) && $form['maxlen']>0 ) { | |
| 1472 | - $this->mpdf->_out('/MaxLen '.$form['maxlen']); | |
| 1473 | - } | |
| 1474 | - | |
| 1475 | - $temp = ''; | |
| 1476 | - $temp .= '/W '.$form['BS_W'].' '; | |
| 1477 | - $temp .= '/S /'.$form['BS_S'].' '; | |
| 1478 | - $this->mpdf->_out("/BS << $temp >>"); | |
| 1479 | - | |
| 1480 | - $temp = ''; | |
| 1481 | - $temp .= '/BC [ '.$form['BC_C']." ] "; | |
| 1482 | - $temp .= '/BG [ '.$form['BG_C']." ] "; | |
| 1483 | - $this->mpdf->_out('/MK <<'.$temp.' >>'); | |
| 1484 | - | |
| 1485 | - $this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) ); | |
| 1486 | - $this->mpdf->_out('/TU '.$this->mpdf->_textstring($form['TU']) ); | |
| 1487 | - if ($form['V'] || $form['V']==='0') | |
| 1488 | - $this->mpdf->_out('/V '.$this->mpdf->_textstring($form['V']) ); | |
| 1489 | - $this->mpdf->_out('/DV '.$this->mpdf->_textstring($form['DV']) ); | |
| 1490 | - $this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')'); | |
| 1491 | - if ( $form['Q'] ) $this->mpdf->_out('/Q '.$form['Q'].''); | |
| 1492 | - | |
| 1493 | - $this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (5000 + $form['n'])))); | |
| 1494 | - $this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis'))); | |
| 1495 | - | |
| 1496 | - | |
| 1497 | - if ( isset($this->array_form_text_js[$form['T']]) ) { | |
| 1498 | - $put_js = 1; | |
| 1499 | - $cc = 0; | |
| 1500 | - $js_str = ''; | |
| 1501 | - | |
| 1502 | - if ( isset($this->array_form_text_js[$form['T']]['F']) ) { | |
| 1503 | - $cc++; | |
| 1504 | - $js_str .= '/F '.($cc + $this->mpdf->n).' 0 R '; | |
| 1505 | - } | |
| 1506 | - if ( isset($this->array_form_text_js[$form['T']]['K']) ) { | |
| 1507 | - $cc++; | |
| 1508 | - $js_str .= '/K '.($cc + $this->mpdf->n).' 0 R '; | |
| 1509 | - } | |
| 1510 | - if ( isset($this->array_form_text_js[$form['T']]['V']) ) { | |
| 1511 | - $cc++; | |
| 1512 | - $js_str .= '/V '.($cc + $this->mpdf->n).' 0 R '; | |
| 1513 | - } | |
| 1514 | - if ( isset($this->array_form_text_js[$form['T']]['C']) ) { | |
| 1515 | - $cc++; | |
| 1516 | - $js_str .= '/C '.($cc + $this->mpdf->n).' 0 R '; | |
| 1517 | - $this->pdf_array_co .= $this->mpdf->n.' 0 R '; | |
| 1518 | - } | |
| 1519 | - $this->mpdf->_out('/AA << '.$js_str.' >>'); | |
| 1520 | - } | |
| 1521 | - | |
| 1522 | - $this->mpdf->_out('>>'); | |
| 1523 | - $this->mpdf->_out('endobj'); | |
| 1524 | - | |
| 1525 | - if ( $put_js == 1 ) { | |
| 1526 | - if ( isset($this->array_form_text_js[$form['T']]['F']) ) { | |
| 1527 | - $this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['F']['js'] ); | |
| 1528 | - unset( $this->array_form_text_js[$form['T']]['F'] ); | |
| 1529 | - } | |
| 1530 | - if ( isset($this->array_form_text_js[$form['T']]['K']) ) { | |
| 1531 | - $this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['K']['js'] ); | |
| 1532 | - unset( $this->array_form_text_js[$form['T']]['K'] ); | |
| 1533 | - } | |
| 1534 | - if ( isset($this->array_form_text_js[$form['T']]['V']) ) { | |
| 1535 | - $this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['V']['js'] ); | |
| 1536 | - unset( $this->array_form_text_js[$form['T']]['V'] ); | |
| 1537 | - } | |
| 1538 | - if ( isset($this->array_form_text_js[$form['T']]['C']) ) { | |
| 1539 | - $this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['C']['js'] ); | |
| 1540 | - unset( $this->array_form_text_js[$form['T']]['C'] ); | |
| 1541 | - } | |
| 1542 | - } | |
| 1543 | - return $n; | |
| 1544 | -} | |
| 1545 | - | |
| 1546 | - | |
| 1547 | - | |
| 1548 | -} | |
| 1549 | - | |
| 1550 | -?> | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once __DIR__ . '/../MpdfException.php'; | |
| 4 | + | |
| 5 | +class mpdfform | |
| 6 | +{ | |
| 7 | + | |
| 8 | + var $mpdf = null; | |
| 9 | + | |
| 10 | + var $forms; | |
| 11 | + | |
| 12 | + var $formn; | |
| 13 | + | |
| 14 | + // Active Forms | |
| 15 | + var $formSubmitNoValueFields; | |
| 16 | + | |
| 17 | + var $formExportType; | |
| 18 | + | |
| 19 | + var $formSelectDefaultOption; | |
| 20 | + | |
| 21 | + var $formUseZapD; | |
| 22 | + | |
| 23 | + // Form Styles | |
| 24 | + var $form_border_color; | |
| 25 | + | |
| 26 | + var $form_background_color; | |
| 27 | + | |
| 28 | + var $form_border_width; | |
| 29 | + | |
| 30 | + var $form_border_style; | |
| 31 | + | |
| 32 | + var $form_button_border_color; | |
| 33 | + | |
| 34 | + var $form_button_background_color; | |
| 35 | + | |
| 36 | + var $form_button_border_width; | |
| 37 | + | |
| 38 | + var $form_button_border_style; | |
| 39 | + | |
| 40 | + var $form_radio_color; | |
| 41 | + | |
| 42 | + var $form_radio_background_color; | |
| 43 | + | |
| 44 | + var $form_element_spacing; | |
| 45 | + | |
| 46 | + // Active forms | |
| 47 | + var $formMethod; | |
| 48 | + | |
| 49 | + var $formAction; | |
| 50 | + | |
| 51 | + var $form_fonts; | |
| 52 | + | |
| 53 | + var $form_radio_groups; | |
| 54 | + | |
| 55 | + var $form_checkboxes; | |
| 56 | + | |
| 57 | + var $pdf_acro_array; | |
| 58 | + | |
| 59 | + var $pdf_array_co; | |
| 60 | + | |
| 61 | + var $array_form_button_js; | |
| 62 | + | |
| 63 | + var $array_form_choice_js; | |
| 64 | + | |
| 65 | + var $array_form_text_js; | |
| 66 | + | |
| 67 | + // Button Text | |
| 68 | + var $form_button_text; | |
| 69 | + | |
| 70 | + var $form_button_text_over; | |
| 71 | + | |
| 72 | + var $form_button_text_click; | |
| 73 | + | |
| 74 | + var $form_button_icon; | |
| 75 | + | |
| 76 | + // FORMS | |
| 77 | + var $textarea_lineheight; | |
| 78 | + | |
| 79 | + public function __construct(mPDF $mpdf) | |
| 80 | + { | |
| 81 | + $this->mpdf = $mpdf; | |
| 82 | + | |
| 83 | + // ACTIVE FORMS | |
| 84 | + $this->formExportType = 'xfdf'; // 'xfdf' or 'html' | |
| 85 | + $this->formSubmitNoValueFields = true; // Whether to include blank fields when submitting data | |
| 86 | + $this->formSelectDefaultOption = true; // for Select drop down box; if no option is explicitly maked as selected, | |
| 87 | + // this determines whether to select 1st option (as per browser) | |
| 88 | + // - affects whether "required" attribute is relevant | |
| 89 | + $this->formUseZapD = true; // Determine whether to use ZapfDingbat icons for radio/checkboxes | |
| 90 | + // FORM STYLES | |
| 91 | + // These can alternatively use a 4 number string to represent CMYK colours | |
| 92 | + $this->form_border_color = '0.6 0.6 0.72'; // RGB | |
| 93 | + $this->form_background_color = '0.975 0.975 0.975'; // RGB | |
| 94 | + $this->form_border_width = '1'; // 0 doesn't seem to work as it should | |
| 95 | + $this->form_border_style = 'S'; // B - Bevelled; D - Double | |
| 96 | + $this->form_button_border_color = '0.2 0.2 0.55'; | |
| 97 | + $this->form_button_background_color = '0.941 0.941 0.941'; | |
| 98 | + $this->form_button_border_width = '1'; | |
| 99 | + $this->form_button_border_style = 'S'; | |
| 100 | + $this->form_radio_color = '0.0 0.0 0.4'; // radio and checkbox | |
| 101 | + $this->form_radio_background_color = '0.9 0.9 0.9'; | |
| 102 | + | |
| 103 | + // FORMS | |
| 104 | + $this->textarea_lineheight = 1.25; | |
| 105 | + | |
| 106 | + // FORM ELEMENT SPACING | |
| 107 | + $this->form_element_spacing['select']['outer']['h'] = 0.5; // Horizontal spacing around SELECT | |
| 108 | + $this->form_element_spacing['select']['outer']['v'] = 0.5; // Vertical spacing around SELECT | |
| 109 | + $this->form_element_spacing['select']['inner']['h'] = 0.7; // Horizontal padding around SELECT | |
| 110 | + $this->form_element_spacing['select']['inner']['v'] = 0.7; // Vertical padding around SELECT | |
| 111 | + $this->form_element_spacing['input']['outer']['h'] = 0.5; | |
| 112 | + $this->form_element_spacing['input']['outer']['v'] = 0.5; | |
| 113 | + $this->form_element_spacing['input']['inner']['h'] = 0.7; | |
| 114 | + $this->form_element_spacing['input']['inner']['v'] = 0.7; | |
| 115 | + $this->form_element_spacing['textarea']['outer']['h'] = 0.5; | |
| 116 | + $this->form_element_spacing['textarea']['outer']['v'] = 0.5; | |
| 117 | + $this->form_element_spacing['textarea']['inner']['h'] = 1; | |
| 118 | + $this->form_element_spacing['textarea']['inner']['v'] = 0.5; | |
| 119 | + $this->form_element_spacing['button']['outer']['h'] = 0.5; | |
| 120 | + $this->form_element_spacing['button']['outer']['v'] = 0.5; | |
| 121 | + $this->form_element_spacing['button']['inner']['h'] = 2; | |
| 122 | + $this->form_element_spacing['button']['inner']['v'] = 1; | |
| 123 | + | |
| 124 | + // INITIALISE non-configurable | |
| 125 | + $this->formMethod = 'POST'; | |
| 126 | + $this->formAction = ''; | |
| 127 | + $this->form_fonts = array(); | |
| 128 | + $this->form_radio_groups = array(); | |
| 129 | + $this->form_checkboxes = false; | |
| 130 | + $this->forms = array(); | |
| 131 | + $this->pdf_array_co = ''; | |
| 132 | + } | |
| 133 | + | |
| 134 | + function print_ob_text($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir) | |
| 135 | + { | |
| 136 | + // TEXT/PASSWORD INPUT | |
| 137 | + if ($this->mpdf->useActiveForms) { | |
| 138 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 139 | + $flags = array(); | |
| 140 | + if ((isset($objattr['disabled']) && $objattr['disabled']) || (isset($objattr['readonly']) && $objattr['readonly'])) { | |
| 141 | + $flags[] = 1; | |
| 142 | + } // readonly | |
| 143 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 144 | + $flags[] = 3; // no export | |
| 145 | + $objattr['color'] = array(3, 128, 128, 128); // gray out disabled | |
| 146 | + } | |
| 147 | + if (isset($objattr['required']) && $objattr['required']) { | |
| 148 | + $flags[] = 2; | |
| 149 | + } // required | |
| 150 | + if (!isset($objattr['spellcheck']) || !$objattr['spellcheck']) { | |
| 151 | + $flags[] = 23; | |
| 152 | + } // DoNotSpellCheck | |
| 153 | + if (isset($objattr['subtype']) && $objattr['subtype'] == 'PASSWORD') { | |
| 154 | + $flags[] = 14; | |
| 155 | + $val = $objattr['value']; | |
| 156 | + } | |
| 157 | + if (isset($objattr['color'])) { | |
| 158 | + $this->mpdf->SetTColor($objattr['color']); | |
| 159 | + } else { | |
| 160 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 161 | + } | |
| 162 | + $fieldalign = $rtlalign; | |
| 163 | + if (isset($objattr['text_align']) && $objattr['text_align']) { | |
| 164 | + $fieldalign = $objattr['text_align']; | |
| 165 | + } else { | |
| 166 | + $val = $objattr['text']; | |
| 167 | + } | |
| 168 | + // mPDF 5.3.25 | |
| 169 | + $js = array(); | |
| 170 | + if (isset($objattr['onCalculate']) && $objattr['onCalculate']) { | |
| 171 | + $js[] = array('C', $objattr['onCalculate']); | |
| 172 | + } | |
| 173 | + if (isset($objattr['onValidate']) && $objattr['onValidate']) { | |
| 174 | + $js[] = array('V', $objattr['onValidate']); | |
| 175 | + } | |
| 176 | + if (isset($objattr['onFormat']) && $objattr['onFormat']) { | |
| 177 | + $js[] = array('F', $objattr['onFormat']); | |
| 178 | + } | |
| 179 | + if (isset($objattr['onKeystroke']) && $objattr['onKeystroke']) { | |
| 180 | + $js[] = array('K', $objattr['onKeystroke']); | |
| 181 | + } | |
| 182 | + $this->SetFormText($w, $h, $objattr['fieldname'], $val, $val, $objattr['title'], $flags, $fieldalign, false, (isset($objattr['maxlength']) ? $objattr['maxlength'] : false), $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false)); | |
| 183 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 184 | + } else { | |
| 185 | + $w -= $this->form_element_spacing['input']['outer']['h'] * 2 / $k; | |
| 186 | + $h -= $this->form_element_spacing['input']['outer']['v'] * 2 / $k; | |
| 187 | + $this->mpdf->x += $this->form_element_spacing['input']['outer']['h'] / $k; | |
| 188 | + $this->mpdf->y += $this->form_element_spacing['input']['outer']['v'] / $k; | |
| 189 | + // Chop texto to max length $w-inner-padding | |
| 190 | + while ($this->mpdf->GetStringWidth($texto) > $w - ($this->form_element_spacing['input']['inner']['h'] * 2)) { | |
| 191 | + $texto = mb_substr($texto, 0, mb_strlen($texto, $this->mpdf->mb_enc) - 1, $this->mpdf->mb_enc); | |
| 192 | + } | |
| 193 | + | |
| 194 | + // DIRECTIONALITY | |
| 195 | + if (preg_match("/([" . $this->mpdf->pregRTLchars . "])/u", $texto)) { | |
| 196 | + $this->mpdf->biDirectional = true; | |
| 197 | + } // *RTL* | |
| 198 | + // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 199 | + if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 200 | + $texto = $this->mpdf->otl->applyOTL($texto, $this->mpdf->CurrentFont['useOTL']); | |
| 201 | + $OTLdata = $this->mpdf->otl->OTLdata; | |
| 202 | + } | |
| 203 | + | |
| 204 | + $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $OTLdata); | |
| 205 | + | |
| 206 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 207 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 208 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 209 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 210 | + } else if (isset($objattr['readonly']) && $objattr['readonly']) { | |
| 211 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 212 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 213 | + } else { | |
| 214 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 215 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 216 | + } | |
| 217 | + $this->mpdf->Cell($w, $h, $texto, 1, 0, $rtlalign, 1, '', 0, $this->form_element_spacing['input']['inner']['h'] / $k, $this->form_element_spacing['input']['inner']['h'] / $k, 'M', 0, false, $OTLdata); | |
| 218 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 219 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + function print_ob_textarea($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir) | |
| 224 | + { | |
| 225 | + // TEXTAREA | |
| 226 | + if ($this->mpdf->useActiveForms) { | |
| 227 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 228 | + $flags = array(); | |
| 229 | + $flags = array(13); // textarea | |
| 230 | + if ((isset($objattr['disabled']) && $objattr['disabled']) || (isset($objattr['readonly']) && $objattr['readonly'])) { | |
| 231 | + $flags[] = 1; | |
| 232 | + } // readonly | |
| 233 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 234 | + $flags[] = 3; // no export | |
| 235 | + $objattr['color'] = array(3, 128, 128, 128); // gray out disabled | |
| 236 | + } | |
| 237 | + if (isset($objattr['required']) && $objattr['required']) { | |
| 238 | + $flags[] = 2; | |
| 239 | + } // required | |
| 240 | + if (!isset($objattr['spellcheck']) || !$objattr['spellcheck']) { | |
| 241 | + $flags[] = 23; | |
| 242 | + } // DoNotSpellCheck | |
| 243 | + if (isset($objattr['donotscroll']) && $objattr['donotscroll']) { | |
| 244 | + $flags[] = 24; | |
| 245 | + } // DoNotScroll | |
| 246 | + if (isset($objattr['color'])) { | |
| 247 | + $this->mpdf->SetTColor($objattr['color']); | |
| 248 | + } else { | |
| 249 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 250 | + } | |
| 251 | + $fieldalign = $rtlalign; | |
| 252 | + if ($texto == ' ') { | |
| 253 | + $texto = ''; | |
| 254 | + } // mPDF 5.3.24 | |
| 255 | + if (isset($objattr['text_align']) && $objattr['text_align']) { | |
| 256 | + $fieldalign = $objattr['text_align']; | |
| 257 | + } | |
| 258 | + // mPDF 5.3.25 | |
| 259 | + $js = array(); | |
| 260 | + if (isset($objattr['onCalculate']) && $objattr['onCalculate']) { | |
| 261 | + $js[] = array('C', $objattr['onCalculate']); | |
| 262 | + } | |
| 263 | + if (isset($objattr['onValidate']) && $objattr['onValidate']) { | |
| 264 | + $js[] = array('V', $objattr['onValidate']); | |
| 265 | + } | |
| 266 | + if (isset($objattr['onFormat']) && $objattr['onFormat']) { | |
| 267 | + $js[] = array('F', $objattr['onFormat']); | |
| 268 | + } | |
| 269 | + if (isset($objattr['onKeystroke']) && $objattr['onKeystroke']) { | |
| 270 | + $js[] = array('K', $objattr['onKeystroke']); | |
| 271 | + } | |
| 272 | + $this->SetFormText($w, $h, $objattr['fieldname'], $texto, $texto, (isset($objattr['title']) ? $objattr['title'] : ''), $flags, $fieldalign, false, -1, $js, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false)); | |
| 273 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 274 | + } else { | |
| 275 | + $w -= $this->form_element_spacing['textarea']['outer']['h'] * 2 / $k; | |
| 276 | + $h -= $this->form_element_spacing['textarea']['outer']['v'] * 2 / $k; | |
| 277 | + $this->mpdf->x += $this->form_element_spacing['textarea']['outer']['h'] / $k; | |
| 278 | + $this->mpdf->y += $this->form_element_spacing['textarea']['outer']['v'] / $k; | |
| 279 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 280 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 281 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 282 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 283 | + } else if (isset($objattr['readonly']) && $objattr['readonly']) { | |
| 284 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 285 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 286 | + } else { | |
| 287 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 288 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 289 | + } | |
| 290 | + $this->mpdf->Rect($this->mpdf->x, $this->mpdf->y, $w, $h, 'DF'); | |
| 291 | + $ClipPath = sprintf('q %.3F %.3F %.3F %.3F re W n ', $this->mpdf->x * _MPDFK, ($this->mpdf->h - $this->mpdf->y) * _MPDFK, $w * _MPDFK, -$h * _MPDFK); | |
| 292 | + $this->mpdf->_out($ClipPath); | |
| 293 | + | |
| 294 | + $w -= $this->form_element_spacing['textarea']['inner']['h'] * 2 / $k; | |
| 295 | + $this->mpdf->x += $this->form_element_spacing['textarea']['inner']['h'] / $k; | |
| 296 | + $this->mpdf->y += $this->form_element_spacing['textarea']['inner']['v'] / $k; | |
| 297 | + | |
| 298 | + if ($texto != '') | |
| 299 | + $this->mpdf->MultiCell($w, $this->mpdf->FontSize * $this->textarea_lineheight, $texto, 0, '', 0, '', $blockdir, true, $objattr['OTLdata'], $objattr['rows']); | |
| 300 | + $this->mpdf->_out('Q'); | |
| 301 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 302 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 303 | + } | |
| 304 | + } | |
| 305 | + | |
| 306 | + function print_ob_select($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir) | |
| 307 | + { | |
| 308 | + // SELECT | |
| 309 | + if ($this->mpdf->useActiveForms) { | |
| 310 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; 19 - edit (only if combo) | |
| 311 | + $flags = array(); | |
| 312 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 313 | + $flags[] = 1; // readonly | |
| 314 | + $flags[] = 3; // no export | |
| 315 | + $objattr['color'] = array(3, 128, 128, 128); // gray out disabled | |
| 316 | + } | |
| 317 | + if (isset($objattr['required']) && $objattr['required']) { | |
| 318 | + $flags[] = 2; | |
| 319 | + } // required | |
| 320 | + if (isset($objattr['multiple']) && $objattr['multiple'] && isset($objattr['size']) && $objattr['size'] > 1) { | |
| 321 | + $flags[] = 22; | |
| 322 | + } //flag 22 = multiselect (listbox) | |
| 323 | + if (isset($objattr['size']) && $objattr['size'] < 2) { | |
| 324 | + $flags[] = 18; //flag 18 = combobox (else a listbox) | |
| 325 | + if (isset($objattr['editable']) && $objattr['editable']) { | |
| 326 | + $flags[] = 19; | |
| 327 | + } // editable | |
| 328 | + } | |
| 329 | + // only allow spellcheck if combo and editable | |
| 330 | + if ((!isset($objattr['spellcheck']) || !$objattr['spellcheck']) || (isset($objattr['size']) && $objattr['size'] > 1) || (!isset($objattr['editable']) || !$objattr['editable'])) { | |
| 331 | + $flags[] = 23; | |
| 332 | + } // DoNotSpellCheck | |
| 333 | + if (isset($objattr['subtype']) && $objattr['subtype'] == 'PASSWORD') { | |
| 334 | + $flags[] = 14; | |
| 335 | + } | |
| 336 | + if (isset($objattr['onChange']) && $objattr['onChange']) { | |
| 337 | + $js = $objattr['onChange']; | |
| 338 | + } else { | |
| 339 | + $js = ''; | |
| 340 | + } // mPDF 5.3.37 | |
| 341 | + $data = array('VAL' => array(), 'OPT' => array(), 'SEL' => array(),); | |
| 342 | + if (isset($objattr['items'])) { | |
| 343 | + for ($i = 0; $i < count($objattr['items']); $i++) { | |
| 344 | + $item = $objattr['items'][$i]; | |
| 345 | + $data['VAL'][] = (isset($item['exportValue']) ? $item['exportValue'] : ''); | |
| 346 | + $data['OPT'][] = (isset($item['content']) ? $item['content'] : ''); | |
| 347 | + if (isset($item['selected']) && $item['selected']) { | |
| 348 | + $data['SEL'][] = $i; | |
| 349 | + } | |
| 350 | + } | |
| 351 | + } | |
| 352 | + if (count($data['SEL']) == 0 && $this->formSelectDefaultOption) { | |
| 353 | + $data['SEL'][] = 0; | |
| 354 | + } | |
| 355 | + if (isset($objattr['color'])) { | |
| 356 | + $this->mpdf->SetTColor($objattr['color']); | |
| 357 | + } else { | |
| 358 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 359 | + } | |
| 360 | + $this->SetFormChoice($w, $h, $objattr['fieldname'], $flags, $data, $rtlalign, $js); | |
| 361 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 362 | + } else { | |
| 363 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 364 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 365 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 366 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(127)); | |
| 367 | + } else { | |
| 368 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 369 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 370 | + } | |
| 371 | + $w -= $this->form_element_spacing['select']['outer']['h'] * 2 / $k; | |
| 372 | + $h -= $this->form_element_spacing['select']['outer']['v'] * 2 / $k; | |
| 373 | + $this->mpdf->x += $this->form_element_spacing['select']['outer']['h'] / $k; | |
| 374 | + $this->mpdf->y += $this->form_element_spacing['select']['outer']['v'] / $k; | |
| 375 | + | |
| 376 | + // DIRECTIONALITY | |
| 377 | + if (preg_match("/([" . $this->mpdf->pregRTLchars . "])/u", $texto)) { | |
| 378 | + $this->mpdf->biDirectional = true; | |
| 379 | + } // *RTL* | |
| 380 | + | |
| 381 | + $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $objattr['OTLdata']); | |
| 382 | + | |
| 383 | + $this->mpdf->Cell($w - ($this->mpdf->FontSize * 1.4), $h, $texto, 1, 0, $rtlalign, 1, '', 0, $this->form_element_spacing['select']['inner']['h'] / $k, $this->form_element_spacing['select']['inner']['h'] / $k, 'M', 0, false, $objattr['OTLdata']); | |
| 384 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(190)); | |
| 385 | + $save_font = $this->mpdf->FontFamily; | |
| 386 | + $save_currentfont = $this->mpdf->currentfontfamily; | |
| 387 | + if ($this->mpdf->PDFA || $this->mpdf->PDFX) { | |
| 388 | + if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { | |
| 389 | + $this->mpdf->PDFAXwarnings[] = "Core Adobe font Zapfdingbats cannot be embedded in mPDF - used in Form element: Select - which is required for PDFA1-b or PDFX/1-a. (Different character/font will be substituted.)"; | |
| 390 | + } | |
| 391 | + $this->mpdf->SetFont('sans'); | |
| 392 | + if ($this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9660)) { | |
| 393 | + $down = "\xe2\x96\xbc"; | |
| 394 | + } else { | |
| 395 | + $down = '='; | |
| 396 | + } | |
| 397 | + $this->mpdf->Cell(($this->mpdf->FontSize * 1.4), $h, $down, 1, 0, 'C', 1, '', 0, 0, 0, 'M'); | |
| 398 | + } else { | |
| 399 | + $this->mpdf->SetFont('czapfdingbats', '', 0); | |
| 400 | + $this->mpdf->Cell(($this->mpdf->FontSize * 1.4), $h, chr(116), 1, 0, 'C', 1, '', 0, 0, 0, 'M'); | |
| 401 | + } | |
| 402 | + $this->mpdf->SetFont($save_font, '', 0); | |
| 403 | + $this->mpdf->currentfontfamily = $save_currentfont; | |
| 404 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 405 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 406 | + } | |
| 407 | + } | |
| 408 | + | |
| 409 | + function print_ob_imageinput($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir) | |
| 410 | + { | |
| 411 | + // INPUT/BUTTON as IMAGE | |
| 412 | + if ($this->mpdf->useActiveForms) { | |
| 413 | + // Flags: 1 - Readonly; 3 - No export; | |
| 414 | + $flags = array(); | |
| 415 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 416 | + $flags[] = 1; // readonly | |
| 417 | + $flags[] = 3; // no export | |
| 418 | + } | |
| 419 | + if (isset($objattr['onClick']) && $objattr['onClick']) { | |
| 420 | + $js = $objattr['onClick']; | |
| 421 | + } else { | |
| 422 | + $js = ''; | |
| 423 | + } | |
| 424 | + $this->SetJSButton($w, $h, $objattr['fieldname'], (isset($objattr['value']) ? $objattr['value'] : ''), $js, $objattr['ID'], $objattr['title'], $flags, (isset($objattr['Indexed']) ? $objattr['Indexed'] : false)); | |
| 425 | + } else { | |
| 426 | + $this->mpdf->y = $objattr['INNER-Y']; | |
| 427 | + $this->mpdf->_out(sprintf("q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q", $objattr['INNER-WIDTH'] * _MPDFK, $objattr['INNER-HEIGHT'] * _MPDFK, $objattr['INNER-X'] * _MPDFK, ($this->mpdf->h - ($objattr['INNER-Y'] + $objattr['INNER-HEIGHT'] )) * _MPDFK, $objattr['ID'])); | |
| 428 | + if (isset($objattr['BORDER-WIDTH']) && $objattr['BORDER-WIDTH']) { | |
| 429 | + $this->mpdf->PaintImgBorder($objattr, $is_table); | |
| 430 | + } | |
| 431 | + } | |
| 432 | + } | |
| 433 | + | |
| 434 | + function print_ob_button($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir) | |
| 435 | + { | |
| 436 | + // BUTTON | |
| 437 | + if ($this->mpdf->useActiveForms) { | |
| 438 | + // Flags: 1 - Readonly; 3 - No export; | |
| 439 | + $flags = array(); | |
| 440 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 441 | + $flags[] = 1; // readonly | |
| 442 | + $flags[] = 3; // no export | |
| 443 | + $objattr['color'] = array(3, 128, 128, 128); | |
| 444 | + } | |
| 445 | + if (isset($objattr['color'])) { | |
| 446 | + $this->mpdf->SetTColor($objattr['color']); | |
| 447 | + } else { | |
| 448 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 449 | + } | |
| 450 | + if (isset($objattr['subtype']) && $objattr['subtype'] == 'RESET') { | |
| 451 | + $this->SetFormButtonText($objattr['value']); | |
| 452 | + $this->SetFormReset($w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $flags, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false)); | |
| 453 | + } else if (isset($objattr['subtype']) && $objattr['subtype'] == 'SUBMIT') { | |
| 454 | + $url = $this->formAction; | |
| 455 | + $type = $this->formExportType; | |
| 456 | + $method = $this->formMethod; | |
| 457 | + $this->SetFormButtonText($objattr['value']); | |
| 458 | + $this->SetFormSubmit($w, $h, $objattr['fieldname'], $objattr['value'], $url, $objattr['title'], $type, $method, $flags, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false)); | |
| 459 | + } else if (isset($objattr['subtype']) && $objattr['subtype'] == 'BUTTON') { | |
| 460 | + $this->SetFormButtonText($objattr['value']); | |
| 461 | + if (isset($objattr['onClick']) && $objattr['onClick']) { | |
| 462 | + $js = $objattr['onClick']; | |
| 463 | + } else { | |
| 464 | + $js = ''; | |
| 465 | + } | |
| 466 | + $this->SetJSButton($w, $h, $objattr['fieldname'], $objattr['value'], $js, 0, $objattr['title'], $flags, false, (isset($objattr['background-col']) ? $objattr['background-col'] : false), (isset($objattr['border-col']) ? $objattr['border-col'] : false), (isset($objattr['noprint']) ? $objattr['noprint'] : false)); | |
| 467 | + } | |
| 468 | + $this->mpdf->SetTColor($this->mpdf->ConvertColor(0)); | |
| 469 | + } else { | |
| 470 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 471 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(190)); | |
| 472 | + $w -= $this->form_element_spacing['button']['outer']['h'] * 2 / $k; | |
| 473 | + $h -= $this->form_element_spacing['button']['outer']['v'] * 2 / $k; | |
| 474 | + $this->mpdf->x += $this->form_element_spacing['button']['outer']['h'] / $k; | |
| 475 | + $this->mpdf->y += $this->form_element_spacing['button']['outer']['v'] / $k; | |
| 476 | + $this->mpdf->RoundedRect($this->mpdf->x, $this->mpdf->y, $w, $h, 0.5 / $k, 'DF'); | |
| 477 | + $w -= $this->form_element_spacing['button']['inner']['h'] * 2 / $k; | |
| 478 | + $h -= $this->form_element_spacing['button']['inner']['v'] * 2 / $k; | |
| 479 | + $this->mpdf->x += $this->form_element_spacing['button']['inner']['h'] / $k; | |
| 480 | + $this->mpdf->y += $this->form_element_spacing['button']['inner']['v'] / $k; | |
| 481 | + | |
| 482 | + // DIRECTIONALITY | |
| 483 | + if (preg_match("/([" . $this->mpdf->pregRTLchars . "])/u", $texto)) { | |
| 484 | + $this->mpdf->biDirectional = true; | |
| 485 | + } // *RTL* | |
| 486 | + // Use OTL OpenType Table Layout - GSUB & GPOS | |
| 487 | + if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) { | |
| 488 | + $texto = $this->mpdf->otl->applyOTL($texto, $this->mpdf->CurrentFont['useOTL']); | |
| 489 | + $OTLdata = $this->mpdf->otl->OTLdata; | |
| 490 | + } | |
| 491 | + | |
| 492 | + $this->mpdf->magic_reverse_dir($texto, $this->mpdf->directionality, $OTLdata); | |
| 493 | + | |
| 494 | + $this->mpdf->Cell($w, $h, $texto, '', 0, 'C', 0, '', 0, 0, 0, 'M', 0, false, $OTLdata); | |
| 495 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(0)); | |
| 496 | + } | |
| 497 | + } | |
| 498 | + | |
| 499 | + function print_ob_checkbox($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir, $x, $y) | |
| 500 | + { | |
| 501 | + // CHECKBOX | |
| 502 | + if ($this->mpdf->useActiveForms) { | |
| 503 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; | |
| 504 | + $flags = array(); | |
| 505 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 506 | + $flags[] = 1; // readonly | |
| 507 | + $flags[] = 3; // no export | |
| 508 | + } | |
| 509 | + $checked = false; | |
| 510 | + if (isset($objattr['checked']) && $objattr['checked']) { | |
| 511 | + $checked = true; | |
| 512 | + } | |
| 513 | + if ($this->formUseZapD) { | |
| 514 | + $save_font = $this->mpdf->FontFamily; | |
| 515 | + $save_currentfont = $this->mpdf->currentfontfamily; | |
| 516 | + $this->mpdf->SetFont('czapfdingbats', '', 0); | |
| 517 | + } | |
| 518 | + $this->SetCheckBox($w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $checked, $flags, (isset($objattr['disabled']) ? $objattr['disabled'] : false)); | |
| 519 | + if ($this->formUseZapD) { | |
| 520 | + $this->mpdf->SetFont($save_font, '', 0); | |
| 521 | + $this->mpdf->currentfontfamily = $save_currentfont; | |
| 522 | + } | |
| 523 | + } else { | |
| 524 | + $iw = $w * 0.7; | |
| 525 | + $ih = $h * 0.7; | |
| 526 | + $lx = $x + (($w - $iw) / 2); | |
| 527 | + $ty = $y + (($h - $ih) / 2); | |
| 528 | + $rx = $lx + $iw; | |
| 529 | + $by = $ty + $ih; | |
| 530 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 531 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 532 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(225)); | |
| 533 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(127)); | |
| 534 | + } else { | |
| 535 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(250)); | |
| 536 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 537 | + } | |
| 538 | + $this->mpdf->Rect($lx, $ty, $iw, $ih, 'DF'); | |
| 539 | + if (isset($objattr['checked']) && $objattr['checked']) { | |
| 540 | + //Round join and cap | |
| 541 | + $this->mpdf->SetLineCap(1); | |
| 542 | + $this->mpdf->Line($lx, $ty, $rx, $by); | |
| 543 | + $this->mpdf->Line($lx, $by, $rx, $ty); | |
| 544 | + //Set line cap style back to square | |
| 545 | + $this->mpdf->SetLineCap(2); | |
| 546 | + } | |
| 547 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 548 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 549 | + } | |
| 550 | + } | |
| 551 | + | |
| 552 | + function print_ob_radio($objattr, $w, $h, $texto, $rtlalign, $k, $blockdir, $x, $y) | |
| 553 | + { | |
| 554 | + // RADIO | |
| 555 | + if ($this->mpdf->useActiveForms) { | |
| 556 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; | |
| 557 | + $flags = array(); | |
| 558 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 559 | + $flags[] = 1; // readonly | |
| 560 | + $flags[] = 3; // no export | |
| 561 | + } | |
| 562 | + $checked = false; | |
| 563 | + if (isset($objattr['checked']) && $objattr['checked']) { | |
| 564 | + $checked = true; | |
| 565 | + } | |
| 566 | + if ($this->formUseZapD) { | |
| 567 | + $save_font = $this->mpdf->FontFamily; | |
| 568 | + $save_currentfont = $this->mpdf->currentfontfamily; | |
| 569 | + $this->mpdf->SetFont('czapfdingbats', '', 0); | |
| 570 | + } | |
| 571 | + $this->SetRadio($w, $h, $objattr['fieldname'], $objattr['value'], (isset($objattr['title']) ? $objattr['title'] : ''), $checked, $flags, (isset($objattr['disabled']) ? $objattr['disabled'] : false)); | |
| 572 | + if ($this->formUseZapD) { | |
| 573 | + $this->mpdf->SetFont($save_font, '', 0); | |
| 574 | + $this->mpdf->currentfontfamily = $save_currentfont; | |
| 575 | + } | |
| 576 | + } else { | |
| 577 | + $this->mpdf->SetLineWidth(0.2 / $k); | |
| 578 | + $radius = $this->mpdf->FontSize * 0.35; | |
| 579 | + $cx = $x + ($w / 2); | |
| 580 | + $cy = $y + ($h / 2); | |
| 581 | + if (isset($objattr['disabled']) && $objattr['disabled']) { | |
| 582 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(127)); | |
| 583 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(127)); | |
| 584 | + } else { | |
| 585 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(0)); | |
| 586 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 587 | + } | |
| 588 | + $this->mpdf->Circle($cx, $cy, $radius, 'D'); | |
| 589 | + if (isset($objattr['checked']) && $objattr['checked']) { | |
| 590 | + $this->mpdf->Circle($cx, $cy, $radius * 0.4, 'DF'); | |
| 591 | + } | |
| 592 | + $this->mpdf->SetFColor($this->mpdf->ConvertColor(255)); | |
| 593 | + $this->mpdf->SetDColor($this->mpdf->ConvertColor(0)); | |
| 594 | + } | |
| 595 | + } | |
| 596 | + | |
| 597 | +// In _putpages | |
| 598 | + function countPageForms($n, &$totaladdnum) | |
| 599 | + { | |
| 600 | + foreach ($this->forms as $form) { | |
| 601 | + if ($form['page'] == $n) { | |
| 602 | + $totaladdnum++; | |
| 603 | + if ($form['typ'] == 'Tx') { | |
| 604 | + if (isset($this->array_form_text_js[$form['T']])) { | |
| 605 | + if (isset($this->array_form_text_js[$form['T']]['F'])) { | |
| 606 | + $totaladdnum++; | |
| 607 | + } | |
| 608 | + if (isset($this->array_form_text_js[$form['T']]['K'])) { | |
| 609 | + $totaladdnum++; | |
| 610 | + } | |
| 611 | + if (isset($this->array_form_text_js[$form['T']]['V'])) { | |
| 612 | + $totaladdnum++; | |
| 613 | + } | |
| 614 | + if (isset($this->array_form_text_js[$form['T']]['C'])) { | |
| 615 | + $totaladdnum++; | |
| 616 | + } | |
| 617 | + } | |
| 618 | + } | |
| 619 | + if ($form['typ'] == 'Bt') { | |
| 620 | + if (isset($this->array_form_button_js[$form['T']])) { | |
| 621 | + $totaladdnum++; | |
| 622 | + } | |
| 623 | + if (isset($this->form_button_icon[$form['T']])) { | |
| 624 | + $totaladdnum++; | |
| 625 | + if ($this->form_button_icon[$form['T']]['Indexed']) { | |
| 626 | + $totaladdnum++; | |
| 627 | + } | |
| 628 | + } | |
| 629 | + if ($form['subtype'] == 'radio') { | |
| 630 | + $totaladdnum+=2; | |
| 631 | + } else if ($form['subtype'] == 'checkbox' && $this->formUseZapD) { | |
| 632 | + $totaladdnum++; | |
| 633 | + } else if ($form['subtype'] == 'checkbox' && !$this->formUseZapD) { | |
| 634 | + $totaladdnum+=2; | |
| 635 | + } | |
| 636 | + } | |
| 637 | + if ($form['typ'] == 'Ch') { | |
| 638 | + if (isset($this->array_form_choice_js[$form['T']])) { | |
| 639 | + $totaladdnum++; | |
| 640 | + } | |
| 641 | + } | |
| 642 | + } | |
| 643 | + } | |
| 644 | + } | |
| 645 | + | |
| 646 | +// In _putpages | |
| 647 | + function addFormIds($n, &$s, &$annotid) | |
| 648 | + { | |
| 649 | + foreach ($this->forms as $form) { | |
| 650 | + if ($form['page'] == $n) { | |
| 651 | + $s .= ($annotid) . ' 0 R '; | |
| 652 | + $annotid++; | |
| 653 | + if ($form['typ'] == 'Tx') { | |
| 654 | + if (isset($this->array_form_text_js[$form['T']])) { | |
| 655 | + if (isset($this->array_form_text_js[$form['T']]['F'])) { | |
| 656 | + $annotid++; | |
| 657 | + } | |
| 658 | + if (isset($this->array_form_text_js[$form['T']]['K'])) { | |
| 659 | + $annotid++; | |
| 660 | + } | |
| 661 | + if (isset($this->array_form_text_js[$form['T']]['V'])) { | |
| 662 | + $annotid++; | |
| 663 | + } | |
| 664 | + if (isset($this->array_form_text_js[$form['T']]['C'])) { | |
| 665 | + $annotid++; | |
| 666 | + } | |
| 667 | + } | |
| 668 | + } | |
| 669 | + if ($form['typ'] == 'Bt') { | |
| 670 | + if (isset($this->array_form_button_js[$form['T']])) { | |
| 671 | + $annotid++; | |
| 672 | + } | |
| 673 | + if (isset($this->form_button_icon[$form['T']])) { | |
| 674 | + $annotid++; | |
| 675 | + if ($this->form_button_icon[$form['T']]['Indexed']) { | |
| 676 | + $annotid++; | |
| 677 | + } | |
| 678 | + } | |
| 679 | + if ($form['subtype'] == 'radio') { | |
| 680 | + $annotid+=2; | |
| 681 | + } else if ($form['subtype'] == 'checkbox' && $this->formUseZapD) { | |
| 682 | + $annotid++; | |
| 683 | + } else if ($form['subtype'] == 'checkbox' && !$this->formUseZapD) { | |
| 684 | + $annotid+=2; | |
| 685 | + } | |
| 686 | + } | |
| 687 | + if ($form['typ'] == 'Ch') { | |
| 688 | + if (isset($this->array_form_choice_js[$form['T']])) { | |
| 689 | + $annotid++; | |
| 690 | + } | |
| 691 | + } | |
| 692 | + } | |
| 693 | + } | |
| 694 | + } | |
| 695 | + | |
| 696 | +// In _putannots | |
| 697 | + function _putFormItems($n, $hPt) | |
| 698 | + { | |
| 699 | + foreach ($this->forms as $val) { | |
| 700 | + if ($val['page'] == $n) { | |
| 701 | + if ($val['typ'] == 'Tx') | |
| 702 | + $this->_putform_tx($val, $hPt); | |
| 703 | + if ($val['typ'] == 'Ch') | |
| 704 | + $this->_putform_ch($val, $hPt); | |
| 705 | + if ($val['typ'] == 'Bt') | |
| 706 | + $this->_putform_bt($val, $hPt); | |
| 707 | + } | |
| 708 | + } | |
| 709 | + } | |
| 710 | + | |
| 711 | +// In _putannots | |
| 712 | + function _putRadioItems($n) | |
| 713 | + { | |
| 714 | + // Output Radio Groups | |
| 715 | + $key = 1; | |
| 716 | + foreach ($this->form_radio_groups AS $name => $frg) { | |
| 717 | + $this->mpdf->_newobj(); | |
| 718 | + $this->pdf_acro_array .= $this->mpdf->n . ' 0 R '; | |
| 719 | + $this->mpdf->_out('<<'); | |
| 720 | + $this->mpdf->_out('/Type /Annot '); | |
| 721 | + $this->mpdf->_out('/Subtype /Widget'); | |
| 722 | + $this->mpdf->_out('/NM ' . $this->mpdf->_textstring(sprintf('%04u-%04u', $n, (3000 + $key++)))); | |
| 723 | + $this->mpdf->_out('/M ' . $this->mpdf->_textstring('D:' . date('YmdHis'))); | |
| 724 | + $this->mpdf->_out('/Rect [0 0 0 0] '); | |
| 725 | + $this->mpdf->_out('/FT /Btn '); | |
| 726 | + if (isset($frg['disabled']) && $frg['disabled']) { | |
| 727 | + $flags = array(1, 3, 15, 16); | |
| 728 | + } // NoExport and readonly | |
| 729 | + else { | |
| 730 | + $flags = array(15, 16); | |
| 731 | + } // Flags for Radiobutton, and NoToggleToOff | |
| 732 | + $this->mpdf->_out('/Ff ' . $this->_setflag($flags)); | |
| 733 | + $kstr = ''; | |
| 734 | + $optstr = ''; | |
| 735 | + foreach ($frg['kids'] AS $kid) { | |
| 736 | + $kstr .= $this->forms[$kid['n']]['obj'] . ' 0 R '; | |
| 737 | + // $optstr .= ' '.$this->mpdf->_textstring($kid['OPT']).' '; | |
| 738 | + } | |
| 739 | + $this->mpdf->_out('/Kids [ ' . $kstr . ' ] '); // 11 0 R 12 0 R etc. | |
| 740 | + // $this->mpdf->_out('/Opt [ '.$optstr.' ] '); | |
| 741 | + //V entry holds index corresponding to the appearance state of | |
| 742 | + //whichever child field is currently in the on state = or Off | |
| 743 | + if (isset($frg['on'])) { | |
| 744 | + $state = $frg['on']; | |
| 745 | + } else { | |
| 746 | + $state = 'Off'; | |
| 747 | + } | |
| 748 | + $this->mpdf->_out('/V /' . $state . ' '); | |
| 749 | + $this->mpdf->_out('/DV /' . $state . ' '); | |
| 750 | + $this->mpdf->_out('/T ' . $this->mpdf->_textstring($name) . ' '); | |
| 751 | + $this->mpdf->_out('>>'); | |
| 752 | + $this->mpdf->_out('endobj'); | |
| 753 | + } | |
| 754 | + } | |
| 755 | + | |
| 756 | + function _putFormsCatalog() | |
| 757 | + { | |
| 758 | + if (isset($this->pdf_acro_array)) { | |
| 759 | + $this->mpdf->_out('/AcroForm << /DA (/F1 0 Tf 0 g )'); | |
| 760 | + $this->mpdf->_out('/Q 0'); | |
| 761 | + $this->mpdf->_out('/Fields [' . $this->pdf_acro_array . ']'); | |
| 762 | + $f = ''; | |
| 763 | + foreach ($this->form_fonts AS $fn) { | |
| 764 | + if (is_array($this->mpdf->fonts[$fn]['n'])) { | |
| 765 | + $this->mpdf->Error("Cannot use fonts with SMP or SIP characters for interactive Form elements"); | |
| 766 | + } | |
| 767 | + $f .= '/F' . $this->mpdf->fonts[$fn]['i'] . ' ' . $this->mpdf->fonts[$fn]['n'] . ' 0 R '; | |
| 768 | + } | |
| 769 | + $this->mpdf->_out('/DR << /Font << ' . $f . ' >> >>'); | |
| 770 | + // CO Calculation Order | |
| 771 | + if ($this->pdf_array_co) { | |
| 772 | + $this->mpdf->_out('/CO [' . $this->pdf_array_co . ']'); | |
| 773 | + } | |
| 774 | + $this->mpdf->_out('/NeedAppearances true'); | |
| 775 | + $this->mpdf->_out('>>'); | |
| 776 | + } | |
| 777 | + } | |
| 778 | + | |
| 779 | + function SetFormButtonJS($name, $js) | |
| 780 | + { | |
| 781 | + $js = str_replace("\t", ' ', trim($js)); | |
| 782 | + if (isset($name) && isset($js)) { | |
| 783 | + $this->array_form_button_js[$this->mpdf->_escape($name)] = array( | |
| 784 | + 'js' => $js | |
| 785 | + ); | |
| 786 | + } | |
| 787 | + } | |
| 788 | + | |
| 789 | + function SetFormChoiceJS($name, $js) | |
| 790 | + { | |
| 791 | + $js = str_replace("\t", ' ', trim($js)); | |
| 792 | + if (isset($name) && isset($js)) { | |
| 793 | + $this->array_form_choice_js[$this->mpdf->_escape($name)] = array( | |
| 794 | + 'js' => $js | |
| 795 | + ); | |
| 796 | + } | |
| 797 | + } | |
| 798 | + | |
| 799 | + function SetFormTextJS($name, $js) | |
| 800 | + { | |
| 801 | + for ($i = 0; $i < count($js); $i++) { | |
| 802 | + $j = str_replace("\t", ' ', trim($js[$i][1])); | |
| 803 | + $format = $js[$i][0]; | |
| 804 | + if ($name) { | |
| 805 | + $this->array_form_text_js[$this->mpdf->_escape($name)][$format] = array('js' => $j); | |
| 806 | + } | |
| 807 | + } | |
| 808 | + } | |
| 809 | + | |
| 810 | + function Win1252ToPDFDocEncoding($txt) | |
| 811 | + { | |
| 812 | + $Win1252ToPDFDocEncoding = array( | |
| 813 | + chr(0200) => chr(0240), chr(0214) => chr(0226), chr(0212) => chr(0227), chr(0237) => chr(0230), | |
| 814 | + chr(0225) => chr(0200), chr(0210) => chr(0032), chr(0206) => chr(0201), chr(0207) => chr(0202), | |
| 815 | + chr(0205) => chr(0203), chr(0227) => chr(0204), chr(0226) => chr(0205), chr(0203) => chr(0206), | |
| 816 | + chr(0213) => chr(0210), chr(0233) => chr(0211), chr(0211) => chr(0213), chr(0204) => chr(0214), | |
| 817 | + chr(0223) => chr(0215), chr(0224) => chr(0216), chr(0221) => chr(0217), chr(0222) => chr(0220), | |
| 818 | + chr(0202) => chr(0221), chr(0232) => chr(0235), chr(0230) => chr(0037), chr(0231) => chr(0222), | |
| 819 | + chr(0216) => chr(0231), chr(0240) => chr(0040) | |
| 820 | + ); // mPDF 5.3.46 | |
| 821 | + return strtr($txt, $Win1252ToPDFDocEncoding); | |
| 822 | + } | |
| 823 | + | |
| 824 | + function SetFormText($w, $h, $name, $value = '', $default = '', $title = '', $flags = array(), $align = 'L', $hidden = false, $maxlen = -1, $js = '', $background_col = false, $border_col = false) | |
| 825 | + { | |
| 826 | + // Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password | |
| 827 | + $this->formn++; | |
| 828 | + if ($align == 'C') { | |
| 829 | + $align = '1'; | |
| 830 | + } else if ($align == 'R') { | |
| 831 | + $align = '2'; | |
| 832 | + } else { | |
| 833 | + $align = '0'; | |
| 834 | + } | |
| 835 | + if ($maxlen < 1) { | |
| 836 | + $maxlen = false; | |
| 837 | + } | |
| 838 | + if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 839 | + $this->mpdf->Error("Field [" . $name . "] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 840 | + } | |
| 841 | + if ($this->mpdf->onlyCoreFonts) { | |
| 842 | + $value = $this->Win1252ToPDFDocEncoding($value); | |
| 843 | + $default = $this->Win1252ToPDFDocEncoding($default); | |
| 844 | + $title = $this->Win1252ToPDFDocEncoding($title); | |
| 845 | + } else { | |
| 846 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 847 | + $this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset | |
| 848 | + $this->mpdf->UTF8StringToArray($default, true); // Add characters to font subset | |
| 849 | + $this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset | |
| 850 | + } | |
| 851 | + if ($value) | |
| 852 | + $value = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 853 | + if ($default) | |
| 854 | + $default = $this->mpdf->UTF8ToUTF16BE($default, true); | |
| 855 | + $title = $this->mpdf->UTF8ToUTF16BE($title, true); | |
| 856 | + } | |
| 857 | + if ($background_col) { | |
| 858 | + $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); | |
| 859 | + } else { | |
| 860 | + $bg_c = $this->form_background_color; | |
| 861 | + } | |
| 862 | + if ($border_col) { | |
| 863 | + $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); | |
| 864 | + } else { | |
| 865 | + $bc_c = $this->form_border_color; | |
| 866 | + } | |
| 867 | + $f = array('n' => $this->formn, | |
| 868 | + 'typ' => 'Tx', | |
| 869 | + 'page' => $this->mpdf->page, | |
| 870 | + 'x' => $this->mpdf->x, | |
| 871 | + 'y' => $this->mpdf->y, | |
| 872 | + 'w' => $w, | |
| 873 | + 'h' => $h, | |
| 874 | + 'T' => $name, | |
| 875 | + 'FF' => $flags, | |
| 876 | + 'V' => $value, | |
| 877 | + 'DV' => $default, | |
| 878 | + 'TU' => $title, | |
| 879 | + 'hidden' => $hidden, | |
| 880 | + 'Q' => $align, | |
| 881 | + 'maxlen' => $maxlen, | |
| 882 | + 'BS_W' => $this->form_border_width, | |
| 883 | + 'BS_S' => $this->form_border_style, | |
| 884 | + 'BC_C' => $bc_c, | |
| 885 | + 'BG_C' => $bg_c, | |
| 886 | + 'style' => array( | |
| 887 | + 'font' => $this->mpdf->FontFamily, | |
| 888 | + 'fontsize' => $this->mpdf->FontSizePt, | |
| 889 | + 'fontcolor' => $this->mpdf->TextColor, | |
| 890 | + ) | |
| 891 | + ); | |
| 892 | + if (is_array($js) && count($js) > 0) { | |
| 893 | + $this->SetFormTextJS($name, $js); | |
| 894 | + } // mPDF 5.3.25 | |
| 895 | + if ($this->mpdf->keep_block_together) { | |
| 896 | + $this->mpdf->ktForms[] = $f; | |
| 897 | + } else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { | |
| 898 | + $this->mpdf->HTMLheaderPageForms[] = $f; | |
| 899 | + } else { | |
| 900 | + if ($this->mpdf->ColActive) { | |
| 901 | + $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 902 | + 'h' => $h); | |
| 903 | + $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 904 | + } | |
| 905 | + $this->forms[$this->formn] = $f; | |
| 906 | + } | |
| 907 | + if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 908 | + $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 909 | + $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 910 | + } | |
| 911 | + if (!$hidden) | |
| 912 | + $this->mpdf->x += $w; | |
| 913 | + } | |
| 914 | + | |
| 915 | + function SetFormChoice($w, $h, $name, $flags, $array, $align = 'L', $js = '') | |
| 916 | + { | |
| 917 | + $this->formn++; | |
| 918 | + if ($this->mpdf->blk[$this->mpdf->blklvl]['direction'] == 'rtl') { | |
| 919 | + $align = '2'; | |
| 920 | + } else { | |
| 921 | + $align = '0'; | |
| 922 | + } | |
| 923 | + if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 924 | + $this->mpdf->Error("Field [" . $name . "] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 925 | + } | |
| 926 | + if ($this->mpdf->onlyCoreFonts) { | |
| 927 | + for ($i = 0; $i < count($array['VAL']); $i++) { | |
| 928 | + $array['VAL'][$i] = $this->Win1252ToPDFDocEncoding($array['VAL'][$i]); | |
| 929 | + $array['OPT'][$i] = $this->Win1252ToPDFDocEncoding($array['OPT'][$i]); | |
| 930 | + } | |
| 931 | + } else { | |
| 932 | + for ($i = 0; $i < count($array['VAL']); $i++) { | |
| 933 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 934 | + $this->mpdf->UTF8StringToArray($array['VAL'][$i], true); // Add characters to font subset | |
| 935 | + $this->mpdf->UTF8StringToArray($array['OPT'][$i], true); // Add characters to font subset | |
| 936 | + } | |
| 937 | + if ($array['VAL'][$i]) | |
| 938 | + $array['VAL'][$i] = $this->mpdf->UTF8ToUTF16BE($array['VAL'][$i], true); | |
| 939 | + if ($array['OPT'][$i]) | |
| 940 | + $array['OPT'][$i] = $this->mpdf->UTF8ToUTF16BE($array['OPT'][$i], true); | |
| 941 | + } | |
| 942 | + } | |
| 943 | + $f = array('n' => $this->formn, | |
| 944 | + 'typ' => 'Ch', | |
| 945 | + 'page' => $this->mpdf->page, | |
| 946 | + 'x' => $this->mpdf->x, | |
| 947 | + 'y' => $this->mpdf->y, | |
| 948 | + 'w' => $w, | |
| 949 | + 'h' => $h, | |
| 950 | + 'T' => $name, | |
| 951 | + 'OPT' => $array, | |
| 952 | + 'FF' => $flags, | |
| 953 | + 'Q' => $align, | |
| 954 | + 'BS_W' => $this->form_border_width, | |
| 955 | + 'BS_S' => $this->form_border_style, | |
| 956 | + 'BC_C' => $this->form_border_color, | |
| 957 | + 'BG_C' => $this->form_background_color, | |
| 958 | + 'style' => array( | |
| 959 | + 'font' => $this->mpdf->FontFamily, | |
| 960 | + 'fontsize' => $this->mpdf->FontSizePt, | |
| 961 | + 'fontcolor' => $this->mpdf->TextColor, | |
| 962 | + ) | |
| 963 | + ); | |
| 964 | + if ($js) { | |
| 965 | + $this->SetFormChoiceJS($name, $js); | |
| 966 | + } | |
| 967 | + if ($this->mpdf->keep_block_together) { | |
| 968 | + $this->mpdf->ktForms[] = $f; | |
| 969 | + } else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { | |
| 970 | + $this->mpdf->HTMLheaderPageForms[] = $f; | |
| 971 | + } else { | |
| 972 | + if ($this->mpdf->ColActive) { | |
| 973 | + $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 974 | + 'h' => $h); | |
| 975 | + $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 976 | + } | |
| 977 | + $this->forms[$this->formn] = $f; | |
| 978 | + } | |
| 979 | + if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 980 | + $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 981 | + $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 982 | + } | |
| 983 | + $this->mpdf->x += $w; | |
| 984 | + } | |
| 985 | + | |
| 986 | + // CHECKBOX | |
| 987 | + function SetCheckBox($w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled = false) | |
| 988 | + { | |
| 989 | + $this->SetFormButton($w, $h, $name, $value, 'checkbox', $title, $flags, $checked, $disabled); | |
| 990 | + $this->mpdf->x += $w; | |
| 991 | + } | |
| 992 | + | |
| 993 | + // RADIO | |
| 994 | + function SetRadio($w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled = false) | |
| 995 | + { | |
| 996 | + $this->SetFormButton($w, $h, $name, $value, 'radio', $title, $flags, $checked, $disabled); | |
| 997 | + $this->mpdf->x += $w; | |
| 998 | + } | |
| 999 | + | |
| 1000 | + function SetFormReset($w, $h, $name, $value = 'Reset', $title = '', $flags = array(), $background_col = false, $border_col = false, $noprint = false) | |
| 1001 | + { | |
| 1002 | + if (!$name) { | |
| 1003 | + $name = 'Reset'; | |
| 1004 | + } | |
| 1005 | + $this->SetFormButton($w, $h, $name, $value, 'reset', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 1006 | + $this->mpdf->x += $w; | |
| 1007 | + } | |
| 1008 | + | |
| 1009 | + function SetJSButton($w, $h, $name, $value, $js, $image_id = 0, $title = '', $flags = array(), $indexed = false, $background_col = false, $border_col = false, $noprint = false) | |
| 1010 | + { | |
| 1011 | + $this->SetFormButton($w, $h, $name, $value, 'js_button', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 1012 | + // pos => 1 = no caption, icon only; 0 = caption only | |
| 1013 | + if ($image_id) { | |
| 1014 | + $this->form_button_icon[$this->mpdf->_escape($name)] = array( | |
| 1015 | + 'pos' => 1, | |
| 1016 | + 'image_id' => $image_id, | |
| 1017 | + 'Indexed' => $indexed, | |
| 1018 | + ); | |
| 1019 | + } | |
| 1020 | + if ($js) { | |
| 1021 | + $this->SetFormButtonJS($name, $js); | |
| 1022 | + } | |
| 1023 | + $this->mpdf->x += $w; | |
| 1024 | + } | |
| 1025 | + | |
| 1026 | + function SetFormSubmit($w, $h, $name, $value = 'Submit', $url, $title = '', $typ = 'html', $method = 'POST', $flags = array(), $background_col = false, $border_col = false, $noprint = false) | |
| 1027 | + { | |
| 1028 | + if (!$name) { | |
| 1029 | + $name = 'Submit'; | |
| 1030 | + } | |
| 1031 | + $this->SetFormButton($w, $h, $name, $value, 'submit', $title, $flags, false, false, $background_col, $border_col, $noprint); | |
| 1032 | + $this->forms[$this->formn]['URL'] = $url; | |
| 1033 | + $this->forms[$this->formn]['method'] = $method; | |
| 1034 | + $this->forms[$this->formn]['exporttype'] = $typ; | |
| 1035 | + $this->mpdf->x += $w; | |
| 1036 | + } | |
| 1037 | + | |
| 1038 | + function SetFormButtonText($ca, $rc = '', $ac = '') | |
| 1039 | + { | |
| 1040 | + if ($this->mpdf->onlyCoreFonts) { | |
| 1041 | + $ca = $this->Win1252ToPDFDocEncoding($ca); | |
| 1042 | + if ($rc) | |
| 1043 | + $rc = $this->Win1252ToPDFDocEncoding($rc); | |
| 1044 | + if ($ac) | |
| 1045 | + $ac = $this->Win1252ToPDFDocEncoding($ac); | |
| 1046 | + } | |
| 1047 | + else { | |
| 1048 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 1049 | + $this->mpdf->UTF8StringToArray($ca, true); // Add characters to font subset | |
| 1050 | + } | |
| 1051 | + $ca = $this->mpdf->UTF8ToUTF16BE($ca, true); | |
| 1052 | + if ($rc) { | |
| 1053 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 1054 | + $this->mpdf->UTF8StringToArray($rc, true); | |
| 1055 | + } | |
| 1056 | + $rc = $this->mpdf->UTF8ToUTF16BE($rc, true); | |
| 1057 | + } | |
| 1058 | + if ($ac) { | |
| 1059 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 1060 | + $this->mpdf->UTF8StringToArray($ac, true); | |
| 1061 | + } | |
| 1062 | + $ac = $this->mpdf->UTF8ToUTF16BE($ac, true); | |
| 1063 | + } | |
| 1064 | + } | |
| 1065 | + $this->form_button_text = $ca; | |
| 1066 | + $this->form_button_text_over = $rc ? $rc : $ca; | |
| 1067 | + $this->form_button_text_click = $ac ? $ac : $ca; | |
| 1068 | + } | |
| 1069 | + | |
| 1070 | + function SetFormButton($bb, $hh, $name, $value, $type, $title = '', $flags = array(), $checked = false, $disabled = false, $background_col = false, $border_col = false, $noprint = false) | |
| 1071 | + { | |
| 1072 | + $this->formn++; | |
| 1073 | + if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) { | |
| 1074 | + $this->mpdf->Error("Field [" . $name . "] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)"); | |
| 1075 | + } | |
| 1076 | + if (!$this->mpdf->onlyCoreFonts) { | |
| 1077 | + if (isset($this->mpdf->CurrentFont['subset'])) { | |
| 1078 | + $this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset | |
| 1079 | + $this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset | |
| 1080 | + } | |
| 1081 | + $title = $this->mpdf->UTF8ToUTF16BE($title, true); | |
| 1082 | + if ($type == 'checkbox') { | |
| 1083 | + $uvalue = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 1084 | + } else if ($type == 'radio') { | |
| 1085 | + $uvalue = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 1086 | + $value = mb_convert_encoding($value, 'Windows-1252', 'UTF-8'); | |
| 1087 | + } else { | |
| 1088 | + $value = $this->mpdf->UTF8ToUTF16BE($value, true); | |
| 1089 | + $uvalue = $value; | |
| 1090 | + } | |
| 1091 | + } else { | |
| 1092 | + $title = $this->Win1252ToPDFDocEncoding($title); | |
| 1093 | + $value = $this->Win1252ToPDFDocEncoding($value); //// ??? not needed | |
| 1094 | + $uvalue = mb_convert_encoding($value, 'UTF-8', 'Windows-1252'); | |
| 1095 | + $uvalue = $this->mpdf->UTF8ToUTF16BE($uvalue, true); | |
| 1096 | + } | |
| 1097 | + if ($type == 'radio' || $type == 'checkbox') { | |
| 1098 | + if (!preg_match('/^[a-zA-Z0-9_:\-\.]+$/', $value)) { | |
| 1099 | + $this->mpdf->Error("Field '" . $name . "' must have a value, which can only contain letters, numbers, colon(:), undersore(_), hyphen(-) or period(.)"); | |
| 1100 | + } | |
| 1101 | + } | |
| 1102 | + if ($type == 'radio') { | |
| 1103 | + if (!isset($this->form_radio_groups[$name])) { | |
| 1104 | + $this->form_radio_groups[$name] = array( | |
| 1105 | + 'page' => $this->mpdf->page, | |
| 1106 | + 'kids' => array(), | |
| 1107 | + ); | |
| 1108 | + } | |
| 1109 | + $this->form_radio_groups[$name]['kids'][] = array( | |
| 1110 | + 'n' => $this->formn, 'V' => $value, 'OPT' => $uvalue, 'disabled' => $disabled | |
| 1111 | + ); | |
| 1112 | + if ($checked) { | |
| 1113 | + $this->form_radio_groups[$name]['on'] = $value; | |
| 1114 | + } | |
| 1115 | + // Disable the whole radio group if one is disabled, because of inconsistency in PDF readers | |
| 1116 | + if ($disabled) { | |
| 1117 | + $this->form_radio_groups[$name]['disabled'] = true; | |
| 1118 | + } | |
| 1119 | + } | |
| 1120 | + if ($type == 'checkbox') { | |
| 1121 | + $this->form_checkboxes = true; | |
| 1122 | + } | |
| 1123 | + if ($checked) { | |
| 1124 | + $activ = 1; | |
| 1125 | + } else { | |
| 1126 | + $activ = 0; | |
| 1127 | + } | |
| 1128 | + if ($background_col) { | |
| 1129 | + $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); | |
| 1130 | + } else { | |
| 1131 | + $bg_c = $this->form_button_background_color; | |
| 1132 | + } | |
| 1133 | + if ($border_col) { | |
| 1134 | + $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); | |
| 1135 | + } else { | |
| 1136 | + $bc_c = $this->form_button_border_color; | |
| 1137 | + } | |
| 1138 | + $f = array('n' => $this->formn, | |
| 1139 | + 'typ' => 'Bt', | |
| 1140 | + 'page' => $this->mpdf->page, | |
| 1141 | + 'subtype' => $type, | |
| 1142 | + 'x' => $this->mpdf->x, | |
| 1143 | + 'y' => $this->mpdf->y, | |
| 1144 | + 'w' => $bb, | |
| 1145 | + 'h' => $hh, | |
| 1146 | + 'T' => $name, | |
| 1147 | + 'V' => $value, | |
| 1148 | + 'OPT' => $uvalue, | |
| 1149 | + 'TU' => $title, | |
| 1150 | + 'FF' => $flags, | |
| 1151 | + 'CA' => $this->form_button_text, | |
| 1152 | + 'RC' => $this->form_button_text_over, | |
| 1153 | + 'AC' => $this->form_button_text_click, | |
| 1154 | + 'BS_W' => $this->form_button_border_width, | |
| 1155 | + 'BS_S' => $this->form_button_border_style, | |
| 1156 | + 'BC_C' => $bc_c, | |
| 1157 | + 'BG_C' => $bg_c, | |
| 1158 | + 'activ' => $activ, | |
| 1159 | + 'disabled' => $disabled, | |
| 1160 | + 'noprint' => $noprint, | |
| 1161 | + 'style' => array( | |
| 1162 | + 'font' => $this->mpdf->FontFamily, | |
| 1163 | + 'fontsize' => $this->mpdf->FontSizePt, | |
| 1164 | + 'fontcolor' => $this->mpdf->TextColor, | |
| 1165 | + ) | |
| 1166 | + ); | |
| 1167 | + if ($this->mpdf->keep_block_together) { | |
| 1168 | + $this->mpdf->ktForms[] = $f; | |
| 1169 | + } else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { | |
| 1170 | + $this->mpdf->HTMLheaderPageForms[] = $f; | |
| 1171 | + } else { | |
| 1172 | + if ($this->mpdf->ColActive) { | |
| 1173 | + $this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y, | |
| 1174 | + 'h' => $hh); | |
| 1175 | + $this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn; | |
| 1176 | + } | |
| 1177 | + $this->forms[$this->formn] = $f; | |
| 1178 | + } | |
| 1179 | + if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) { | |
| 1180 | + $this->form_fonts[] = $this->mpdf->FontFamily; | |
| 1181 | + $this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true; | |
| 1182 | + } | |
| 1183 | + | |
| 1184 | + $this->form_button_text = NULL; | |
| 1185 | + $this->form_button_text_over = NULL; | |
| 1186 | + $this->form_button_text_click = NULL; | |
| 1187 | + } | |
| 1188 | + | |
| 1189 | + function SetFormBorderWidth($string) | |
| 1190 | + { | |
| 1191 | + switch ($string) { | |
| 1192 | + case 'S': $this->form_border_width = '1'; | |
| 1193 | + break; | |
| 1194 | + case 'M': $this->form_border_width = '2'; | |
| 1195 | + break; | |
| 1196 | + case 'B': $this->form_border_width = '3'; | |
| 1197 | + break; | |
| 1198 | + case '0': $this->form_border_width = '0'; | |
| 1199 | + break; | |
| 1200 | + default: $this->form_border_width = '0'; | |
| 1201 | + break; | |
| 1202 | + } | |
| 1203 | + } | |
| 1204 | + | |
| 1205 | + function SetFormBorderStyle($string) | |
| 1206 | + { | |
| 1207 | + switch ($string) { | |
| 1208 | + case 'S': $this->form_border_style = 'S'; | |
| 1209 | + break; | |
| 1210 | + case 'D': $this->form_border_style = 'D /D [3]'; | |
| 1211 | + break; | |
| 1212 | + case 'B': $this->form_border_style = 'B'; | |
| 1213 | + break; | |
| 1214 | + case 'I': $this->form_border_style = 'I'; | |
| 1215 | + break; | |
| 1216 | + case 'U': $this->form_border_style = 'U'; | |
| 1217 | + break; | |
| 1218 | + default: $this->form_border_style = 'B'; | |
| 1219 | + break; | |
| 1220 | + } | |
| 1221 | + } | |
| 1222 | + | |
| 1223 | + function SetFormBorderColor($r, $g = -1, $b = -1) | |
| 1224 | + { | |
| 1225 | + if (($r == 0 and $g == 0 and $b == 0) || $g == -1) | |
| 1226 | + $this->form_border_color = sprintf('%.3F', $r / 255); | |
| 1227 | + else | |
| 1228 | + $this->form_border_color = sprintf('%.3F %.3F %.3F', $r / 255, $g / 255, $b / 255); | |
| 1229 | + } | |
| 1230 | + | |
| 1231 | + function SetFormBackgroundColor($r, $g = -1, $b = -1) | |
| 1232 | + { | |
| 1233 | + if (($r == 0 and $g == 0 and $b == 0) || $g == -1) | |
| 1234 | + $this->form_background_color = sprintf('%.3F', $r / 255); | |
| 1235 | + else | |
| 1236 | + $this->form_background_color = sprintf('%.3F %.3F %.3F', $r / 255, $g / 255, $b / 255); | |
| 1237 | + } | |
| 1238 | + | |
| 1239 | + function SetFormD($W, $S, $BC, $BG) | |
| 1240 | + { | |
| 1241 | + $this->SetFormBorderWidth($W); | |
| 1242 | + $this->SetFormBorderStyle($S); | |
| 1243 | + $this->SetFormBorderColor($BC); | |
| 1244 | + $this->SetFormBackgroundColor($BG); | |
| 1245 | + } | |
| 1246 | + | |
| 1247 | + function _setflag($array) | |
| 1248 | + { | |
| 1249 | + $flag = 0; | |
| 1250 | + foreach ($array as $val) { | |
| 1251 | + $flag += 1 << ($val - 1); | |
| 1252 | + } | |
| 1253 | + return $flag; | |
| 1254 | + } | |
| 1255 | + | |
| 1256 | + function _form_rect($x, $y, $w, $h, $hPt) | |
| 1257 | + { | |
| 1258 | + $x = $x * _MPDFK; | |
| 1259 | + $y = $hPt - ($y * _MPDFK); | |
| 1260 | + $x2 = $x + ($w * _MPDFK); | |
| 1261 | + $y2 = $y - ($h * _MPDFK); | |
| 1262 | + $rect = sprintf('%.3F %.3F %.3F %.3F', $x, $y2, $x2, $y); | |
| 1263 | + return $rect; | |
| 1264 | + } | |
| 1265 | + | |
| 1266 | + function _put_button_icon($array, $w, $h) | |
| 1267 | + { | |
| 1268 | + if (isset($array['image_id'])) { | |
| 1269 | + $info = false; | |
| 1270 | + foreach ($this->mpdf->images AS $iid => $img) { | |
| 1271 | + if ($img['i'] == $array['image_id']) { | |
| 1272 | + $info = $this->mpdf->images[$iid]; | |
| 1273 | + break; | |
| 1274 | + } | |
| 1275 | + } | |
| 1276 | + } | |
| 1277 | + if (!$info) { | |
| 1278 | + throw new MpdfException("Cannot find Button image"); | |
| 1279 | + } | |
| 1280 | + $this->mpdf->_newobj(); | |
| 1281 | + $this->mpdf->_out('<<'); | |
| 1282 | + $this->mpdf->_out('/Type /XObject'); | |
| 1283 | + $this->mpdf->_out('/Subtype /Image'); | |
| 1284 | + $this->mpdf->_out('/BBox [0 0 1 1]'); | |
| 1285 | + $this->mpdf->_out('/Length ' . strlen($info['data'])); | |
| 1286 | + $this->mpdf->_out('/BitsPerComponent ' . $info['bpc']); | |
| 1287 | + if ($info['cs'] == 'Indexed') { | |
| 1288 | + $this->mpdf->_out('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->mpdf->n + 1) . ' 0 R]'); | |
| 1289 | + } else { | |
| 1290 | + $this->mpdf->_out('/ColorSpace /' . $info['cs']); | |
| 1291 | + if ($info['cs'] == 'DeviceCMYK') | |
| 1292 | + if ($info['type'] == 'jpg') { | |
| 1293 | + $this->mpdf->_out('/Decode [1 0 1 0 1 0 1 0]'); | |
| 1294 | + } | |
| 1295 | + } | |
| 1296 | + if (isset($info['f'])) | |
| 1297 | + $this->mpdf->_out('/Filter /' . $info['f']); | |
| 1298 | + if (isset($info['parms'])) | |
| 1299 | + $this->mpdf->_out($info['parms']); | |
| 1300 | + $this->mpdf->_out('/Width ' . $info['w']); | |
| 1301 | + $this->mpdf->_out('/Height ' . $info['h']); | |
| 1302 | + $this->mpdf->_out('>>'); | |
| 1303 | + $this->mpdf->_putstream($info['data']); | |
| 1304 | + $this->mpdf->_out('endobj'); | |
| 1305 | + unset($array); | |
| 1306 | + //Palette | |
| 1307 | + if ($info['cs'] == 'Indexed') { | |
| 1308 | + $filter = ($this->mpdf->compress) ? '/Filter /FlateDecode ' : ''; | |
| 1309 | + $this->mpdf->_newobj(); | |
| 1310 | + $pal = ($this->mpdf->compress) ? gzcompress($info['pal']) : $info['pal']; | |
| 1311 | + $this->mpdf->_out('<<' . $filter . '/Length ' . strlen($pal) . '>>'); | |
| 1312 | + $this->mpdf->_putstream($pal); | |
| 1313 | + $this->mpdf->_out('endobj'); | |
| 1314 | + } | |
| 1315 | + } | |
| 1316 | + | |
| 1317 | + function _putform_bt($form, $hPt) | |
| 1318 | + { | |
| 1319 | + $cc = 0; | |
| 1320 | + $put_xobject = 0; | |
| 1321 | + $put_js = 0; | |
| 1322 | + $put_icon = 0; | |
| 1323 | + $this->mpdf->_newobj(); | |
| 1324 | + $n = $this->mpdf->n; | |
| 1325 | + if ($form['subtype'] != 'radio') | |
| 1326 | + $this->pdf_acro_array .= $n . ' 0 R '; // Add to /Field element | |
| 1327 | + $this->forms[$form['n']]['obj'] = $n; | |
| 1328 | + $this->mpdf->_out('<<'); | |
| 1329 | + $this->mpdf->_out('/Type /Annot '); | |
| 1330 | + $this->mpdf->_out('/Subtype /Widget'); | |
| 1331 | + $this->mpdf->_out('/NM ' . $this->mpdf->_textstring(sprintf('%04u-%04u', $n, (7000 + $form['n'])))); | |
| 1332 | + $this->mpdf->_out('/M ' . $this->mpdf->_textstring('D:' . date('YmdHis'))); | |
| 1333 | + $this->mpdf->_out('/Rect [ ' . $this->_form_rect($form['x'], $form['y'], $form['w'], $form['h'], $hPt) . ' ]'); | |
| 1334 | + $form['noprint'] ? $this->mpdf->_out('/F 0 ') : $this->mpdf->_out('/F 4 '); | |
| 1335 | + $this->mpdf->_out('/FT /Btn '); | |
| 1336 | + $this->mpdf->_out('/H /P '); | |
| 1337 | + if ($form['subtype'] != 'radio') // mPDF 5.3.23 | |
| 1338 | + $this->mpdf->_out('/T ' . $this->mpdf->_textstring($form['T'])); | |
| 1339 | + $this->mpdf->_out('/TU ' . $this->mpdf->_textstring($form['TU'])); | |
| 1340 | + if (isset($this->form_button_icon[$form['T']])) { | |
| 1341 | + $form['BS_W'] = 0; | |
| 1342 | + } | |
| 1343 | + if ($form['BS_W'] == 0) { | |
| 1344 | + $form['BC_C'] = $form['BG_C']; | |
| 1345 | + } | |
| 1346 | + $bstemp = ''; | |
| 1347 | + $bstemp .= '/W ' . $form['BS_W'] . ' '; | |
| 1348 | + $bstemp .= '/S /' . $form['BS_S'] . ' '; | |
| 1349 | + $temp = ''; | |
| 1350 | + $temp .= '/BC [ ' . $form['BC_C'] . " ] "; | |
| 1351 | + $temp .= '/BG [ ' . $form['BG_C'] . " ] "; | |
| 1352 | + if ($form['subtype'] == 'checkbox') { | |
| 1353 | + if ($form['disabled']) { | |
| 1354 | + $radio_color = '0.5 0.5 0.5'; | |
| 1355 | + $radio_background_color = '0.9 0.9 0.9'; | |
| 1356 | + } else { | |
| 1357 | + $radio_color = $this->form_radio_color; | |
| 1358 | + $radio_background_color = $this->form_radio_background_color; | |
| 1359 | + } | |
| 1360 | + $temp = ''; | |
| 1361 | + $temp .= '/BC [ ' . $radio_color . " ] "; | |
| 1362 | + $temp .= '/BG [ ' . $radio_background_color . " ] "; | |
| 1363 | + $this->mpdf->_out("/BS << /W 1 /S /S >>"); | |
| 1364 | + $this->mpdf->_out("/MK << $temp >>"); | |
| 1365 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF'])); | |
| 1366 | + if ($form['activ']) { | |
| 1367 | + $this->mpdf->_out('/V /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1368 | + $this->mpdf->_out('/DV /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1369 | + $this->mpdf->_out('/AS /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1370 | + } else { | |
| 1371 | + $this->mpdf->_out('/AS /Off '); | |
| 1372 | + } | |
| 1373 | + if ($this->formUseZapD) { | |
| 1374 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts['czapfdingbats']['i'] . ' 0 Tf ' . $radio_color . ' rg)'); | |
| 1375 | + $this->mpdf->_out("/AP << /N << /" . $this->mpdf->_escape($form['V']) . " " . ($this->mpdf->n + 1) . " 0 R /Off /Off >> >>"); | |
| 1376 | + } else { | |
| 1377 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'] . ' 0 Tf ' . $radio_color . ' rg)'); | |
| 1378 | + $this->mpdf->_out("/AP << /N << /" . $this->mpdf->_escape($form['V']) . " " . ($this->mpdf->n + 1) . " 0 R /Off " . ($this->mpdf->n + 2) . " 0 R >> >>"); | |
| 1379 | + } | |
| 1380 | + $this->mpdf->_out('/Opt [ ' . $this->mpdf->_textstring($form['OPT']) . ' ' . $this->mpdf->_textstring($form['OPT']) . ' ]'); | |
| 1381 | + } | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + if ($form['subtype'] == 'radio') { | |
| 1385 | + if ((isset($form['disabled']) && $form['disabled']) || (isset($this->form_radio_groups[$form['T']]['disabled']) && $this->form_radio_groups[$form['T']]['disabled'])) { | |
| 1386 | + $radio_color = '0.5 0.5 0.5'; | |
| 1387 | + $radio_background_color = '0.9 0.9 0.9'; | |
| 1388 | + } else { | |
| 1389 | + $radio_color = $this->form_radio_color; | |
| 1390 | + $radio_background_color = $this->form_radio_background_color; | |
| 1391 | + } | |
| 1392 | + $this->mpdf->_out('/Parent ' . $this->form_radio_groups[$form['T']]['obj_id'] . ' 0 R '); | |
| 1393 | + $temp = ''; | |
| 1394 | + $temp .= '/BC [ ' . $radio_color . " ] "; | |
| 1395 | + $temp .= '/BG [ ' . $radio_background_color . " ] "; | |
| 1396 | + $this->mpdf->_out("/BS << /W 1 /S /S >>"); | |
| 1397 | + $this->mpdf->_out('/MK << ' . $temp . ' >> '); | |
| 1398 | + $form['FF'][] = 16; // Radiobutton | |
| 1399 | + $form['FF'][] = 15; // NoToggleOff - must be same as radio button group setting? | |
| 1400 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF'])); | |
| 1401 | + if ($this->formUseZapD) | |
| 1402 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts['czapfdingbats']['i'] . ' 0 Tf ' . $radio_color . ' rg)'); | |
| 1403 | + else | |
| 1404 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'] . ' 0 Tf ' . $radio_color . ' rg)'); | |
| 1405 | + $this->mpdf->_out("/AP << /N << /" . $this->mpdf->_escape($form['V']) . " " . ($this->mpdf->n + 1) . " 0 R /Off " . ($this->mpdf->n + 2) . " 0 R >> >>"); | |
| 1406 | + if ($form['activ']) { | |
| 1407 | + $this->mpdf->_out('/V /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1408 | + $this->mpdf->_out('/DV /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1409 | + $this->mpdf->_out('/AS /' . $this->mpdf->_escape($form['V']) . ' '); | |
| 1410 | + } else { | |
| 1411 | + $this->mpdf->_out('/AS /Off '); | |
| 1412 | + } | |
| 1413 | + $this->mpdf->_out("/AP << /N << /" . $this->mpdf->_escape($form['V']) . " " . ($this->mpdf->n + 1) . " 0 R /Off " . ($this->mpdf->n + 2) . " 0 R >> >>"); | |
| 1414 | + // $this->mpdf->_out('/Opt [ '.$this->mpdf->_textstring($form['OPT']).' '.$this->mpdf->_textstring($form['OPT']).' ]'); | |
| 1415 | + } | |
| 1416 | + | |
| 1417 | + if ($form['subtype'] == 'reset') { | |
| 1418 | + $temp .= $form['CA'] ? '/CA ' . $this->mpdf->_textstring($form['CA']) . ' ' : '/CA ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1419 | + $temp .= $form['RC'] ? '/RC ' . $this->mpdf->_textstring($form['RC']) . ' ' : '/RC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1420 | + $temp .= $form['AC'] ? '/AC ' . $this->mpdf->_textstring($form['AC']) . ' ' : '/AC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1421 | + $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1422 | + $this->mpdf->_out('/MK << ' . $temp . ' >>'); | |
| 1423 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$form['style']['font']]['i'] . ' ' . $form['style']['fontsize'] . ' Tf ' . $form['style']['fontcolor'] . ')'); | |
| 1424 | + $this->mpdf->_out('/AA << /D << /S /ResetForm /Flags 1 >> >>'); | |
| 1425 | + $form['FF'][] = 17; | |
| 1426 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF'])); | |
| 1427 | + } | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + if ($form['subtype'] == 'submit') { | |
| 1431 | + $temp .= $form['CA'] ? '/CA ' . $this->mpdf->_textstring($form['CA']) . ' ' : '/CA ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1432 | + $temp .= $form['RC'] ? '/RC ' . $this->mpdf->_textstring($form['RC']) . ' ' : '/RC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1433 | + $temp .= $form['AC'] ? '/AC ' . $this->mpdf->_textstring($form['AC']) . ' ' : '/AC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1434 | + $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1435 | + $this->mpdf->_out("/MK << $temp >>"); | |
| 1436 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$form['style']['font']]['i'] . ' ' . $form['style']['fontsize'] . ' Tf ' . $form['style']['fontcolor'] . ')'); | |
| 1437 | + // Bit 4 (8) = useGETmethod else use POST | |
| 1438 | + // Bit 3 (4) = HTML export format (charset chosen by Adobe)--- OR --- | |
| 1439 | + // Bit 6 (32) = XFDF export format (form of XML in UTF-8) | |
| 1440 | + if ($form['exporttype'] == 'xfdf') { | |
| 1441 | + $flag = 32; | |
| 1442 | + } // 'xfdf' or 'html' | |
| 1443 | + else { | |
| 1444 | + if ($form['method'] == 'GET') { | |
| 1445 | + $flag = 12; | |
| 1446 | + } else { | |
| 1447 | + $flag = 4; | |
| 1448 | + } | |
| 1449 | + } | |
| 1450 | + // Bit 2 (2) = IncludeNoValueFields | |
| 1451 | + if ($this->formSubmitNoValueFields) | |
| 1452 | + $flag += 2; | |
| 1453 | + // To submit a value, needs to be in /AP dictionary, AND this object must contain a /Fields entry | |
| 1454 | + // listing all fields to output | |
| 1455 | + $this->mpdf->_out('/AA << /D << /S /SubmitForm /F (' . $form['URL'] . ') /Flags ' . $flag . ' >> >>'); | |
| 1456 | + $form['FF'][] = 17; | |
| 1457 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF'])); | |
| 1458 | + } | |
| 1459 | + | |
| 1460 | + if ($form['subtype'] == 'js_button') { | |
| 1461 | + // Icon / image | |
| 1462 | + if (isset($this->form_button_icon[$form['T']])) { | |
| 1463 | + $cc++; | |
| 1464 | + $temp .= '/TP ' . $this->form_button_icon[$form['T']]['pos'] . ' '; | |
| 1465 | + $temp .= '/I ' . ($cc + $this->mpdf->n) . ' 0 R '; // Normal icon | |
| 1466 | + $temp .= '/RI ' . ($cc + $this->mpdf->n) . ' 0 R '; // onMouseOver | |
| 1467 | + $temp .= '/IX ' . ($cc + $this->mpdf->n) . ' 0 R '; // onClick / onMouseDown | |
| 1468 | + $temp .= '/IF << /SW /A /S /A /A [0.0 0.0] >> '; // Icon fit dictionary | |
| 1469 | + if ($this->form_button_icon[$form['T']]['Indexed']) { | |
| 1470 | + $cc++; | |
| 1471 | + } | |
| 1472 | + $put_icon = 1; | |
| 1473 | + } | |
| 1474 | + $temp .= $form['CA'] ? '/CA ' . $this->mpdf->_textstring($form['CA']) . ' ' : '/CA ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1475 | + $temp .= $form['RC'] ? '/RC ' . $this->mpdf->_textstring($form['RC']) . ' ' : '/RC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1476 | + $temp .= $form['AC'] ? '/AC ' . $this->mpdf->_textstring($form['AC']) . ' ' : '/AC ' . $this->mpdf->_textstring($form['T']) . ' '; | |
| 1477 | + $this->mpdf->_out("/BS << $bstemp >>"); | |
| 1478 | + $this->mpdf->_out("/MK << $temp >>"); | |
| 1479 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$form['style']['font']]['i'] . ' ' . $form['style']['fontsize'] . ' Tf ' . $form['style']['fontcolor'] . ')'); | |
| 1480 | + $form['FF'][] = 17; | |
| 1481 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF'])); | |
| 1482 | + // Javascript | |
| 1483 | + if (isset($this->array_form_button_js[$form['T']])) { | |
| 1484 | + $cc++; | |
| 1485 | + $this->mpdf->_out("/AA << /D " . ($cc + $this->mpdf->n) . " 0 R >>"); | |
| 1486 | + $put_js = 1; | |
| 1487 | + } | |
| 1488 | + } | |
| 1489 | + | |
| 1490 | + $this->mpdf->_out('>>'); | |
| 1491 | + $this->mpdf->_out('endobj'); | |
| 1492 | + | |
| 1493 | + // additional objects | |
| 1494 | + // obj icon | |
| 1495 | + if ($put_icon == 1) { | |
| 1496 | + $this->_put_button_icon($this->form_button_icon[$form['T']], $form['w'], $form['h']); | |
| 1497 | + $put_icon = NULL; | |
| 1498 | + } | |
| 1499 | + // obj + 1 | |
| 1500 | + if ($put_js == 1) { | |
| 1501 | + $this->mpdf->_set_object_javascript($this->array_form_button_js[$form['T']]['js']); | |
| 1502 | + unset($this->array_form_button_js[$form['T']]); | |
| 1503 | + $put_js = NULL; | |
| 1504 | + } | |
| 1505 | + | |
| 1506 | + // RADIO and CHECK BOX appearance streams | |
| 1507 | + $filter = ($this->mpdf->compress) ? '/Filter /FlateDecode ' : ''; | |
| 1508 | + if ($form['subtype'] == 'radio') { | |
| 1509 | + // output 2 appearance streams for radio buttons on/off | |
| 1510 | + if ($this->formUseZapD) { | |
| 1511 | + $fs = sprintf('%.3F', $form['style']['fontsize'] * 1.25); | |
| 1512 | + $fi = 'czapfdingbats'; | |
| 1513 | + $r_on = 'q ' . $radio_color . ' rg BT /F' . $this->mpdf->fonts[$fi]['i'] . ' ' . $fs . ' Tf 0 0 Td (4) Tj ET Q'; | |
| 1514 | + $r_off = 'q ' . $radio_color . ' rg BT /F' . $this->mpdf->fonts[$fi]['i'] . ' ' . $fs . ' Tf 0 0 Td (8) Tj ET Q'; | |
| 1515 | + } else { | |
| 1516 | + $matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize'] * 1.33 / 10, $form['style']['fontsize'] * 1.25 / 10, $form['style']['fontsize']); | |
| 1517 | + $fill = $radio_background_color . ' rg 3.778 -7.410 m 2.800 -7.410 1.947 -7.047 1.225 -6.322 c 0.500 -5.600 0.138 -4.747 0.138 -3.769 c 0.138 -2.788 0.500 -1.938 1.225 -1.213 c 1.947 -0.491 2.800 -0.128 3.778 -0.128 c 4.757 -0.128 5.610 -0.491 6.334 -1.213 c 7.056 -1.938 7.419 -2.788 7.419 -3.769 c 7.419 -4.747 7.056 -5.600 6.334 -6.322 c 5.610 -7.047 4.757 -7.410 3.778 -7.410 c h f '; | |
| 1518 | + $circle = '3.778 -6.963 m 4.631 -6.963 5.375 -6.641 6.013 -6.004 c 6.653 -5.366 6.972 -4.619 6.972 -3.769 c 6.972 -2.916 6.653 -2.172 6.013 -1.532 c 5.375 -0.894 4.631 -0.576 3.778 -0.576 c 2.928 -0.576 2.182 -0.894 1.544 -1.532 c 0.904 -2.172 0.585 -2.916 0.585 -3.769 c 0.585 -4.619 0.904 -5.366 1.544 -6.004 c 2.182 -6.641 2.928 -6.963 3.778 -6.963 c h 3.778 -7.410 m 2.800 -7.410 1.947 -7.047 1.225 -6.322 c 0.500 -5.600 0.138 -4.747 0.138 -3.769 c 0.138 -2.788 0.500 -1.938 1.225 -1.213 c 1.947 -0.491 2.800 -0.128 3.778 -0.128 c 4.757 -0.128 5.610 -0.491 6.334 -1.213 c 7.056 -1.938 7.419 -2.788 7.419 -3.769 c 7.419 -4.747 7.056 -5.600 6.334 -6.322 c 5.610 -7.047 4.757 -7.410 3.778 -7.410 c h f '; | |
| 1519 | + $r_on = 'q ' . $matrix . ' cm ' . $fill . $radio_color . ' rg ' . $circle . ' ' . $radio_color . ' rg | |
| 1520 | +5.184 -5.110 m 4.800 -5.494 4.354 -5.685 3.841 -5.685 c 3.331 -5.685 2.885 -5.494 2.501 -5.110 c 2.119 -4.725 1.925 -4.279 1.925 -3.769 c 1.925 -3.257 2.119 -2.810 2.501 -2.429 c 2.885 -2.044 3.331 -1.853 3.841 -1.853 c 4.354 -1.853 4.800 -2.044 5.184 -2.429 c 5.566 -2.810 5.760 -3.257 5.760 -3.769 c 5.760 -4.279 5.566 -4.725 5.184 -5.110 c h | |
| 1521 | +f Q '; | |
| 1522 | + $r_off = 'q ' . $matrix . ' cm ' . $fill . $radio_color . ' rg ' . $circle . ' Q '; | |
| 1523 | + } | |
| 1524 | + | |
| 1525 | + $this->mpdf->_newobj(); | |
| 1526 | + $p = ($this->mpdf->compress) ? gzcompress($r_on) : $r_on; | |
| 1527 | + $this->mpdf->_out('<<' . $filter . '/Length ' . strlen($p) . ' /Resources 2 0 R>>'); | |
| 1528 | + $this->mpdf->_putstream($p); | |
| 1529 | + $this->mpdf->_out('endobj'); | |
| 1530 | + | |
| 1531 | + $this->mpdf->_newobj(); | |
| 1532 | + $p = ($this->mpdf->compress) ? gzcompress($r_off) : $r_off; | |
| 1533 | + $this->mpdf->_out('<<' . $filter . '/Length ' . strlen($p) . ' /Resources 2 0 R>>'); | |
| 1534 | + $this->mpdf->_putstream($p); | |
| 1535 | + $this->mpdf->_out('endobj'); | |
| 1536 | + } | |
| 1537 | + if ($form['subtype'] == 'checkbox') { | |
| 1538 | + // First output appearance stream for check box on | |
| 1539 | + if ($this->formUseZapD) { | |
| 1540 | + $fs = sprintf('%.3F', $form['style']['fontsize'] * 1.25); | |
| 1541 | + $fi = 'czapfdingbats'; | |
| 1542 | + $cb_on = 'q ' . $radio_color . ' rg BT /F' . $this->mpdf->fonts[$fi]['i'] . ' ' . $fs . ' Tf 0 0 Td (4) Tj ET Q'; | |
| 1543 | + $cb_off = 'q ' . $radio_color . ' rg BT /F' . $this->mpdf->fonts[$fi]['i'] . ' ' . $fs . ' Tf 0 0 Td (8) Tj ET Q'; | |
| 1544 | + } else { | |
| 1545 | + $matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize'] * 1.33 / 10, $form['style']['fontsize'] * 1.25 / 10, $form['style']['fontsize']); | |
| 1546 | + $fill = $radio_background_color . ' rg 7.395 -0.070 m 7.395 -7.344 l 0.121 -7.344 l 0.121 -0.070 l 7.395 -0.070 l h f '; | |
| 1547 | + $square = '0.508 -6.880 m 6.969 -6.880 l 6.969 -0.534 l 0.508 -0.534 l 0.508 -6.880 l h 7.395 -0.070 m 7.395 -7.344 l 0.121 -7.344 l 0.121 -0.070 l 7.395 -0.070 l h '; | |
| 1548 | + $cb_on = 'q ' . $matrix . ' cm ' . $fill . $radio_color . ' rg ' . $square . ' f ' . $radio_color . ' rg | |
| 1549 | +6.321 -1.352 m 5.669 -2.075 5.070 -2.801 4.525 -3.532 c 3.979 -4.262 3.508 -4.967 3.112 -5.649 c 3.080 -5.706 3.039 -5.779 2.993 -5.868 c 2.858 -6.118 2.638 -6.243 2.334 -6.243 c 2.194 -6.243 2.100 -6.231 2.052 -6.205 c 2.003 -6.180 1.954 -6.118 1.904 -6.020 c 1.787 -5.788 1.688 -5.523 1.604 -5.226 c 1.521 -4.930 1.480 -4.721 1.480 -4.600 c 1.480 -4.535 1.491 -4.484 1.512 -4.447 c 1.535 -4.410 1.579 -4.367 1.647 -4.319 c 1.733 -4.259 1.828 -4.210 1.935 -4.172 c 2.040 -4.134 2.131 -4.115 2.205 -4.115 c 2.267 -4.115 2.341 -4.232 2.429 -4.469 c 2.437 -4.494 2.444 -4.511 2.448 -4.522 c 2.451 -4.531 2.456 -4.546 2.465 -4.568 c 2.546 -4.795 2.614 -4.910 2.668 -4.910 c 2.714 -4.910 2.898 -4.652 3.219 -4.136 c 3.539 -3.620 3.866 -3.136 4.197 -2.683 c 4.426 -2.367 4.633 -2.103 4.816 -1.889 c 4.998 -1.676 5.131 -1.544 5.211 -1.493 c 5.329 -1.426 5.483 -1.368 5.670 -1.319 c 5.856 -1.271 6.066 -1.238 6.296 -1.217 c 6.321 -1.352 l h f Q '; | |
| 1550 | + $cb_off = 'q ' . $matrix . ' cm ' . $fill . $radio_color . ' rg ' . $square . ' f Q '; | |
| 1551 | + } | |
| 1552 | + $this->mpdf->_newobj(); | |
| 1553 | + $p = ($this->mpdf->compress) ? gzcompress($cb_on) : $cb_on; | |
| 1554 | + $this->mpdf->_out('<<' . $filter . '/Length ' . strlen($p) . ' /Resources 2 0 R>>'); | |
| 1555 | + $this->mpdf->_putstream($p); | |
| 1556 | + $this->mpdf->_out('endobj'); | |
| 1557 | + | |
| 1558 | + // output appearance stream for check box off (only if not using ZapfDingbats) | |
| 1559 | + if (!$this->formUseZapD) { | |
| 1560 | + $this->mpdf->_newobj(); | |
| 1561 | + $p = ($this->mpdf->compress) ? gzcompress($cb_off) : $cb_off; | |
| 1562 | + $this->mpdf->_out('<<' . $filter . '/Length ' . strlen($p) . ' /Resources 2 0 R>>'); | |
| 1563 | + $this->mpdf->_putstream($p); | |
| 1564 | + $this->mpdf->_out('endobj'); | |
| 1565 | + } | |
| 1566 | + } | |
| 1567 | + return $n; | |
| 1568 | + } | |
| 1569 | + | |
| 1570 | + function _putform_ch($form, $hPt) | |
| 1571 | + { | |
| 1572 | + $put_js = 0; | |
| 1573 | + $this->mpdf->_newobj(); | |
| 1574 | + $n = $this->mpdf->n; | |
| 1575 | + $this->pdf_acro_array .= $n . ' 0 R '; | |
| 1576 | + $this->forms[$form['n']]['obj'] = $n; | |
| 1577 | + | |
| 1578 | + $this->mpdf->_out('<<'); | |
| 1579 | + $this->mpdf->_out('/Type /Annot '); | |
| 1580 | + $this->mpdf->_out('/Subtype /Widget'); | |
| 1581 | + $this->mpdf->_out('/Rect [ ' . $this->_form_rect($form['x'], $form['y'], $form['w'], $form['h'], $hPt) . ' ]'); | |
| 1582 | + $this->mpdf->_out('/F 4'); | |
| 1583 | + $this->mpdf->_out('/FT /Ch'); | |
| 1584 | + if ($form['Q']) | |
| 1585 | + $this->mpdf->_out('/Q ' . $form['Q'] . ''); | |
| 1586 | + $temp = ''; | |
| 1587 | + $temp .= '/W ' . $form['BS_W'] . ' '; | |
| 1588 | + $temp .= '/S /' . $form['BS_S'] . ' '; | |
| 1589 | + $this->mpdf->_out("/BS << $temp >>"); | |
| 1590 | + | |
| 1591 | + $temp = ''; | |
| 1592 | + $temp .= '/BC [ ' . $form['BC_C'] . " ] "; | |
| 1593 | + $temp .= '/BG [ ' . $form['BG_C'] . " ] "; | |
| 1594 | + $this->mpdf->_out('/MK << ' . $temp . ' >>'); | |
| 1595 | + | |
| 1596 | + $this->mpdf->_out('/NM ' . $this->mpdf->_textstring(sprintf('%04u-%04u', $n, (6000 + $form['n'])))); | |
| 1597 | + $this->mpdf->_out('/M ' . $this->mpdf->_textstring('D:' . date('YmdHis'))); | |
| 1598 | + | |
| 1599 | + $this->mpdf->_out('/T ' . $this->mpdf->_textstring($form['T'])); | |
| 1600 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$form['style']['font']]['i'] . ' ' . $form['style']['fontsize'] . ' Tf ' . $form['style']['fontcolor'] . ')'); | |
| 1601 | + | |
| 1602 | + $opt = ''; | |
| 1603 | + for ($i = 0; $i < count($form['OPT']['VAL']); $i++) { | |
| 1604 | + $opt .= '[ ' . $this->mpdf->_textstring($form['OPT']['VAL'][$i]) . ' ' . $this->mpdf->_textstring($form['OPT']['OPT'][$i]) . ' ] '; | |
| 1605 | + } | |
| 1606 | + $this->mpdf->_out('/Opt [ ' . $opt . ']'); | |
| 1607 | + | |
| 1608 | + // selected | |
| 1609 | + $selectItem = false; | |
| 1610 | + $selectIndex = false; | |
| 1611 | + foreach ($form['OPT']['SEL'] as $selectKey => $selectVal) { | |
| 1612 | + $selectName = $this->mpdf->_textstring($form['OPT']['VAL'][$selectVal]); | |
| 1613 | + $selectItem .= ' ' . $selectName . ' '; | |
| 1614 | + $selectIndex .= ' ' . $selectVal . ' '; | |
| 1615 | + } | |
| 1616 | + if ($selectItem) { | |
| 1617 | + if (count($form['OPT']['SEL']) < 2) { | |
| 1618 | + $this->mpdf->_out('/V ' . $selectItem . ' '); | |
| 1619 | + $this->mpdf->_out('/DV ' . $selectItem . ' '); | |
| 1620 | + } else { | |
| 1621 | + $this->mpdf->_out('/V [' . $selectItem . '] '); | |
| 1622 | + $this->mpdf->_out('/DV [' . $selectItem . '] '); | |
| 1623 | + } | |
| 1624 | + $this->mpdf->_out('/I [' . $selectIndex . '] '); | |
| 1625 | + } | |
| 1626 | + | |
| 1627 | + if (is_array($form['FF']) && count($form['FF']) > 0) { | |
| 1628 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF']) . ' '); | |
| 1629 | + } | |
| 1630 | + // Javascript | |
| 1631 | + if (isset($this->array_form_choice_js[$form['T']])) { | |
| 1632 | + $this->mpdf->_out("/AA << /V " . ($this->mpdf->n + 1) . " 0 R >>"); | |
| 1633 | + $put_js = 1; | |
| 1634 | + } | |
| 1635 | + | |
| 1636 | + $this->mpdf->_out('>>'); | |
| 1637 | + $this->mpdf->_out('endobj'); | |
| 1638 | + // obj + 1 | |
| 1639 | + if ($put_js == 1) { | |
| 1640 | + $this->mpdf->_set_object_javascript($this->array_form_choice_js[$form['T']]['js']); | |
| 1641 | + unset($this->array_form_choice_js[$form['T']]); | |
| 1642 | + $put_js = NULL; | |
| 1643 | + } | |
| 1644 | + | |
| 1645 | + return $n; | |
| 1646 | + } | |
| 1647 | + | |
| 1648 | + function _putform_tx($form, $hPt) | |
| 1649 | + { | |
| 1650 | + $put_js = 0; | |
| 1651 | + $this->mpdf->_newobj(); | |
| 1652 | + $n = $this->mpdf->n; | |
| 1653 | + $this->pdf_acro_array .= $n . ' 0 R '; | |
| 1654 | + $this->forms[$form['n']]['obj'] = $n; | |
| 1655 | + | |
| 1656 | + $this->mpdf->_out('<<'); | |
| 1657 | + $this->mpdf->_out('/Type /Annot '); | |
| 1658 | + $this->mpdf->_out('/Subtype /Widget '); | |
| 1659 | + | |
| 1660 | + $this->mpdf->_out('/Rect [ ' . $this->_form_rect($form['x'], $form['y'], $form['w'], $form['h'], $hPt) . ' ] '); | |
| 1661 | + $form['hidden'] ? $this->mpdf->_out('/F 2 ') : $this->mpdf->_out('/F 4 '); | |
| 1662 | + $this->mpdf->_out('/FT /Tx '); | |
| 1663 | + | |
| 1664 | + $this->mpdf->_out('/H /N '); | |
| 1665 | + $this->mpdf->_out('/R 0 '); | |
| 1666 | + | |
| 1667 | + if (is_array($form['FF']) && count($form['FF']) > 0) { | |
| 1668 | + $this->mpdf->_out('/Ff ' . $this->_setflag($form['FF']) . ' '); | |
| 1669 | + } | |
| 1670 | + if (isset($form['maxlen']) && $form['maxlen'] > 0) { | |
| 1671 | + $this->mpdf->_out('/MaxLen ' . $form['maxlen']); | |
| 1672 | + } | |
| 1673 | + | |
| 1674 | + $temp = ''; | |
| 1675 | + $temp .= '/W ' . $form['BS_W'] . ' '; | |
| 1676 | + $temp .= '/S /' . $form['BS_S'] . ' '; | |
| 1677 | + $this->mpdf->_out("/BS << $temp >>"); | |
| 1678 | + | |
| 1679 | + $temp = ''; | |
| 1680 | + $temp .= '/BC [ ' . $form['BC_C'] . " ] "; | |
| 1681 | + $temp .= '/BG [ ' . $form['BG_C'] . " ] "; | |
| 1682 | + $this->mpdf->_out('/MK <<' . $temp . ' >>'); | |
| 1683 | + | |
| 1684 | + $this->mpdf->_out('/T ' . $this->mpdf->_textstring($form['T'])); | |
| 1685 | + $this->mpdf->_out('/TU ' . $this->mpdf->_textstring($form['TU'])); | |
| 1686 | + if ($form['V'] || $form['V'] === '0') | |
| 1687 | + $this->mpdf->_out('/V ' . $this->mpdf->_textstring($form['V'])); | |
| 1688 | + $this->mpdf->_out('/DV ' . $this->mpdf->_textstring($form['DV'])); | |
| 1689 | + $this->mpdf->_out('/DA (/F' . $this->mpdf->fonts[$form['style']['font']]['i'] . ' ' . $form['style']['fontsize'] . ' Tf ' . $form['style']['fontcolor'] . ')'); | |
| 1690 | + if ($form['Q']) | |
| 1691 | + $this->mpdf->_out('/Q ' . $form['Q'] . ''); | |
| 1692 | + | |
| 1693 | + $this->mpdf->_out('/NM ' . $this->mpdf->_textstring(sprintf('%04u-%04u', $n, (5000 + $form['n'])))); | |
| 1694 | + $this->mpdf->_out('/M ' . $this->mpdf->_textstring('D:' . date('YmdHis'))); | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + if (isset($this->array_form_text_js[$form['T']])) { | |
| 1698 | + $put_js = 1; | |
| 1699 | + $cc = 0; | |
| 1700 | + $js_str = ''; | |
| 1701 | + | |
| 1702 | + if (isset($this->array_form_text_js[$form['T']]['F'])) { | |
| 1703 | + $cc++; | |
| 1704 | + $js_str .= '/F ' . ($cc + $this->mpdf->n) . ' 0 R '; | |
| 1705 | + } | |
| 1706 | + if (isset($this->array_form_text_js[$form['T']]['K'])) { | |
| 1707 | + $cc++; | |
| 1708 | + $js_str .= '/K ' . ($cc + $this->mpdf->n) . ' 0 R '; | |
| 1709 | + } | |
| 1710 | + if (isset($this->array_form_text_js[$form['T']]['V'])) { | |
| 1711 | + $cc++; | |
| 1712 | + $js_str .= '/V ' . ($cc + $this->mpdf->n) . ' 0 R '; | |
| 1713 | + } | |
| 1714 | + if (isset($this->array_form_text_js[$form['T']]['C'])) { | |
| 1715 | + $cc++; | |
| 1716 | + $js_str .= '/C ' . ($cc + $this->mpdf->n) . ' 0 R '; | |
| 1717 | + $this->pdf_array_co .= $this->mpdf->n . ' 0 R '; | |
| 1718 | + } | |
| 1719 | + $this->mpdf->_out('/AA << ' . $js_str . ' >>'); | |
| 1720 | + } | |
| 1721 | + | |
| 1722 | + $this->mpdf->_out('>>'); | |
| 1723 | + $this->mpdf->_out('endobj'); | |
| 1724 | + | |
| 1725 | + if ($put_js == 1) { | |
| 1726 | + if (isset($this->array_form_text_js[$form['T']]['F'])) { | |
| 1727 | + $this->mpdf->_set_object_javascript($this->array_form_text_js[$form['T']]['F']['js']); | |
| 1728 | + unset($this->array_form_text_js[$form['T']]['F']); | |
| 1729 | + } | |
| 1730 | + if (isset($this->array_form_text_js[$form['T']]['K'])) { | |
| 1731 | + $this->mpdf->_set_object_javascript($this->array_form_text_js[$form['T']]['K']['js']); | |
| 1732 | + unset($this->array_form_text_js[$form['T']]['K']); | |
| 1733 | + } | |
| 1734 | + if (isset($this->array_form_text_js[$form['T']]['V'])) { | |
| 1735 | + $this->mpdf->_set_object_javascript($this->array_form_text_js[$form['T']]['V']['js']); | |
| 1736 | + unset($this->array_form_text_js[$form['T']]['V']); | |
| 1737 | + } | |
| 1738 | + if (isset($this->array_form_text_js[$form['T']]['C'])) { | |
| 1739 | + $this->mpdf->_set_object_javascript($this->array_form_text_js[$form['T']]['C']['js']); | |
| 1740 | + unset($this->array_form_text_js[$form['T']]['C']); | |
| 1741 | + } | |
| 1742 | + } | |
| 1743 | + return $n; | |
| 1744 | + } | |
| 1745 | + | |
| 1746 | +} | |