mpdfform.php 67 KB

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