103 |
- |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class form {
|
|
|
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 form(&$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 ($objattr['disabled'] || $objattr['readonly']) { $flags[] = 1; } // readonly
|
|
|
116 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
117 |
if ($objattr['disabled']) { $objattr['color'] = array(3,128,128,128); } // gray out disabled
|
|
|
118 |
if ($objattr['required']) { $flags[] = 2; } // required
|
|
|
119 |
if (!$objattr['spellcheck']) { $flags[] = 23; } // DoNotSpellCheck
|
|
|
120 |
if ($objattr['subtype']=='PASSWORD') { $flags[] = 14; }
|
|
|
121 |
$this->mpdf->SetTColor($objattr['color']);
|
|
|
122 |
$fieldalign = $rtlalign;
|
|
|
123 |
if ($objattr['text_align']) { $fieldalign = $objattr['text_align']; }
|
|
|
124 |
if ($objattr['subtype']=='PASSWORD') { $val = $objattr['value']; }
|
|
|
125 |
else { $val = $objattr['text']; }
|
|
|
126 |
// mPDF 5.3.25
|
|
|
127 |
$js = array();
|
|
|
128 |
if ($objattr['onCalculate']) { $js[] = array('C', $objattr['onCalculate']); }
|
|
|
129 |
if ($objattr['onValidate']) { $js[] = array('V', $objattr['onValidate']); }
|
|
|
130 |
if ($objattr['onFormat']) { $js[] = array('F', $objattr['onFormat']); }
|
|
|
131 |
if ($objattr['onKeystroke']) { $js[] = array('K', $objattr['onKeystroke']); }
|
|
|
132 |
$this->SetFormText( $w, $h, $objattr['fieldname'], $val, $val, $objattr['title'], $flags, $fieldalign, false, $objattr['maxlength'], $js, $objattr['background-col'], $objattr['border-col'] );
|
|
|
133 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
134 |
}
|
|
|
135 |
else {
|
|
|
136 |
$w -= $this->form_element_spacing['input']['outer']['h']*2 /$k;
|
|
|
137 |
$h -= $this->form_element_spacing['input']['outer']['v']*2 /$k;
|
|
|
138 |
$this->mpdf->x += $this->form_element_spacing['input']['outer']['h'] /$k;
|
|
|
139 |
$this->mpdf->y += $this->form_element_spacing['input']['outer']['v'] /$k;
|
|
|
140 |
// Chop texto to max length $w-inner-padding
|
|
|
141 |
while ($this->mpdf->GetStringWidth($texto) > $w-($this->form_element_spacing['input']['inner']['h']*2)) {
|
|
|
142 |
$texto = mb_substr($texto,0,mb_strlen($texto,$this->mpdf->mb_enc)-1,$this->mpdf->mb_enc);
|
|
|
143 |
}
|
|
|
144 |
$save_linemaxfontsize = $this->mpdf->linemaxfontsize;
|
|
|
145 |
$this->mpdf->linemaxfontsize = $this->mpdf->FontSize;
|
|
|
146 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
147 |
$this->mpdf->magic_reverse_dir($texto, false, $blockdir); // *RTL*
|
|
|
148 |
if (isset($objattr['disabled']) && $objattr['disabled']) {
|
|
|
149 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
150 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(127));
|
|
|
151 |
}
|
|
|
152 |
else if (isset($objattr['readonly']) && $objattr['readonly']) {
|
|
|
153 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
154 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
155 |
}
|
|
|
156 |
else {
|
|
|
157 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(250));
|
|
|
158 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
159 |
}
|
|
|
160 |
$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');
|
|
|
161 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(255));
|
|
|
162 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
163 |
$this->mpdf->linemaxfontsize = $save_linemaxfontsize;
|
|
|
164 |
}
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
function print_ob_textarea($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
|
|
|
168 |
// TEXTAREA
|
|
|
169 |
if ($this->mpdf->useActiveForms) {
|
|
|
170 |
// Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password
|
|
|
171 |
$flags = array();
|
|
|
172 |
$flags = array(13); // textarea
|
|
|
173 |
if ($objattr['disabled'] || $objattr['readonly']) { $flags[] = 1; } // readonly
|
|
|
174 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
175 |
if ($objattr['disabled']) { $objattr['color'] = array(3,128,128,128); } // gray out disabled
|
|
|
176 |
if ($objattr['required']) { $flags[] = 2; } // required
|
|
|
177 |
if (!$objattr['spellcheck']) { $flags[] = 23; } // DoNotSpellCheck
|
|
|
178 |
if ($objattr['donotscroll']) { $flags[] = 24; } // DoNotScroll
|
|
|
179 |
$this->mpdf->SetTColor($objattr['color']);
|
|
|
180 |
$fieldalign = $rtlalign;
|
|
|
181 |
if ($texto == ' ') { $texto = ''; } // mPDF 5.3.24
|
|
|
182 |
if ($objattr['text_align']) { $fieldalign = $objattr['text_align']; }
|
|
|
183 |
// mPDF 5.3.25
|
|
|
184 |
$js = array();
|
|
|
185 |
if ($objattr['onCalculate']) { $js[] = array('C', $objattr['onCalculate']); }
|
|
|
186 |
if ($objattr['onValidate']) { $js[] = array('V', $objattr['onValidate']); }
|
|
|
187 |
if ($objattr['onFormat']) { $js[] = array('F', $objattr['onFormat']); }
|
|
|
188 |
if ($objattr['onKeystroke']) { $js[] = array('K', $objattr['onKeystroke']); }
|
|
|
189 |
$this->SetFormText( $w, $h, $objattr['fieldname'], $texto, $texto, $objattr['title'], $flags, $fieldalign , false, -1, $js, $objattr['background-col'], $objattr['border-col'] );
|
|
|
190 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
191 |
}
|
|
|
192 |
else {
|
|
|
193 |
$w -= $this->form_element_spacing['textarea']['outer']['h']*2 /$k ;
|
|
|
194 |
$h -= $this->form_element_spacing['textarea']['outer']['v']*2 /$k ;
|
|
|
195 |
$this->mpdf->x += $this->form_element_spacing['textarea']['outer']['h'] /$k ;
|
|
|
196 |
$this->mpdf->y += $this->form_element_spacing['textarea']['outer']['v'] /$k ;
|
|
|
197 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
198 |
if (isset($objattr['disabled']) && $objattr['disabled']) {
|
|
|
199 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
200 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(127));
|
|
|
201 |
}
|
|
|
202 |
else if (isset($objattr['readonly']) && $objattr['readonly']) {
|
|
|
203 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
204 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
205 |
}
|
|
|
206 |
else {
|
|
|
207 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(250));
|
|
|
208 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
209 |
}
|
|
|
210 |
$this->mpdf->Rect($this->mpdf->x,$this->mpdf->y,$w,$h,'DF');
|
|
|
211 |
$w -= $this->form_element_spacing['textarea']['inner']['h']*2 /$k ;
|
|
|
212 |
$this->mpdf->x += $this->form_element_spacing['textarea']['inner']['h'] /$k ;
|
|
|
213 |
$this->mpdf->y += $this->form_element_spacing['textarea']['inner']['v'] /$k ;
|
|
|
214 |
$linesneeded = $this->mpdf->WordWrap($texto,$w);
|
|
|
215 |
if ($linesneeded > $objattr['rows']) { //Too many words inside textarea
|
|
|
216 |
$textoaux = explode("\n",$texto);
|
|
|
217 |
$texto = '';
|
|
|
218 |
for($i=0;$i<$objattr['rows'];$i++) {
|
|
|
219 |
if ($i == ($objattr['rows']-1)) $texto .= $textoaux[$i];
|
|
|
220 |
else $texto .= $textoaux[$i] . "\n";
|
|
|
221 |
}
|
|
|
222 |
$texto = mb_substr($texto,0,mb_strlen($texto,$this->mpdf->mb_enc)-4,$this->mpdf->mb_enc) . "...";
|
|
|
223 |
}
|
|
|
224 |
if ($texto != '') $this->mpdf->MultiCell($w,$this->mpdf->FontSize*$this->textarea_lineheight,$texto,0,'',0,'',$blockdir,true);
|
|
|
225 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(255));
|
|
|
226 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
227 |
}
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
function print_ob_select($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
|
|
|
231 |
// SELECT
|
|
|
232 |
if ($this->mpdf->useActiveForms) {
|
|
|
233 |
// Flags: 1 - Readonly; 2 - Required; 3 - No export; 19 - edit (only if combo)
|
|
|
234 |
$flags = array();
|
|
|
235 |
if ($objattr['disabled']) { $flags[] = 1; } // readonly
|
|
|
236 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
237 |
if ($objattr['disabled']) { $objattr['color'] = array(3,128,128,128); } // gray out disabled
|
|
|
238 |
if ($objattr['required']) { $flags[] = 2; } // required
|
|
|
239 |
if ($objattr['multiple'] && $objattr['size']>1) { $flags[] = 22; } //flag 22 = multiselect (listbox)
|
|
|
240 |
if ($objattr['size']<2) {
|
|
|
241 |
$flags[] = 18; //flag 18 = combobox (else a listbox)
|
|
|
242 |
if ($objattr['editable']) { $flags[] = 19; } // editable
|
|
|
243 |
}
|
|
|
244 |
// only spellcheck if combo and editable
|
|
|
245 |
if (!$objattr['spellcheck'] || $objattr['size']>1 || !$objattr['editable']) { $flags[] = 23; } // DoNotSpellCheck
|
|
|
246 |
if ($objattr['subtype']=='PASSWORD') { $flags[] = 14; }
|
|
|
247 |
if ($objattr['onChange']) { $js = $objattr['onChange']; }
|
|
|
248 |
else { $js = ''; } // mPDF 5.3.37
|
|
|
249 |
$data = array('VAL' => array(), 'OPT' => array(), 'SEL' => array(), );
|
|
|
250 |
for($i=0; $i<count($objattr['items']); $i++) {
|
|
|
251 |
$item = $objattr['items'][$i];
|
|
|
252 |
$data['VAL'][] = $item['exportValue'];
|
|
|
253 |
$data['OPT'][] = $item['content'];
|
|
|
254 |
if ($item['selected']) { $data['SEL'][] = $i; }
|
|
|
255 |
}
|
|
|
256 |
if (count($data['SEL'])==0 && $this->formSelectDefaultOption) {$data['SEL'][] = 0; }
|
|
|
257 |
$this->mpdf->SetTColor($objattr['color']);
|
|
|
258 |
$this->SetFormChoice( $w, $h, $objattr['fieldname'], $flags, $data, $rtlalign, $js );
|
|
|
259 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
260 |
}
|
|
|
261 |
else {
|
|
|
262 |
$save_linemaxfontsize = $this->mpdf->linemaxfontsize;
|
|
|
263 |
$this->mpdf->linemaxfontsize = $this->mpdf->FontSize;
|
|
|
264 |
$this->mpdf->magic_reverse_dir($texto, false, $blockdir); // *RTL*
|
|
|
265 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
266 |
if (isset($objattr['disabled']) && $objattr['disabled']) {
|
|
|
267 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
268 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(127));
|
|
|
269 |
}
|
|
|
270 |
else {
|
|
|
271 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(250));
|
|
|
272 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
273 |
}
|
|
|
274 |
$w -= $this->form_element_spacing['select']['outer']['h']*2 /$k ;
|
|
|
275 |
$h -= $this->form_element_spacing['select']['outer']['v']*2 /$k ;
|
|
|
276 |
$this->mpdf->x += $this->form_element_spacing['select']['outer']['h'] /$k ;
|
|
|
277 |
$this->mpdf->y += $this->form_element_spacing['select']['outer']['v'] /$k ;
|
|
|
278 |
$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') ;
|
|
|
279 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(190));
|
|
|
280 |
$save_font = $this->mpdf->FontFamily;
|
|
|
281 |
$save_currentfont = $this->mpdf->currentfontfamily;
|
|
|
282 |
if ($this->mpdf->PDFA || $this->mpdf->PDFX) {
|
|
|
283 |
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.)"; }
|
|
|
284 |
$this->mpdf->SetFont('sans');
|
|
|
285 |
if ($this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9660)) { $down = "\xe2\x96\xbc"; }
|
|
|
286 |
else { $down = '='; }
|
|
|
287 |
$this->mpdf->Cell(($this->mpdf->FontSize*1.4),$h,$down,1,0,'C',1,'',0,0,0, 'M') ;
|
|
|
288 |
}
|
|
|
289 |
else {
|
|
|
290 |
$this->mpdf->SetFont('czapfdingbats','',0);
|
|
|
291 |
$this->mpdf->Cell(($this->mpdf->FontSize*1.4),$h,chr(116),1,0,'C',1,'',0,0,0, 'M') ;
|
|
|
292 |
}
|
|
|
293 |
$this->mpdf->SetFont($save_font,'',0);
|
|
|
294 |
$this->mpdf->currentfontfamily = $save_currentfont;
|
|
|
295 |
$this->mpdf->linemaxfontsize = $save_linemaxfontsize;
|
|
|
296 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(255));
|
|
|
297 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
298 |
}
|
|
|
299 |
}
|
|
|
300 |
|
|
|
301 |
function print_ob_imageinput($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
|
|
|
302 |
// INPUT/BUTTON as IMAGE
|
|
|
303 |
if ($this->mpdf->useActiveForms) {
|
|
|
304 |
// Flags: 1 - Readonly; 3 - No export;
|
|
|
305 |
$flags = array();
|
|
|
306 |
if ($objattr['disabled']) { $flags[] = 1; } // readonly
|
|
|
307 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
308 |
if ($objattr['onClick']) { $js = $objattr['onClick']; }
|
|
|
309 |
else { $js = ''; }
|
|
|
310 |
$this->SetJSButton( $w, $h, $objattr['fieldname'], $objattr['value'], $js, $objattr['ID'], $objattr['title'], $flags, $objattr['Indexed']);
|
|
|
311 |
}
|
|
|
312 |
else {
|
|
|
313 |
$this->mpdf->y = $objattr['INNER-Y'];
|
|
|
314 |
$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'] ) );
|
|
|
315 |
if (isset($objattr['BORDER-WIDTH']) && $objattr['BORDER-WIDTH']) { $this->mpdf->PaintImgBorder($objattr,$is_table); }
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
function print_ob_button($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
|
|
|
320 |
// BUTTON
|
|
|
321 |
if ($this->mpdf->useActiveForms) {
|
|
|
322 |
// Flags: 1 - Readonly; 3 - No export;
|
|
|
323 |
$flags = array();
|
|
|
324 |
if ($objattr['disabled']) { $flags[] = 1; } // readonly
|
|
|
325 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
326 |
if ($objattr['disabled']) { $objattr['color'] = array(3,128,128,128); }
|
|
|
327 |
$this->mpdf->SetTColor($objattr['color']);
|
|
|
328 |
if ($objattr['subtype'] == 'RESET') {
|
|
|
329 |
$this->SetFormButtonText( $objattr['value'] );
|
|
|
330 |
$this->SetFormReset( $w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $flags, $objattr['background-col'], $objattr['border-col'], $objattr['noprint'] );
|
|
|
331 |
}
|
|
|
332 |
else if ($objattr['subtype'] == 'SUBMIT') {
|
|
|
333 |
$url = $this->formAction;
|
|
|
334 |
$type = $this->formExportType;
|
|
|
335 |
$method = $this->formMethod;
|
|
|
336 |
$this->SetFormButtonText( $objattr['value'] );
|
|
|
337 |
$this->SetFormSubmit( $w, $h, $objattr['fieldname'], $objattr['value'], $url, $objattr['title'], $type, $method, $flags, $objattr['background-col'], $objattr['border-col'], $objattr['noprint'] );
|
|
|
338 |
}
|
|
|
339 |
else if ($objattr['subtype'] == 'BUTTON') {
|
|
|
340 |
$this->SetFormButtonText( $objattr['value'] );
|
|
|
341 |
if ($objattr['onClick']) { $js = $objattr['onClick']; }
|
|
|
342 |
else { $js = ''; }
|
|
|
343 |
$this->SetJSButton( $w, $h, $objattr['fieldname'], $objattr['value'], $js, 0, $objattr['title'], $flags, false, $objattr['background-col'], $objattr['border-col'], $objattr['noprint'] );
|
|
|
344 |
}
|
|
|
345 |
$this->mpdf->SetTColor($this->mpdf->ConvertColor(0));
|
|
|
346 |
}
|
|
|
347 |
else {
|
|
|
348 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
349 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(190));
|
|
|
350 |
$w -= $this->form_element_spacing['button']['outer']['h']*2 /$k ;
|
|
|
351 |
$h -= $this->form_element_spacing['button']['outer']['v']*2 /$k ;
|
|
|
352 |
$this->mpdf->x += $this->form_element_spacing['button']['outer']['h'] /$k ;
|
|
|
353 |
$this->mpdf->y += $this->form_element_spacing['button']['outer']['v'] /$k ;
|
|
|
354 |
$this->mpdf->RoundedRect($this->mpdf->x, $this->mpdf->y, $w, $h, 0.5 /$k , 'DF');
|
|
|
355 |
$w -= $this->form_element_spacing['button']['inner']['h']*2 /$k ;
|
|
|
356 |
$h -= $this->form_element_spacing['button']['inner']['v']*2 /$k ;
|
|
|
357 |
$this->mpdf->x += $this->form_element_spacing['button']['inner']['h'] /$k ;
|
|
|
358 |
$this->mpdf->y += $this->form_element_spacing['button']['inner']['v'] /$k ;
|
|
|
359 |
$save_linemaxfontsize = $this->mpdf->linemaxfontsize;
|
|
|
360 |
$this->mpdf->linemaxfontsize = $this->mpdf->FontSize;
|
|
|
361 |
$this->mpdf->magic_reverse_dir($texto, false, $blockdir); // *RTL*
|
|
|
362 |
$this->mpdf->Cell($w,$h,$texto,'',0,'C',0,'',0,0,0, 'M') ;
|
|
|
363 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(0));
|
|
|
364 |
$this->mpdf->linemaxfontsize = $save_linemaxfontsize;
|
|
|
365 |
}
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
function print_ob_checkbox($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
|
|
|
369 |
// CHECKBOX
|
|
|
370 |
if ($this->mpdf->useActiveForms) {
|
|
|
371 |
// Flags: 1 - Readonly; 2 - Required; 3 - No export;
|
|
|
372 |
$flags = array();
|
|
|
373 |
if ($objattr['disabled']) { $flags[] = 1; } // readonly
|
|
|
374 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
375 |
$checked = false;
|
|
|
376 |
if ($objattr['checked']) { $checked = true; }
|
|
|
377 |
if ($this->formUseZapD) {
|
|
|
378 |
$save_font = $this->mpdf->FontFamily;
|
|
|
379 |
$save_currentfont = $this->mpdf->currentfontfamily;
|
|
|
380 |
$this->mpdf->SetFont('czapfdingbats','',0);
|
|
|
381 |
}
|
|
|
382 |
$this->SetCheckBox( $w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $checked, $flags, $objattr['disabled'] );
|
|
|
383 |
if ($this->formUseZapD) {
|
|
|
384 |
$this->mpdf->SetFont($save_font,'',0);
|
|
|
385 |
$this->mpdf->currentfontfamily = $save_currentfont;
|
|
|
386 |
}
|
|
|
387 |
}
|
|
|
388 |
else {
|
|
|
389 |
$iw = $w * 0.7;
|
|
|
390 |
$ih = $h * 0.7;
|
|
|
391 |
$lx = $x + (($w-$iw)/2);
|
|
|
392 |
$ty = $y + (($h-$ih)/2);
|
|
|
393 |
$rx = $lx + $iw;
|
|
|
394 |
$by = $ty + $ih;
|
|
|
395 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
396 |
if (isset($objattr['disabled']) && $objattr['disabled']) {
|
|
|
397 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(225));
|
|
|
398 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(127));
|
|
|
399 |
}
|
|
|
400 |
else {
|
|
|
401 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(250));
|
|
|
402 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(0));
|
|
|
403 |
}
|
|
|
404 |
$this->mpdf->Rect($lx,$ty,$iw,$ih,'DF');
|
|
|
405 |
if (isset($objattr['checked']) && $objattr['checked']) {
|
|
|
406 |
//Round join and cap
|
|
|
407 |
$this->mpdf->SetLineCap(1);
|
|
|
408 |
$this->mpdf->Line($lx,$ty,$rx,$by);
|
|
|
409 |
$this->mpdf->Line($lx,$by,$rx,$ty);
|
|
|
410 |
//Set line cap style back to square
|
|
|
411 |
$this->mpdf->SetLineCap(2);
|
|
|
412 |
}
|
|
|
413 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(255));
|
|
|
414 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(0));
|
|
|
415 |
}
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
function print_ob_radio($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
|
|
|
419 |
// RADIO
|
|
|
420 |
if ($this->mpdf->useActiveForms) {
|
|
|
421 |
// Flags: 1 - Readonly; 2 - Required; 3 - No export;
|
|
|
422 |
$flags = array();
|
|
|
423 |
if ($objattr['disabled']) { $flags[] = 1; } // readonly
|
|
|
424 |
if ($objattr['disabled']) { $flags[] = 3; } // no export
|
|
|
425 |
$checked = false;
|
|
|
426 |
if ($objattr['checked']) { $checked = true; }
|
|
|
427 |
if ($this->formUseZapD) {
|
|
|
428 |
$save_font = $this->mpdf->FontFamily;
|
|
|
429 |
$save_currentfont = $this->mpdf->currentfontfamily;
|
|
|
430 |
$this->mpdf->SetFont('czapfdingbats','',0);
|
|
|
431 |
}
|
|
|
432 |
$this->SetRadio( $w, $h, $objattr['fieldname'], $objattr['value'], $objattr['title'], $checked, $flags, $objattr['disabled'] );
|
|
|
433 |
if ($this->formUseZapD) {
|
|
|
434 |
$this->mpdf->SetFont($save_font,'',0);
|
|
|
435 |
$this->mpdf->currentfontfamily = $save_currentfont;
|
|
|
436 |
}
|
|
|
437 |
}
|
|
|
438 |
else {
|
|
|
439 |
$this->mpdf->SetLineWidth(0.2 /$k );
|
|
|
440 |
$radius = $this->mpdf->FontSize *0.35;
|
|
|
441 |
$cx = $x + ($w/2);
|
|
|
442 |
$cy = $y + ($h/2);
|
|
|
443 |
if (isset($objattr['disabled']) && $objattr['disabled']) {
|
|
|
444 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(127));
|
|
|
445 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(127));
|
|
|
446 |
}
|
|
|
447 |
else {
|
|
|
448 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(0));
|
|
|
449 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(0));
|
|
|
450 |
}
|
|
|
451 |
$this->mpdf->Circle($cx,$cy,$radius,'D');
|
|
|
452 |
if (isset($objattr['checked']) && $objattr['checked']) {
|
|
|
453 |
$this->mpdf->Circle($cx,$cy,$radius*0.4,'DF');
|
|
|
454 |
}
|
|
|
455 |
$this->mpdf->SetFColor($this->mpdf->ConvertColor(255));
|
|
|
456 |
$this->mpdf->SetDColor($this->mpdf->ConvertColor(0));
|
|
|
457 |
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
// In _putpages
|
|
|
463 |
function countPageForms($n, &$totaladdnum) {
|
|
|
464 |
foreach( $this->forms as $form ) {
|
|
|
465 |
if ( $form['page'] == $n ) {
|
|
|
466 |
$totaladdnum++;
|
|
|
467 |
if ( $form['typ'] == 'Tx' ) {
|
|
|
468 |
if ( isset($this->array_form_text_js[$form['T']]) ) {
|
|
|
469 |
if ( isset($this->array_form_text_js[$form['T']]['F']) ) { $totaladdnum++; }
|
|
|
470 |
if ( isset($this->array_form_text_js[$form['T']]['K']) ) { $totaladdnum++; }
|
|
|
471 |
if ( isset($this->array_form_text_js[$form['T']]['V']) ) { $totaladdnum++; }
|
|
|
472 |
if ( isset($this->array_form_text_js[$form['T']]['C']) ) { $totaladdnum++; }
|
|
|
473 |
}
|
|
|
474 |
}
|
|
|
475 |
if ( $form['typ'] == 'Bt' ) {
|
|
|
476 |
if ( isset($this->array_form_button_js[$form['T']]) ) { $totaladdnum++; }
|
|
|
477 |
if ( isset($this->form_button_icon[$form['T']]) ) {
|
|
|
478 |
$totaladdnum++;
|
|
|
479 |
if ( $this->form_button_icon[$form['T']]['Indexed'] ) { $totaladdnum++; }
|
|
|
480 |
}
|
|
|
481 |
if ( $form['subtype'] == 'radio' ) { $totaladdnum+=2; }
|
|
|
482 |
else if ( $form['subtype'] == 'checkbox' && $this->formUseZapD ) { $totaladdnum++; }
|
|
|
483 |
else if ( $form['subtype'] == 'checkbox' && !$this->formUseZapD ) { $totaladdnum+=2; }
|
|
|
484 |
}
|
|
|
485 |
if ( $form['typ'] == 'Ch' ) {
|
|
|
486 |
if ( isset($this->array_form_choice_js[$form['T']]) ) { $totaladdnum++; }
|
|
|
487 |
}
|
|
|
488 |
}
|
|
|
489 |
}
|
|
|
490 |
}
|
|
|
491 |
|
|
|
492 |
// In _putpages
|
|
|
493 |
function addFormIds($n, &$s, &$annotid) {
|
|
|
494 |
foreach( $this->forms as $form ) {
|
|
|
495 |
if ( $form['page'] == $n ) {
|
|
|
496 |
$s .= ($annotid) . ' 0 R ';
|
|
|
497 |
$annotid++;
|
|
|
498 |
if ( $form['typ'] == 'Tx' ) {
|
|
|
499 |
if ( isset($this->array_form_text_js[$form['T']]) ) {
|
|
|
500 |
if ( isset($this->array_form_text_js[$form['T']]['F']) ) { $annotid++; }
|
|
|
501 |
if ( isset($this->array_form_text_js[$form['T']]['K']) ) { $annotid++; }
|
|
|
502 |
if ( isset($this->array_form_text_js[$form['T']]['V']) ) { $annotid++; }
|
|
|
503 |
if ( isset($this->array_form_text_js[$form['T']]['C']) ) { $annotid++; }
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
if ( $form['typ'] == 'Bt' ) {
|
|
|
507 |
if ( isset($this->array_form_button_js[$form['T']]) ) { $annotid++; }
|
|
|
508 |
if ( isset($this->form_button_icon[$form['T']]) ) {
|
|
|
509 |
$annotid++;
|
|
|
510 |
if ( $this->form_button_icon[$form['T']]['Indexed'] ) { $annotid++; }
|
|
|
511 |
}
|
|
|
512 |
if ( $form['subtype'] == 'radio' ) { $annotid+=2; }
|
|
|
513 |
else if ( $form['subtype'] == 'checkbox' && $this->formUseZapD ) { $annotid++; }
|
|
|
514 |
else if ( $form['subtype'] == 'checkbox' && !$this->formUseZapD ) { $annotid+=2; }
|
|
|
515 |
}
|
|
|
516 |
if ( $form['typ'] == 'Ch' ) {
|
|
|
517 |
if ( isset($this->array_form_choice_js[$form['T']]) ) { $annotid++; }
|
|
|
518 |
}
|
|
|
519 |
}
|
|
|
520 |
}
|
|
|
521 |
}
|
|
|
522 |
|
|
|
523 |
// In _putannots
|
|
|
524 |
function _putFormItems($n, $hPt) {
|
|
|
525 |
foreach( $this->forms as $val) {
|
|
|
526 |
if ( $val['page'] == $n ) {
|
|
|
527 |
if ( $val['typ'] == 'Tx' ) $this->_putform_tx( $val, $hPt );
|
|
|
528 |
if ( $val['typ'] == 'Ch' ) $this->_putform_ch( $val, $hPt );
|
|
|
529 |
if ( $val['typ'] == 'Bt' ) $this->_putform_bt( $val, $hPt );
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
}
|
|
|
533 |
|
|
|
534 |
// In _putannots
|
|
|
535 |
function _putRadioItems($n) {
|
|
|
536 |
// Output Radio Groups
|
|
|
537 |
$key = 1;
|
|
|
538 |
foreach($this->form_radio_groups AS $name=>$frg) {
|
|
|
539 |
$this->mpdf->_newobj();
|
|
|
540 |
$this->pdf_acro_array .= $this->mpdf->n.' 0 R ';
|
|
|
541 |
$this->mpdf->_out('<<');
|
|
|
542 |
$this->mpdf->_out('/Type /Annot ');
|
|
|
543 |
$this->mpdf->_out('/Subtype /Widget');
|
|
|
544 |
$this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (3000 + $key++))));
|
|
|
545 |
$this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis')));
|
|
|
546 |
$this->mpdf->_out('/Rect [0 0 0 0] ');
|
|
|
547 |
$this->mpdf->_out('/FT /Btn ');
|
|
|
548 |
if ($frg['disabled']) { $flags=array(1,3,15,16); } // NoExport and readonly
|
|
|
549 |
else { $flags=array(15,16); } // Flags for Radiobutton, and NoToggleToOff
|
|
|
550 |
$this->mpdf->_out('/Ff '.$this->_setflag($flags) );
|
|
|
551 |
$kstr = '';
|
|
|
552 |
$optstr = '';
|
|
|
553 |
foreach($frg['kids'] AS $kid) {
|
|
|
554 |
$kstr .= $this->forms[$kid['n']]['obj'].' 0 R ';
|
|
|
555 |
// $optstr .= ' '.$this->mpdf->_textstring($kid['OPT']).' ';
|
|
|
556 |
}
|
|
|
557 |
$this->mpdf->_out('/Kids [ '.$kstr.' ] '); // 11 0 R 12 0 R etc.
|
|
|
558 |
// $this->mpdf->_out('/Opt [ '.$optstr.' ] ');
|
|
|
559 |
|
|
|
560 |
//V entry holds index corresponding to the appearance state of
|
|
|
561 |
//whichever child field is currently in the on state = or Off
|
|
|
562 |
if (isset($frg['on'])) { $state = $frg['on']; }
|
|
|
563 |
else { $state = 'Off'; }
|
|
|
564 |
$this->mpdf->_out('/V /'.$state.' ');
|
|
|
565 |
$this->mpdf->_out('/DV /'.$state.' ');
|
|
|
566 |
$this->mpdf->_out('/T '.$this->mpdf->_textstring($name).' ');
|
|
|
567 |
$this->mpdf->_out('>>');
|
|
|
568 |
$this->mpdf->_out('endobj');
|
|
|
569 |
}
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
function _putFormsCatalog() {
|
|
|
573 |
if (isset($this->pdf_acro_array) ) {
|
|
|
574 |
$this->mpdf->_out('/AcroForm << /DA (/F1 0 Tf 0 g )');
|
|
|
575 |
$this->mpdf->_out('/Q 0');
|
|
|
576 |
$this->mpdf->_out('/Fields ['.$this->pdf_acro_array.']');
|
|
|
577 |
$f = '';
|
|
|
578 |
foreach($this->form_fonts AS $fn) {
|
|
|
579 |
if (is_array($this->mpdf->fonts[$fn]['n'])) { $this->mpdf->Error("Cannot use fonts with SMP or SIP characters for interactive Form elements"); }
|
|
|
580 |
$f .= '/F'.$this->mpdf->fonts[$fn]['i'].' '.$this->mpdf->fonts[$fn]['n'].' 0 R ';
|
|
|
581 |
}
|
|
|
582 |
$this->mpdf->_out('/DR << /Font << '.$f.' >> >>');
|
|
|
583 |
// CO Calculation Order
|
|
|
584 |
if ( $this->pdf_array_co ) {
|
|
|
585 |
$this->mpdf->_out('/CO ['.$this->pdf_array_co.']');
|
|
|
586 |
}
|
|
|
587 |
$this->mpdf->_out('/NeedAppearances true');
|
|
|
588 |
$this->mpdf->_out('>>');
|
|
|
589 |
}
|
|
|
590 |
}
|
|
|
591 |
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
function SetFormButtonJS( $name, $js ) {
|
|
|
595 |
$js = str_replace("\t",' ', trim($js) );
|
|
|
596 |
if ( isset($name) && isset($js) ) {
|
|
|
597 |
$this->array_form_button_js[$this->mpdf->_escape($name)] = array(
|
|
|
598 |
'js' => $js
|
|
|
599 |
);
|
|
|
600 |
}
|
|
|
601 |
}
|
|
|
602 |
|
|
|
603 |
function SetFormChoiceJS( $name, $js ) {
|
|
|
604 |
$js = str_replace("\t",' ', trim($js) );
|
|
|
605 |
if ( isset($name) && isset($js) ) {
|
|
|
606 |
$this->array_form_choice_js[$this->mpdf->_escape($name)] = array(
|
|
|
607 |
'js' => $js
|
|
|
608 |
);
|
|
|
609 |
}
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
function SetFormTextJS( $name, $js) {
|
|
|
613 |
for ($i=0; $i<count($js); $i++) {
|
|
|
614 |
$j = str_replace("\t",' ', trim($js[$i][1]) );
|
|
|
615 |
$format = $js[$i][0];
|
|
|
616 |
if ($name) {
|
|
|
617 |
$this->array_form_text_js[$this->mpdf->_escape($name)][$format] = array('js' => $j);
|
|
|
618 |
}
|
|
|
619 |
}
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
|
|
|
623 |
function Win1252ToPDFDocEncoding($txt) {
|
|
|
624 |
$Win1252ToPDFDocEncoding = array(
|
|
|
625 |
chr(0200) => chr(0240), chr(0214) => chr(0226), chr(0212) => chr(0227), chr(0237) => chr(0230),
|
|
|
626 |
chr(0225) => chr(0200), chr(0210) => chr(0032), chr(0206) => chr(0201), chr(0207) => chr(0202),
|
|
|
627 |
chr(0205) => chr(0203), chr(0227) => chr(0204), chr(0226) => chr(0205), chr(0203) => chr(0206),
|
|
|
628 |
chr(0213) => chr(0210), chr(0233) => chr(0211), chr(0211) => chr(0213), chr(0204) => chr(0214),
|
|
|
629 |
chr(0223) => chr(0215), chr(0224) => chr(0216), chr(0221) => chr(0217), chr(0222) => chr(0220),
|
|
|
630 |
chr(0202) => chr(0221), chr(0232) => chr(0235), chr(0230) => chr(0037), chr(0231) => chr(0222),
|
|
|
631 |
chr(0216) => chr(0231), chr(0240) => chr(0040)
|
|
|
632 |
); // mPDF 5.3.46
|
|
|
633 |
return strtr($txt, $Win1252ToPDFDocEncoding );
|
|
|
634 |
}
|
|
|
635 |
|
|
|
636 |
|
|
|
637 |
function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $flags = array(), $align='L', $hidden = false, $maxlen=-1, $js='', $background_col=false, $border_col=false ) {
|
|
|
638 |
// Flags: 1 - Readonly; 2 - Required; 3 - No export; 13 - textarea; 14 - Password
|
|
|
639 |
$this->formn++;
|
|
|
640 |
if( $align == 'C' ) { $align = '1'; }
|
|
|
641 |
else if( $align == 'R' ) { $align = '2'; }
|
|
|
642 |
else { $align = '0'; }
|
|
|
643 |
if ($maxlen < 1) { $maxlen = false; }
|
|
|
644 |
if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) {
|
|
|
645 |
$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)");
|
|
|
646 |
}
|
|
|
647 |
if ($this->mpdf->onlyCoreFonts) {
|
|
|
648 |
$value = $this->Win1252ToPDFDocEncoding($value);
|
|
|
649 |
$default = $this->Win1252ToPDFDocEncoding($default);
|
|
|
650 |
$title = $this->Win1252ToPDFDocEncoding($title);
|
|
|
651 |
}
|
|
|
652 |
else {
|
|
|
653 |
if (isset($this->mpdf->CurrentFont['subset'])) {
|
|
|
654 |
$this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset
|
|
|
655 |
$this->mpdf->UTF8StringToArray($default, true); // Add characters to font subset
|
|
|
656 |
$this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset
|
|
|
657 |
}
|
|
|
658 |
if ($value) $value = $this->mpdf->UTF8ToUTF16BE($value, true);
|
|
|
659 |
if ($default ) $default = $this->mpdf->UTF8ToUTF16BE($default, true);
|
|
|
660 |
$title = $this->mpdf->UTF8ToUTF16BE($title, true);
|
|
|
661 |
}
|
|
|
662 |
if ($background_col) { $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); }
|
|
|
663 |
else { $bg_c = $this->form_background_color; }
|
|
|
664 |
if ($border_col) { $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); }
|
|
|
665 |
else { $bc_c = $this->form_border_color; }
|
|
|
666 |
$f = array( 'n' => $this->formn,
|
|
|
667 |
'typ' => 'Tx',
|
|
|
668 |
'page' => $this->mpdf->page,
|
|
|
669 |
'x' => $this->mpdf->x,
|
|
|
670 |
'y' => $this->mpdf->y,
|
|
|
671 |
'w' => $w,
|
|
|
672 |
'h' => $h,
|
|
|
673 |
'T' => $name,
|
|
|
674 |
'FF' => $flags,
|
|
|
675 |
'V' => $value,
|
|
|
676 |
'DV' => $default,
|
|
|
677 |
'TU' => $title,
|
|
|
678 |
'hidden' => $hidden,
|
|
|
679 |
'Q' => $align,
|
|
|
680 |
'maxlen' => $maxlen,
|
|
|
681 |
'BS_W' => $this->form_border_width,
|
|
|
682 |
'BS_S' => $this->form_border_style,
|
|
|
683 |
'BC_C' => $bc_c,
|
|
|
684 |
'BG_C' => $bg_c,
|
|
|
685 |
'style' => array(
|
|
|
686 |
'font' => $this->mpdf->FontFamily,
|
|
|
687 |
'fontsize' => $this->mpdf->FontSizePt,
|
|
|
688 |
'fontcolor' => $this->mpdf->TextColor,
|
|
|
689 |
)
|
|
|
690 |
);
|
|
|
691 |
if (is_array($js) && count($js)>0) { $this->SetFormTextJS( $name, $js); } // mPDF 5.3.25
|
|
|
692 |
if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; }
|
|
|
693 |
else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; }
|
|
|
694 |
else {
|
|
|
695 |
if ($this->mpdf->ColActive) {
|
|
|
696 |
$this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y,
|
|
|
697 |
'h' => $h);
|
|
|
698 |
$this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn;
|
|
|
699 |
}
|
|
|
700 |
$this->forms[$this->formn] = $f;
|
|
|
701 |
}
|
|
|
702 |
if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) {
|
|
|
703 |
$this->form_fonts[] = $this->mpdf->FontFamily;
|
|
|
704 |
$this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true;
|
|
|
705 |
}
|
|
|
706 |
if ( !$hidden ) $this->mpdf->x += $w;
|
|
|
707 |
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
|
|
|
711 |
function SetFormChoice( $w, $h, $name, $flags, $array, $align='L', $js = '' ) {
|
|
|
712 |
$this->formn++;
|
|
|
713 |
if( $this->mpdf->blk[$this->mpdf->blklvl]['direction'] == 'rtl' ) { $align = '2'; }
|
|
|
714 |
else { $align = '0'; }
|
|
|
715 |
if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) {
|
|
|
716 |
$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)");
|
|
|
717 |
}
|
|
|
718 |
if ($this->mpdf->onlyCoreFonts) {
|
|
|
719 |
for($i=0;$i<count($array['VAL']);$i++) {
|
|
|
720 |
$array['VAL'][$i] = $this->Win1252ToPDFDocEncoding($array['VAL'][$i]);
|
|
|
721 |
$array['OPT'][$i] = $this->Win1252ToPDFDocEncoding($array['OPT'][$i]);
|
|
|
722 |
}
|
|
|
723 |
}
|
|
|
724 |
else {
|
|
|
725 |
for($i=0;$i<count($array['VAL']);$i++) {
|
|
|
726 |
if (isset($this->mpdf->CurrentFont['subset'])) {
|
|
|
727 |
$this->mpdf->UTF8StringToArray($array['VAL'][$i], true); // Add characters to font subset
|
|
|
728 |
$this->mpdf->UTF8StringToArray($array['OPT'][$i], true); // Add characters to font subset
|
|
|
729 |
}
|
|
|
730 |
if ($array['VAL'][$i] ) $array['VAL'][$i] = $this->mpdf->UTF8ToUTF16BE($array['VAL'][$i], true);
|
|
|
731 |
if ($array['OPT'][$i] ) $array['OPT'][$i] = $this->mpdf->UTF8ToUTF16BE($array['OPT'][$i], true);
|
|
|
732 |
}
|
|
|
733 |
}
|
|
|
734 |
$f = array( 'n' => $this->formn,
|
|
|
735 |
'typ' => 'Ch',
|
|
|
736 |
'page' => $this->mpdf->page,
|
|
|
737 |
'x' => $this->mpdf->x,
|
|
|
738 |
'y' => $this->mpdf->y,
|
|
|
739 |
'w' => $w,
|
|
|
740 |
'h' => $h,
|
|
|
741 |
'T' => $name,
|
|
|
742 |
'OPT' => $array,
|
|
|
743 |
'FF' => $flags,
|
|
|
744 |
'Q' => $align,
|
|
|
745 |
'BS_W' => $this->form_border_width,
|
|
|
746 |
'BS_S' => $this->form_border_style,
|
|
|
747 |
'BC_C' => $this->form_border_color,
|
|
|
748 |
'BG_C' => $this->form_background_color,
|
|
|
749 |
'style' => array(
|
|
|
750 |
'font' => $this->mpdf->FontFamily,
|
|
|
751 |
'fontsize' => $this->mpdf->FontSizePt,
|
|
|
752 |
'fontcolor' => $this->mpdf->TextColor,
|
|
|
753 |
)
|
|
|
754 |
);
|
|
|
755 |
if ($js) { $this->SetFormChoiceJS( $name, $js ); }
|
|
|
756 |
if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; }
|
|
|
757 |
else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; }
|
|
|
758 |
else {
|
|
|
759 |
if ($this->mpdf->ColActive) {
|
|
|
760 |
$this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y,
|
|
|
761 |
'h' => $h);
|
|
|
762 |
$this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn;
|
|
|
763 |
}
|
|
|
764 |
$this->forms[$this->formn] = $f;
|
|
|
765 |
}
|
|
|
766 |
if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) {
|
|
|
767 |
$this->form_fonts[] = $this->mpdf->FontFamily;
|
|
|
768 |
$this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true;
|
|
|
769 |
}
|
|
|
770 |
$this->mpdf->x += $w;
|
|
|
771 |
}
|
|
|
772 |
|
|
|
773 |
// CHECKBOX
|
|
|
774 |
function SetCheckBox( $w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled=false ) {
|
|
|
775 |
$this->SetFormButton( $w, $h, $name, $value, 'checkbox', $title, $flags, $checked, $disabled );
|
|
|
776 |
$this->mpdf->x += $w;
|
|
|
777 |
}
|
|
|
778 |
|
|
|
779 |
|
|
|
780 |
// RADIO
|
|
|
781 |
function SetRadio( $w, $h, $name, $value, $title = '', $checked = false, $flags = array(), $disabled=false ) {
|
|
|
782 |
$this->SetFormButton( $w, $h, $name, $value, 'radio', $title, $flags, $checked, $disabled );
|
|
|
783 |
$this->mpdf->x += $w;
|
|
|
784 |
}
|
|
|
785 |
|
|
|
786 |
|
|
|
787 |
function SetFormReset( $w, $h, $name, $value = 'Reset', $title = '', $flags = array(), $background_col=false, $border_col=false, $noprint=false ) {
|
|
|
788 |
if (!$name) { $name = 'Reset'; }
|
|
|
789 |
$this->SetFormButton( $w, $h, $name, $value, 'reset', $title, $flags, false, false, $background_col, $border_col, $noprint);
|
|
|
790 |
$this->mpdf->x += $w;
|
|
|
791 |
}
|
|
|
792 |
|
|
|
793 |
|
|
|
794 |
function SetJSButton( $w, $h, $name, $value, $js, $image_id = 0, $title = '', $flags = array(), $indexed=false , $background_col=false, $border_col=false, $noprint=false ) {
|
|
|
795 |
$this->SetFormButton( $w, $h, $name, $value, 'js_button', $title, $flags, false, false, $background_col, $border_col, $noprint);
|
|
|
796 |
// pos => 1 = no caption, icon only; 0 = caption only
|
|
|
797 |
if ($image_id) {
|
|
|
798 |
$this->form_button_icon[$this->mpdf->_escape($name)] = array(
|
|
|
799 |
'pos' => 1,
|
|
|
800 |
'image_id' => $image_id,
|
|
|
801 |
'Indexed' => $indexed,
|
|
|
802 |
);
|
|
|
803 |
}
|
|
|
804 |
if ($js) { $this->SetFormButtonJS( $name, $js ); }
|
|
|
805 |
$this->mpdf->x += $w;
|
|
|
806 |
}
|
|
|
807 |
|
|
|
808 |
|
|
|
809 |
function SetFormSubmit( $w, $h, $name, $value = 'Submit', $url, $title = '', $typ = 'html', $method = 'POST', $flags = array(), $background_col=false, $border_col=false, $noprint=false) {
|
|
|
810 |
if (!$name) { $name = 'Submit'; }
|
|
|
811 |
$this->SetFormButton( $w, $h, $name, $value, 'submit', $title, $flags, false, false, $background_col, $border_col, $noprint);
|
|
|
812 |
$this->forms[$this->formn]['URL'] = $url;
|
|
|
813 |
$this->forms[$this->formn]['method'] = $method;
|
|
|
814 |
$this->forms[$this->formn]['exporttype'] = $typ;
|
|
|
815 |
$this->mpdf->x += $w;
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
|
|
|
819 |
function SetFormButtonText( $ca, $rc = '', $ac = '' ) {
|
|
|
820 |
if ($this->mpdf->onlyCoreFonts) {
|
|
|
821 |
$ca = $this->Win1252ToPDFDocEncoding($ca);
|
|
|
822 |
if ($rc) $rc = $this->Win1252ToPDFDocEncoding($rc);
|
|
|
823 |
if ($ac) $ac = $this->Win1252ToPDFDocEncoding($ac);
|
|
|
824 |
}
|
|
|
825 |
else {
|
|
|
826 |
if (isset($this->mpdf->CurrentFont['subset'])) {
|
|
|
827 |
$this->mpdf->UTF8StringToArray($ca, true); // Add characters to font subset
|
|
|
828 |
}
|
|
|
829 |
$ca = $this->mpdf->UTF8ToUTF16BE($ca, true);
|
|
|
830 |
if ($rc) {
|
|
|
831 |
if (isset($this->mpdf->CurrentFont['subset'])) { $this->mpdf->UTF8StringToArray($rc, true); }
|
|
|
832 |
$rc = $this->mpdf->UTF8ToUTF16BE($rc, true);
|
|
|
833 |
}
|
|
|
834 |
if ($ac) {
|
|
|
835 |
if (isset($this->mpdf->CurrentFont['subset'])) { $this->mpdf->UTF8StringToArray($ac, true); }
|
|
|
836 |
$ac = $this->mpdf->UTF8ToUTF16BE($ac, true);
|
|
|
837 |
}
|
|
|
838 |
}
|
|
|
839 |
$this->form_button_text = $ca;
|
|
|
840 |
$this->form_button_text_over = $rc ? $rc : $ca;
|
|
|
841 |
$this->form_button_text_click = $ac ? $ac : $ca;
|
|
|
842 |
}
|
|
|
843 |
|
|
|
844 |
|
|
|
845 |
function SetFormButton( $bb, $hh, $name, $value, $type, $title = '', $flags = array(), $checked=false, $disabled=false, $background_col=false, $border_col=false, $noprint=false ) {
|
|
|
846 |
$this->formn++;
|
|
|
847 |
if (!preg_match('/^[a-zA-Z0-9_:\-]+$/', $name)) {
|
|
|
848 |
$this->mpdf->Error("Field [".$name."] must have a name attribute, which can only contain letters, numbers, colon(:), undersore(_) or hyphen(-)");
|
|
|
849 |
}
|
|
|
850 |
if (!$this->mpdf->onlyCoreFonts) {
|
|
|
851 |
if (isset($this->mpdf->CurrentFont['subset'])) {
|
|
|
852 |
$this->mpdf->UTF8StringToArray($title, true); // Add characters to font subset
|
|
|
853 |
$this->mpdf->UTF8StringToArray($value, true); // Add characters to font subset
|
|
|
854 |
}
|
|
|
855 |
$title = $this->mpdf->UTF8ToUTF16BE($title, true);
|
|
|
856 |
if ($type == 'checkbox') {
|
|
|
857 |
$uvalue = $this->mpdf->UTF8ToUTF16BE($value, true);
|
|
|
858 |
}
|
|
|
859 |
else if ($type == 'radio') {
|
|
|
860 |
$uvalue = $this->mpdf->UTF8ToUTF16BE($value, true);
|
|
|
861 |
$value = mb_convert_encoding($value, 'Windows-1252', 'UTF-8');
|
|
|
862 |
}
|
|
|
863 |
else {
|
|
|
864 |
$value = $this->mpdf->UTF8ToUTF16BE($value, true);
|
|
|
865 |
$uvalue = $value;
|
|
|
866 |
}
|
|
|
867 |
}
|
|
|
868 |
else {
|
|
|
869 |
$title = $this->Win1252ToPDFDocEncoding($title);
|
|
|
870 |
$value = $this->Win1252ToPDFDocEncoding($value); //// ??? not needed
|
|
|
871 |
$uvalue = mb_convert_encoding($value, 'UTF-8', 'Windows-1252');
|
|
|
872 |
$uvalue = $this->mpdf->UTF8ToUTF16BE($uvalue, true);
|
|
|
873 |
}
|
|
|
874 |
if ($type == 'radio' || $type == 'checkbox') {
|
|
|
875 |
if (!preg_match('/^[a-zA-Z0-9_:\-\.]+$/', $value)) {
|
|
|
876 |
$this->mpdf->Error("Field '".$name."' must have a value, which can only contain letters, numbers, colon(:), undersore(_), hyphen(-) or period(.)");
|
|
|
877 |
}
|
|
|
878 |
}
|
|
|
879 |
if ($type == 'radio') {
|
|
|
880 |
if (!isset($this->form_radio_groups[$name])) {
|
|
|
881 |
$this->form_radio_groups[$name] = array(
|
|
|
882 |
'page' => $this->mpdf->page,
|
|
|
883 |
'kids' => array(),
|
|
|
884 |
);
|
|
|
885 |
}
|
|
|
886 |
$this->form_radio_groups[$name]['kids'][] = array(
|
|
|
887 |
'n' => $this->formn, 'V'=> $value, 'OPT'=>$uvalue, 'disabled'=>$disabled
|
|
|
888 |
);
|
|
|
889 |
if ( $checked ) { $this->form_radio_groups[$name]['on'] = $value; }
|
|
|
890 |
// Disable the whole radio group if one is disabled, because of inconsistency in PDF readers
|
|
|
891 |
if ( $disabled ) { $this->form_radio_groups[$name]['disabled'] = true; }
|
|
|
892 |
}
|
|
|
893 |
if ($type == 'checkbox') {
|
|
|
894 |
$this->form_checkboxes = true;
|
|
|
895 |
}
|
|
|
896 |
if ( $checked ) { $activ = 1; }
|
|
|
897 |
else { $activ = 0; }
|
|
|
898 |
if ($background_col) { $bg_c = $this->mpdf->SetColor($background_col, 'CodeOnly'); }
|
|
|
899 |
else { $bg_c = $this->form_button_background_color; }
|
|
|
900 |
if ($border_col) { $bc_c = $this->mpdf->SetColor($border_col, 'CodeOnly'); }
|
|
|
901 |
else { $bc_c = $this->form_button_border_color; }
|
|
|
902 |
$f = array( 'n' => $this->formn,
|
|
|
903 |
'typ' => 'Bt',
|
|
|
904 |
'page' => $this->mpdf->page,
|
|
|
905 |
'subtype' => $type,
|
|
|
906 |
'x' => $this->mpdf->x,
|
|
|
907 |
'y' => $this->mpdf->y,
|
|
|
908 |
'w' => $bb,
|
|
|
909 |
'h' => $hh,
|
|
|
910 |
'T' => $name,
|
|
|
911 |
'V' => $value,
|
|
|
912 |
'OPT' => $uvalue,
|
|
|
913 |
'TU' => $title,
|
|
|
914 |
'FF' => $flags,
|
|
|
915 |
'CA' => $this->form_button_text,
|
|
|
916 |
'RC' => $this->form_button_text_over,
|
|
|
917 |
'AC' => $this->form_button_text_click,
|
|
|
918 |
'BS_W' => $this->form_button_border_width,
|
|
|
919 |
'BS_S' => $this->form_button_border_style,
|
|
|
920 |
'BC_C' => $bc_c,
|
|
|
921 |
'BG_C' => $bg_c,
|
|
|
922 |
'activ' => $activ,
|
|
|
923 |
'disabled' => $disabled,
|
|
|
924 |
'noprint' => $noprint,
|
|
|
925 |
'style' => array(
|
|
|
926 |
'font' => $this->mpdf->FontFamily,
|
|
|
927 |
'fontsize' => $this->mpdf->FontSizePt,
|
|
|
928 |
'fontcolor' => $this->mpdf->TextColor,
|
|
|
929 |
)
|
|
|
930 |
);
|
|
|
931 |
if ($this->mpdf->keep_block_together) { $this->mpdf->ktForms[]= $f; }
|
|
|
932 |
else if ($this->mpdf->writingHTMLheader || $this->mpdf->writingHTMLfooter) { $this->mpdf->HTMLheaderPageForms[]= $f; }
|
|
|
933 |
else {
|
|
|
934 |
if ($this->mpdf->ColActive) {
|
|
|
935 |
$this->mpdf->columnbuffer[] = array('s' => 'ACROFORM', 'col' => $this->mpdf->CurrCol, 'x' => $this->mpdf->x, 'y' => $this->mpdf->y,
|
|
|
936 |
'h' => $hh);
|
|
|
937 |
$this->mpdf->columnForms[$this->mpdf->CurrCol][INTVAL($this->mpdf->x)][INTVAL($this->mpdf->y)] = $this->formn;
|
|
|
938 |
}
|
|
|
939 |
$this->forms[$this->formn] = $f;
|
|
|
940 |
}
|
|
|
941 |
if (!in_array($this->mpdf->FontFamily, $this->form_fonts)) {
|
|
|
942 |
$this->form_fonts[] = $this->mpdf->FontFamily;
|
|
|
943 |
$this->mpdf->fonts[$this->mpdf->FontFamily]['used'] = true;
|
|
|
944 |
}
|
|
|
945 |
|
|
|
946 |
$this->form_button_text = NULL;
|
|
|
947 |
$this->form_button_text_over = NULL;
|
|
|
948 |
$this->form_button_text_click = NULL;
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
|
|
|
952 |
|
|
|
953 |
function SetFormBorderWidth ( $string ) {
|
|
|
954 |
switch( $string ) {
|
|
|
955 |
case 'S': $this->form_border_width = '1';
|
|
|
956 |
break;
|
|
|
957 |
case 'M': $this->form_border_width = '2';
|
|
|
958 |
break;
|
|
|
959 |
case 'B': $this->form_border_width = '3';
|
|
|
960 |
break;
|
|
|
961 |
case '0': $this->form_border_width = '0';
|
|
|
962 |
break;
|
|
|
963 |
default: $this->form_border_width = '0';
|
|
|
964 |
break;
|
|
|
965 |
}
|
|
|
966 |
}
|
|
|
967 |
|
|
|
968 |
|
|
|
969 |
function SetFormBorderStyle ( $string ) {
|
|
|
970 |
switch( $string ) {
|
|
|
971 |
case 'S': $this->form_border_style = 'S';
|
|
|
972 |
break;
|
|
|
973 |
case 'D': $this->form_border_style = 'D /D [3]';
|
|
|
974 |
break;
|
|
|
975 |
case 'B': $this->form_border_style = 'B';
|
|
|
976 |
break;
|
|
|
977 |
case 'I': $this->form_border_style = 'I';
|
|
|
978 |
break;
|
|
|
979 |
case 'U': $this->form_border_style = 'U';
|
|
|
980 |
break;
|
|
|
981 |
default: $this->form_border_style = 'B';
|
|
|
982 |
break;
|
|
|
983 |
}
|
|
|
984 |
}
|
|
|
985 |
|
|
|
986 |
function SetFormBorderColor ( $r, $g=-1, $b=-1 ) {
|
|
|
987 |
if ( ($r==0 and $g==0 and $b==0) || $g==-1 )
|
|
|
988 |
$this->form_border_color = sprintf('%.3F', $r/255);
|
|
|
989 |
else
|
|
|
990 |
$this->form_border_color = sprintf('%.3F %.3F %.3F', $r/255, $g/255, $b/255);
|
|
|
991 |
}
|
|
|
992 |
|
|
|
993 |
function SetFormBackgroundColor ( $r, $g=-1, $b=-1 ) {
|
|
|
994 |
if ( ($r==0 and $g==0 and $b==0) || $g==-1 )
|
|
|
995 |
$this->form_background_color = sprintf('%.3F', $r/255);
|
|
|
996 |
else
|
|
|
997 |
$this->form_background_color = sprintf('%.3F %.3F %.3F', $r/255, $g/255, $b/255);
|
|
|
998 |
}
|
|
|
999 |
|
|
|
1000 |
function SetFormD ( $W, $S, $BC, $BG ) {
|
|
|
1001 |
$this->SetFormBorderWidth ( $W );
|
|
|
1002 |
$this->SetFormBorderStyle ( $S );
|
|
|
1003 |
$this->SetFormBorderColor ( $BC );
|
|
|
1004 |
$this->SetFormBackgroundColor ( $BG );
|
|
|
1005 |
}
|
|
|
1006 |
|
|
|
1007 |
function _setflag( $array ) {
|
|
|
1008 |
$flag = 0;
|
|
|
1009 |
foreach($array as $val) { $flag += 1 << ($val-1); }
|
|
|
1010 |
return $flag;
|
|
|
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
function _form_rect( $x, $y, $w, $h, $hPt ) {
|
|
|
1014 |
$x = $x * _MPDFK;
|
|
|
1015 |
$y = $hPt - ($y * _MPDFK);
|
|
|
1016 |
$x2 = $x + ($w * _MPDFK);
|
|
|
1017 |
$y2 = $y - ($h * _MPDFK);
|
|
|
1018 |
$rect = sprintf('%.3F %.3F %.3F %.3F', $x, $y2, $x2, $y );
|
|
|
1019 |
return $rect;
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
|
|
|
1023 |
function _put_button_icon( $array , $w, $h ) {
|
|
|
1024 |
if (isset($array['image_id'])) {
|
|
|
1025 |
$info = false;
|
|
|
1026 |
foreach($this->mpdf->images AS $iid=>$img) {
|
|
|
1027 |
if ($img['i'] == $array['image_id']) {
|
|
|
1028 |
$info = $this->mpdf->images[$iid];
|
|
|
1029 |
break;
|
|
|
1030 |
}
|
|
|
1031 |
}
|
|
|
1032 |
}
|
|
|
1033 |
if (!$info) { die("Cannot find Button image"); }
|
|
|
1034 |
$this->mpdf->_newobj();
|
|
|
1035 |
$this->mpdf->_out('<<');
|
|
|
1036 |
$this->mpdf->_out('/Type /XObject');
|
|
|
1037 |
$this->mpdf->_out('/Subtype /Image');
|
|
|
1038 |
$this->mpdf->_out('/BBox [0 0 1 1]');
|
|
|
1039 |
$this->mpdf->_out('/Length '.strlen($info['data']));
|
|
|
1040 |
$this->mpdf->_out('/BitsPerComponent '.$info['bpc']);
|
|
|
1041 |
if ($info['cs']=='Indexed') {
|
|
|
1042 |
$this->mpdf->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->mpdf->n+1).' 0 R]');
|
|
|
1043 |
}
|
|
|
1044 |
else {
|
|
|
1045 |
$this->mpdf->_out('/ColorSpace /'.$info['cs']);
|
|
|
1046 |
if ($info['cs']=='DeviceCMYK')
|
|
|
1047 |
if($info['type']=='jpg') { $this->mpdf->_out('/Decode [1 0 1 0 1 0 1 0]'); }
|
|
|
1048 |
}
|
|
|
1049 |
if ( isset($info['f']) )
|
|
|
1050 |
$this->mpdf->_out('/Filter /'.$info['f']);
|
|
|
1051 |
if ( isset($info['parms']) )
|
|
|
1052 |
$this->mpdf->_out($info['parms']);
|
|
|
1053 |
$this->mpdf->_out('/Width '.$info['w']);
|
|
|
1054 |
$this->mpdf->_out('/Height '.$info['h']);
|
|
|
1055 |
$this->mpdf->_out('>>');
|
|
|
1056 |
$this->mpdf->_putstream($info['data']);
|
|
|
1057 |
$this->mpdf->_out('endobj');
|
|
|
1058 |
unset($array);
|
|
|
1059 |
//Palette
|
|
|
1060 |
if($info['cs']=='Indexed') {
|
|
|
1061 |
$filter=($this->mpdf->compress) ? '/Filter /FlateDecode ' : '';
|
|
|
1062 |
$this->mpdf->_newobj();
|
|
|
1063 |
$pal=($this->mpdf->compress) ? gzcompress($info['pal']) : $info['pal'];
|
|
|
1064 |
$this->mpdf->_out('<<'.$filter.'/Length '.strlen($pal).'>>');
|
|
|
1065 |
$this->mpdf->_putstream($pal);
|
|
|
1066 |
$this->mpdf->_out('endobj');
|
|
|
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
}
|
|
|
1070 |
|
|
|
1071 |
|
|
|
1072 |
function _putform_bt( $form, $hPt ) {
|
|
|
1073 |
$cc = 0;
|
|
|
1074 |
$put_xobject = 0;
|
|
|
1075 |
$put_js = 0;
|
|
|
1076 |
$put_icon = 0;
|
|
|
1077 |
$this->mpdf->_newobj();
|
|
|
1078 |
$n = $this->mpdf->n;
|
|
|
1079 |
if ($form['subtype'] != 'radio') $this->pdf_acro_array .= $n.' 0 R '; // Add to /Field element
|
|
|
1080 |
$this->forms[ $form['n'] ]['obj'] = $n;
|
|
|
1081 |
$this->mpdf->_out('<<');
|
|
|
1082 |
$this->mpdf->_out('/Type /Annot ');
|
|
|
1083 |
$this->mpdf->_out('/Subtype /Widget');
|
|
|
1084 |
$this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (7000 + $form['n']))));
|
|
|
1085 |
$this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis')));
|
|
|
1086 |
$this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ]');
|
|
|
1087 |
$form['noprint'] ? $this->mpdf->_out('/F 0 ') : $this->mpdf->_out('/F 4 ');
|
|
|
1088 |
$this->mpdf->_out('/FT /Btn ');
|
|
|
1089 |
$this->mpdf->_out('/H /P ');
|
|
|
1090 |
if ( $form['subtype'] != 'radio' ) // mPDF 5.3.23
|
|
|
1091 |
$this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) );
|
|
|
1092 |
$this->mpdf->_out('/TU '.$this->mpdf->_textstring($form['TU']) );
|
|
|
1093 |
if ( isset( $this->form_button_icon[ $form['T'] ] ) ) { $form['BS_W'] = 0; }
|
|
|
1094 |
if ($form['BS_W'] == 0) { $form['BC_C'] = $form['BG_C']; }
|
|
|
1095 |
$bstemp = '';
|
|
|
1096 |
$bstemp .= '/W '.$form['BS_W'].' ';
|
|
|
1097 |
$bstemp .= '/S /'.$form['BS_S'].' ';
|
|
|
1098 |
$temp = '';
|
|
|
1099 |
$temp .= '/BC [ '.$form['BC_C']." ] ";
|
|
|
1100 |
$temp .= '/BG [ '.$form['BG_C']." ] ";
|
|
|
1101 |
if ( $form['subtype'] == 'checkbox' ) {
|
|
|
1102 |
if ($form['disabled']) {
|
|
|
1103 |
$radio_color = '0.5 0.5 0.5';
|
|
|
1104 |
$radio_background_color = '0.9 0.9 0.9';
|
|
|
1105 |
}
|
|
|
1106 |
else {
|
|
|
1107 |
$radio_color = $this->form_radio_color;
|
|
|
1108 |
$radio_background_color = $this->form_radio_background_color;
|
|
|
1109 |
}
|
|
|
1110 |
$temp = '';
|
|
|
1111 |
$temp .= '/BC [ '.$radio_color." ] ";
|
|
|
1112 |
$temp .= '/BG [ '.$radio_background_color." ] ";
|
|
|
1113 |
$this->mpdf->_out("/BS << /W 1 /S /S >>");
|
|
|
1114 |
$this->mpdf->_out("/MK << $temp >>");
|
|
|
1115 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) );
|
|
|
1116 |
if ( $form['activ'] ) {
|
|
|
1117 |
$this->mpdf->_out('/V /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1118 |
$this->mpdf->_out('/DV /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1119 |
$this->mpdf->_out('/AS /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1120 |
} else {
|
|
|
1121 |
$this->mpdf->_out('/AS /Off ');
|
|
|
1122 |
}
|
|
|
1123 |
if ($this->formUseZapD) {
|
|
|
1124 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts['czapfdingbats']['i'].' 0 Tf '.$radio_color.' rg)');
|
|
|
1125 |
$this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off /Off >> >>");
|
|
|
1126 |
}
|
|
|
1127 |
else {
|
|
|
1128 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'].' 0 Tf '.$radio_color.' rg)');
|
|
|
1129 |
$this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>");
|
|
|
1130 |
}
|
|
|
1131 |
$this->mpdf->_out('/Opt [ '.$this->mpdf->_textstring($form['OPT']).' '.$this->mpdf->_textstring($form['OPT']).' ]');
|
|
|
1132 |
}
|
|
|
1133 |
|
|
|
1134 |
|
|
|
1135 |
if ( $form['subtype'] == 'radio' ) {
|
|
|
1136 |
if ($form['disabled'] || $this->form_radio_groups[$form['T']]['disabled']) {
|
|
|
1137 |
$radio_color = '0.5 0.5 0.5';
|
|
|
1138 |
$radio_background_color = '0.9 0.9 0.9';
|
|
|
1139 |
}
|
|
|
1140 |
else {
|
|
|
1141 |
$radio_color = $this->form_radio_color;
|
|
|
1142 |
$radio_background_color = $this->form_radio_background_color;
|
|
|
1143 |
}
|
|
|
1144 |
$this->mpdf->_out('/Parent '.$this->form_radio_groups[$form['T']]['obj_id'].' 0 R ');
|
|
|
1145 |
$temp = '';
|
|
|
1146 |
$temp .= '/BC [ '.$radio_color." ] ";
|
|
|
1147 |
$temp .= '/BG [ '.$radio_background_color." ] ";
|
|
|
1148 |
$this->mpdf->_out("/BS << /W 1 /S /S >>");
|
|
|
1149 |
$this->mpdf->_out('/MK << '.$temp.' >> ');
|
|
|
1150 |
$form['FF'][] = 16; // Radiobutton
|
|
|
1151 |
$form['FF'][] = 15; // NoToggleOff - must be same as radio button group setting?
|
|
|
1152 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) );
|
|
|
1153 |
if ($this->formUseZapD)
|
|
|
1154 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts['czapfdingbats']['i'].' 0 Tf '.$radio_color.' rg)');
|
|
|
1155 |
else
|
|
|
1156 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$this->mpdf->CurrentFont['fontkey']]['i'].' 0 Tf '.$radio_color.' rg)');
|
|
|
1157 |
$this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>");
|
|
|
1158 |
if ( $form['activ'] ) {
|
|
|
1159 |
$this->mpdf->_out('/V /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1160 |
$this->mpdf->_out('/DV /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1161 |
$this->mpdf->_out('/AS /'.$this->mpdf->_escape($form['V']).' ');
|
|
|
1162 |
}
|
|
|
1163 |
else {
|
|
|
1164 |
$this->mpdf->_out('/AS /Off ');
|
|
|
1165 |
}
|
|
|
1166 |
$this->mpdf->_out("/AP << /N << /".$this->mpdf->_escape($form['V'])." ".($this->mpdf->n+1)." 0 R /Off ".($this->mpdf->n+2)." 0 R >> >>");
|
|
|
1167 |
// $this->mpdf->_out('/Opt [ '.$this->mpdf->_textstring($form['OPT']).' '.$this->mpdf->_textstring($form['OPT']).' ]');
|
|
|
1168 |
}
|
|
|
1169 |
|
|
|
1170 |
if ( $form['subtype'] == 'reset' ) {
|
|
|
1171 |
$temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1172 |
$temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1173 |
$temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1174 |
$this->mpdf->_out("/BS << $bstemp >>");
|
|
|
1175 |
$this->mpdf->_out('/MK << '.$temp.' >>');
|
|
|
1176 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
|
|
|
1177 |
$this->mpdf->_out('/AA << /D << /S /ResetForm /Flags 1 >> >>');
|
|
|
1178 |
$form['FF'][] = 17;
|
|
|
1179 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) );
|
|
|
1180 |
}
|
|
|
1181 |
|
|
|
1182 |
|
|
|
1183 |
if ( $form['subtype'] == 'submit' ) {
|
|
|
1184 |
$temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1185 |
$temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1186 |
$temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1187 |
$this->mpdf->_out("/BS << $bstemp >>");
|
|
|
1188 |
$this->mpdf->_out("/MK << $temp >>");
|
|
|
1189 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
|
|
|
1190 |
// Bit 4 (8) = useGETmethod else use POST
|
|
|
1191 |
// Bit 3 (4) = HTML export format (charset chosen by Adobe)--- OR ---
|
|
|
1192 |
// Bit 6 (32) = XFDF export format (form of XML in UTF-8)
|
|
|
1193 |
if ($form['exporttype'] == 'xfdf') { $flag = 32; } // 'xfdf' or 'html'
|
|
|
1194 |
else {
|
|
|
1195 |
if ($form['method'] == 'GET') { $flag = 12; }
|
|
|
1196 |
else { $flag = 4; }
|
|
|
1197 |
}
|
|
|
1198 |
// Bit 2 (2) = IncludeNoValueFields
|
|
|
1199 |
if ($this->formSubmitNoValueFields) $flag += 2;
|
|
|
1200 |
// To submit a value, needs to be in /AP dictionary, AND this object must contain a /Fields entry
|
|
|
1201 |
// listing all fields to output
|
|
|
1202 |
$this->mpdf->_out('/AA << /D << /S /SubmitForm /F ('.$form['URL'].') /Flags '.$flag.' >> >>');
|
|
|
1203 |
$form['FF'][] = 17;
|
|
|
1204 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) );
|
|
|
1205 |
}
|
|
|
1206 |
|
|
|
1207 |
if ( $form['subtype'] == 'js_button' ) {
|
|
|
1208 |
// Icon / image
|
|
|
1209 |
if ( isset( $this->form_button_icon[ $form['T'] ] ) ) {
|
|
|
1210 |
$cc++;
|
|
|
1211 |
$temp .= '/TP '.$this->form_button_icon[$form['T']]['pos'].' ';
|
|
|
1212 |
$temp .= '/I '.($cc + $this->mpdf->n).' 0 R '; // Normal icon
|
|
|
1213 |
$temp .= '/RI '.($cc + $this->mpdf->n).' 0 R '; // onMouseOver
|
|
|
1214 |
$temp .= '/IX '.($cc + $this->mpdf->n).' 0 R '; // onClick / onMouseDown
|
|
|
1215 |
$temp .= '/IF << /SW /A /S /A /A [0.0 0.0] >> '; // Icon fit dictionary
|
|
|
1216 |
if ($this->form_button_icon[ $form['T'] ]['Indexed']) { $cc++; }
|
|
|
1217 |
$put_icon = 1;
|
|
|
1218 |
}
|
|
|
1219 |
$temp .= $form['CA'] ? '/CA '.$this->mpdf->_textstring($form['CA']).' ' : '/CA '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1220 |
$temp .= $form['RC'] ? '/RC '.$this->mpdf->_textstring($form['RC']).' ' : '/RC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1221 |
$temp .= $form['AC'] ? '/AC '.$this->mpdf->_textstring($form['AC']).' ' : '/AC '.$this->mpdf->_textstring($form['T']).' ';
|
|
|
1222 |
$this->mpdf->_out("/BS << $bstemp >>");
|
|
|
1223 |
$this->mpdf->_out("/MK << $temp >>");
|
|
|
1224 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
|
|
|
1225 |
$form['FF'][] = 17;
|
|
|
1226 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']) );
|
|
|
1227 |
// Javascript
|
|
|
1228 |
if ( isset($this->array_form_button_js[$form['T']]) ) {
|
|
|
1229 |
$cc++;
|
|
|
1230 |
$this->mpdf->_out("/AA << /D ".($cc + $this->mpdf->n)." 0 R >>");
|
|
|
1231 |
$put_js = 1;
|
|
|
1232 |
}
|
|
|
1233 |
}
|
|
|
1234 |
|
|
|
1235 |
$this->mpdf->_out('>>');
|
|
|
1236 |
$this->mpdf->_out('endobj');
|
|
|
1237 |
|
|
|
1238 |
// additional objects
|
|
|
1239 |
// obj icon
|
|
|
1240 |
if ( $put_icon == 1 ) {
|
|
|
1241 |
$this->_put_button_icon( $this->form_button_icon[ $form['T'] ], $form['w'], $form['h'] );
|
|
|
1242 |
$put_icon = NULL;
|
|
|
1243 |
}
|
|
|
1244 |
// obj + 1
|
|
|
1245 |
if ( $put_js == 1 ) {
|
|
|
1246 |
$this->mpdf->_set_object_javascript( $this->array_form_button_js[$form['T']]['js'] );
|
|
|
1247 |
unset( $this->array_form_button_js[$form['T']] );
|
|
|
1248 |
$put_js = NULL;
|
|
|
1249 |
}
|
|
|
1250 |
|
|
|
1251 |
// RADIO and CHECK BOX appearance streams
|
|
|
1252 |
$filter=($this->mpdf->compress) ? '/Filter /FlateDecode ' : '';
|
|
|
1253 |
if ( $form['subtype'] == 'radio' ) {
|
|
|
1254 |
// output 2 appearance streams for radio buttons on/off
|
|
|
1255 |
if ($this->formUseZapD) {
|
|
|
1256 |
$fs = sprintf('%.3F', $form['style']['fontsize']*1.25);
|
|
|
1257 |
$fi = 'czapfdingbats';
|
|
|
1258 |
$r_on = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (4) Tj ET Q';
|
|
|
1259 |
$r_off = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (8) Tj ET Q';
|
|
|
1260 |
}
|
|
|
1261 |
else {
|
|
|
1262 |
$matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize']*1.33/10, $form['style']['fontsize']*1.25/10, $form['style']['fontsize']);
|
|
|
1263 |
$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 ';
|
|
|
1264 |
$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 ';
|
|
|
1265 |
$r_on = 'q '.$matrix.' cm '.$fill .$radio_color.' rg '.$circle.' '.$radio_color.' rg
|
|
|
1266 |
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
|
|
|
1267 |
f Q ';
|
|
|
1268 |
$r_off = 'q '.$matrix.' cm '.$fill .$radio_color.' rg '.$circle.' Q ';
|
|
|
1269 |
}
|
|
|
1270 |
|
|
|
1271 |
$this->mpdf->_newobj();
|
|
|
1272 |
$p=($this->mpdf->compress) ? gzcompress($r_on) : $r_on;
|
|
|
1273 |
$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
|
|
|
1274 |
$this->mpdf->_putstream($p);
|
|
|
1275 |
$this->mpdf->_out('endobj');
|
|
|
1276 |
|
|
|
1277 |
$this->mpdf->_newobj();
|
|
|
1278 |
$p=($this->mpdf->compress) ? gzcompress($r_off) : $r_off;
|
|
|
1279 |
$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
|
|
|
1280 |
$this->mpdf->_putstream($p);
|
|
|
1281 |
$this->mpdf->_out('endobj');
|
|
|
1282 |
}
|
|
|
1283 |
if ( $form['subtype'] == 'checkbox' ) {
|
|
|
1284 |
// First output appearance stream for check box on
|
|
|
1285 |
if ($this->formUseZapD) {
|
|
|
1286 |
$fs = sprintf('%.3F', $form['style']['fontsize']*1.25);
|
|
|
1287 |
$fi = 'czapfdingbats';
|
|
|
1288 |
$cb_on = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (4) Tj ET Q';
|
|
|
1289 |
$cb_off = 'q '.$radio_color .' rg BT /F'.$this->mpdf->fonts[$fi]['i'].' '.$fs.' Tf 0 0 Td (8) Tj ET Q';
|
|
|
1290 |
}
|
|
|
1291 |
else {
|
|
|
1292 |
$matrix = sprintf('%.3F 0 0 %.3F 0 %.3F', $form['style']['fontsize']*1.33/10, $form['style']['fontsize']*1.25/10, $form['style']['fontsize']);
|
|
|
1293 |
$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 ';
|
|
|
1294 |
$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 ';
|
|
|
1295 |
$cb_on = 'q '.$matrix.' cm '.$fill. $radio_color.' rg '.$square.' f '.$radio_color.' rg
|
|
|
1296 |
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 ';
|
|
|
1297 |
$cb_off = 'q '.$matrix.' cm '.$fill. $radio_color.' rg '.$square.' f Q ';
|
|
|
1298 |
|
|
|
1299 |
}
|
|
|
1300 |
$this->mpdf->_newobj();
|
|
|
1301 |
$p=($this->mpdf->compress) ? gzcompress($cb_on) : $cb_on;
|
|
|
1302 |
$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
|
|
|
1303 |
$this->mpdf->_putstream($p);
|
|
|
1304 |
$this->mpdf->_out('endobj');
|
|
|
1305 |
|
|
|
1306 |
// output appearance stream for check box off (only if not using ZapfDingbats)
|
|
|
1307 |
if (!$this->formUseZapD) {
|
|
|
1308 |
$this->mpdf->_newobj();
|
|
|
1309 |
$p=($this->mpdf->compress) ? gzcompress($cb_off) : $cb_off;
|
|
|
1310 |
$this->mpdf->_out('<<'.$filter.'/Length '.strlen($p).' /Resources 2 0 R>>');
|
|
|
1311 |
$this->mpdf->_putstream($p);
|
|
|
1312 |
$this->mpdf->_out('endobj');
|
|
|
1313 |
}
|
|
|
1314 |
|
|
|
1315 |
}
|
|
|
1316 |
return $n;
|
|
|
1317 |
}
|
|
|
1318 |
|
|
|
1319 |
|
|
|
1320 |
function _putform_ch( $form, $hPt ) {
|
|
|
1321 |
$put_js = 0;
|
|
|
1322 |
$this->mpdf->_newobj();
|
|
|
1323 |
$n = $this->mpdf->n;
|
|
|
1324 |
$this->pdf_acro_array .= $n.' 0 R ';
|
|
|
1325 |
$this->forms[ $form['n'] ]['obj'] = $n;
|
|
|
1326 |
|
|
|
1327 |
$this->mpdf->_out('<<');
|
|
|
1328 |
$this->mpdf->_out('/Type /Annot ');
|
|
|
1329 |
$this->mpdf->_out('/Subtype /Widget');
|
|
|
1330 |
$this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ]');
|
|
|
1331 |
$this->mpdf->_out('/F 4');
|
|
|
1332 |
$this->mpdf->_out('/FT /Ch');
|
|
|
1333 |
if ($form['Q']) $this->mpdf->_out('/Q '.$form['Q'].'');
|
|
|
1334 |
$temp = '';
|
|
|
1335 |
$temp .= '/W '.$form['BS_W'].' ';
|
|
|
1336 |
$temp .= '/S /'.$form['BS_S'].' ';
|
|
|
1337 |
$this->mpdf->_out("/BS << $temp >>");
|
|
|
1338 |
|
|
|
1339 |
$temp = '';
|
|
|
1340 |
$temp .= '/BC [ '.$form['BC_C']." ] ";
|
|
|
1341 |
$temp .= '/BG [ '.$form['BG_C']." ] ";
|
|
|
1342 |
$this->mpdf->_out('/MK << '.$temp.' >>');
|
|
|
1343 |
|
|
|
1344 |
$this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (6000 + $form['n']))));
|
|
|
1345 |
$this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis')));
|
|
|
1346 |
|
|
|
1347 |
$this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) );
|
|
|
1348 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
|
|
|
1349 |
|
|
|
1350 |
$opt = '';
|
|
|
1351 |
for( $i = 0; $i < count($form['OPT']['VAL']) ; $i++ ) {
|
|
|
1352 |
$opt .= '[ '.$this->mpdf->_textstring($form['OPT']['VAL'][$i]).' '.$this->mpdf->_textstring($form['OPT']['OPT'][$i]).' ] ';
|
|
|
1353 |
}
|
|
|
1354 |
$this->mpdf->_out('/Opt [ '.$opt.']');
|
|
|
1355 |
|
|
|
1356 |
// selected
|
|
|
1357 |
$selectItem = false;
|
|
|
1358 |
$selectIndex = false;
|
|
|
1359 |
foreach ( $form['OPT']['SEL'] as $selectKey => $selectVal ) {
|
|
|
1360 |
$selectName = $this->mpdf->_textstring($form['OPT']['VAL'][$selectVal]);
|
|
|
1361 |
$selectItem .= ' '.$selectName.' ';
|
|
|
1362 |
$selectIndex .= ' '.$selectVal.' ';
|
|
|
1363 |
}
|
|
|
1364 |
if ( $selectItem ) {
|
|
|
1365 |
if (count($form['OPT']['SEL']) < 2) {
|
|
|
1366 |
$this->mpdf->_out('/V '.$selectItem.' ');
|
|
|
1367 |
$this->mpdf->_out('/DV '.$selectItem.' ');
|
|
|
1368 |
}
|
|
|
1369 |
else {
|
|
|
1370 |
$this->mpdf->_out('/V ['.$selectItem.'] ');
|
|
|
1371 |
$this->mpdf->_out('/DV ['.$selectItem.'] ');
|
|
|
1372 |
}
|
|
|
1373 |
$this->mpdf->_out('/I ['.$selectIndex.'] ');
|
|
|
1374 |
}
|
|
|
1375 |
|
|
|
1376 |
if ( is_array($form['FF']) && count($form['FF'])>0 ) {
|
|
|
1377 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' ');
|
|
|
1378 |
}
|
|
|
1379 |
// Javascript
|
|
|
1380 |
if ( isset($this->array_form_choice_js[$form['T']]) ) {
|
|
|
1381 |
$this->mpdf->_out("/AA << /V ".($this->mpdf->n+1)." 0 R >>");
|
|
|
1382 |
$put_js = 1;
|
|
|
1383 |
}
|
|
|
1384 |
|
|
|
1385 |
$this->mpdf->_out('>>');
|
|
|
1386 |
$this->mpdf->_out('endobj');
|
|
|
1387 |
// obj + 1
|
|
|
1388 |
if ( $put_js == 1 ) {
|
|
|
1389 |
$this->mpdf->_set_object_javascript( $this->array_form_choice_js[$form['T']]['js'] );
|
|
|
1390 |
unset( $this->array_form_choice_js[$form['T']] );
|
|
|
1391 |
$put_js = NULL;
|
|
|
1392 |
}
|
|
|
1393 |
|
|
|
1394 |
return $n;
|
|
|
1395 |
}
|
|
|
1396 |
|
|
|
1397 |
|
|
|
1398 |
function _putform_tx( $form, $hPt ) {
|
|
|
1399 |
$put_js = 0;
|
|
|
1400 |
$this->mpdf->_newobj();
|
|
|
1401 |
$n = $this->mpdf->n;
|
|
|
1402 |
$this->pdf_acro_array .= $n.' 0 R ';
|
|
|
1403 |
$this->forms[ $form['n'] ]['obj'] = $n;
|
|
|
1404 |
|
|
|
1405 |
$this->mpdf->_out('<<');
|
|
|
1406 |
$this->mpdf->_out('/Type /Annot ');
|
|
|
1407 |
$this->mpdf->_out('/Subtype /Widget ');
|
|
|
1408 |
|
|
|
1409 |
$this->mpdf->_out('/Rect [ '.$this->_form_rect($form['x'],$form['y'],$form['w'],$form['h'], $hPt).' ] ');
|
|
|
1410 |
$form['hidden'] ? $this->mpdf->_out('/F 2 ') : $this->mpdf->_out('/F 4 ');
|
|
|
1411 |
$this->mpdf->_out('/FT /Tx ');
|
|
|
1412 |
|
|
|
1413 |
$this->mpdf->_out('/H /N ');
|
|
|
1414 |
$this->mpdf->_out('/R 0 ');
|
|
|
1415 |
|
|
|
1416 |
if ( is_array($form['FF']) && count($form['FF'])>0 ) {
|
|
|
1417 |
$this->mpdf->_out('/Ff '.$this->_setflag($form['FF']).' ');
|
|
|
1418 |
}
|
|
|
1419 |
if ( isset($form['maxlen']) && $form['maxlen']>0 ) {
|
|
|
1420 |
$this->mpdf->_out('/MaxLen '.$form['maxlen']);
|
|
|
1421 |
}
|
|
|
1422 |
|
|
|
1423 |
$temp = '';
|
|
|
1424 |
$temp .= '/W '.$form['BS_W'].' ';
|
|
|
1425 |
$temp .= '/S /'.$form['BS_S'].' ';
|
|
|
1426 |
$this->mpdf->_out("/BS << $temp >>");
|
|
|
1427 |
|
|
|
1428 |
$temp = '';
|
|
|
1429 |
$temp .= '/BC [ '.$form['BC_C']." ] ";
|
|
|
1430 |
$temp .= '/BG [ '.$form['BG_C']." ] ";
|
|
|
1431 |
$this->mpdf->_out('/MK <<'.$temp.' >>');
|
|
|
1432 |
|
|
|
1433 |
$this->mpdf->_out('/T '.$this->mpdf->_textstring($form['T']) );
|
|
|
1434 |
$this->mpdf->_out('/TU '.$this->mpdf->_textstring($form['TU']) );
|
|
|
1435 |
if ($form['V'] || $form['V']==='0')
|
|
|
1436 |
$this->mpdf->_out('/V '.$this->mpdf->_textstring($form['V']) );
|
|
|
1437 |
$this->mpdf->_out('/DV '.$this->mpdf->_textstring($form['DV']) );
|
|
|
1438 |
$this->mpdf->_out('/DA (/F'.$this->mpdf->fonts[$form['style']['font']]['i'].' '.$form['style']['fontsize'].' Tf '.$form['style']['fontcolor'].')');
|
|
|
1439 |
if ( $form['Q'] ) $this->mpdf->_out('/Q '.$form['Q'].'');
|
|
|
1440 |
|
|
|
1441 |
$this->mpdf->_out('/NM '.$this->mpdf->_textstring(sprintf('%04u-%04u', $n, (5000 + $form['n']))));
|
|
|
1442 |
$this->mpdf->_out('/M '.$this->mpdf->_textstring('D:'.date('YmdHis')));
|
|
|
1443 |
|
|
|
1444 |
|
|
|
1445 |
if ( isset($this->array_form_text_js[$form['T']]) ) {
|
|
|
1446 |
$put_js = 1;
|
|
|
1447 |
$cc = 0;
|
|
|
1448 |
$js_str = '';
|
|
|
1449 |
|
|
|
1450 |
if ( isset($this->array_form_text_js[$form['T']]['F']) ) {
|
|
|
1451 |
$cc++;
|
|
|
1452 |
$js_str .= '/F '.($cc + $this->mpdf->n).' 0 R ';
|
|
|
1453 |
}
|
|
|
1454 |
if ( isset($this->array_form_text_js[$form['T']]['K']) ) {
|
|
|
1455 |
$cc++;
|
|
|
1456 |
$js_str .= '/K '.($cc + $this->mpdf->n).' 0 R ';
|
|
|
1457 |
}
|
|
|
1458 |
if ( isset($this->array_form_text_js[$form['T']]['V']) ) {
|
|
|
1459 |
$cc++;
|
|
|
1460 |
$js_str .= '/V '.($cc + $this->mpdf->n).' 0 R ';
|
|
|
1461 |
}
|
|
|
1462 |
if ( isset($this->array_form_text_js[$form['T']]['C']) ) {
|
|
|
1463 |
$cc++;
|
|
|
1464 |
$js_str .= '/C '.($cc + $this->mpdf->n).' 0 R ';
|
|
|
1465 |
$this->pdf_array_co .= $this->mpdf->n.' 0 R ';
|
|
|
1466 |
}
|
|
|
1467 |
$this->mpdf->_out('/AA << '.$js_str.' >>');
|
|
|
1468 |
}
|
|
|
1469 |
|
|
|
1470 |
$this->mpdf->_out('>>');
|
|
|
1471 |
$this->mpdf->_out('endobj');
|
|
|
1472 |
|
|
|
1473 |
if ( $put_js == 1 ) {
|
|
|
1474 |
if ( isset($this->array_form_text_js[$form['T']]['F']) ) {
|
|
|
1475 |
$this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['F']['js'] );
|
|
|
1476 |
unset( $this->array_form_text_js[$form['T']]['F'] );
|
|
|
1477 |
}
|
|
|
1478 |
if ( isset($this->array_form_text_js[$form['T']]['K']) ) {
|
|
|
1479 |
$this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['K']['js'] );
|
|
|
1480 |
unset( $this->array_form_text_js[$form['T']]['K'] );
|
|
|
1481 |
}
|
|
|
1482 |
if ( isset($this->array_form_text_js[$form['T']]['V']) ) {
|
|
|
1483 |
$this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['V']['js'] );
|
|
|
1484 |
unset( $this->array_form_text_js[$form['T']]['V'] );
|
|
|
1485 |
}
|
|
|
1486 |
if ( isset($this->array_form_text_js[$form['T']]['C']) ) {
|
|
|
1487 |
$this->mpdf->_set_object_javascript( $this->array_form_text_js[$form['T']]['C']['js'] );
|
|
|
1488 |
unset( $this->array_form_text_js[$form['T']]['C'] );
|
|
|
1489 |
}
|
|
|
1490 |
}
|
|
|
1491 |
return $n;
|
|
|
1492 |
}
|
|
|
1493 |
|
|
|
1494 |
|
|
|
1495 |
|
|
|
1496 |
}
|
|
|
1497 |
|
|
|
1498 |
?>
|