Gravity PDF - Version 3.7.5

Version Description

  • Housekeeping - Tweak mPDF package to be PHP7 compatible.
Download this release

Release Info

Developer Blue Liquid Designs
Plugin Icon 128x128 Gravity PDF
Version 3.7.5
Comparing to
See all releases

Code changes from version 3.7.4 to 3.7.5

LICENSE DELETED
@@ -1,339 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
- Preamble
10
-
11
- The licenses for most software are designed to take away your
12
- freedom to share and change it. By contrast, the GNU General Public
13
- License is intended to guarantee your freedom to share and change free
14
- software--to make sure the software is free for all its users. This
15
- General Public License applies to most of the Free Software
16
- Foundation's software and to any other program whose authors commit to
17
- using it. (Some other Free Software Foundation software is covered by
18
- the GNU Lesser General Public License instead.) You can apply it to
19
- your programs, too.
20
-
21
- When we speak of free software, we are referring to freedom, not
22
- price. Our General Public Licenses are designed to make sure that you
23
- have the freedom to distribute copies of free software (and charge for
24
- this service if you wish), that you receive source code or can get it
25
- if you want it, that you can change the software or use pieces of it
26
- in new free programs; and that you know you can do these things.
27
-
28
- To protect your rights, we need to make restrictions that forbid
29
- anyone to deny you these rights or to ask you to surrender the rights.
30
- These restrictions translate to certain responsibilities for you if you
31
- distribute copies of the software, or if you modify it.
32
-
33
- For example, if you distribute copies of such a program, whether
34
- gratis or for a fee, you must give the recipients all the rights that
35
- you have. You must make sure that they, too, receive or can get the
36
- source code. And you must show them these terms so they know their
37
- rights.
38
-
39
- We protect your rights with two steps: (1) copyright the software, and
40
- (2) offer you this license which gives you legal permission to copy,
41
- distribute and/or modify the software.
42
-
43
- Also, for each author's protection and ours, we want to make certain
44
- that everyone understands that there is no warranty for this free
45
- software. If the software is modified by someone else and passed on, we
46
- want its recipients to know that what they have is not the original, so
47
- that any problems introduced by others will not reflect on the original
48
- authors' reputations.
49
-
50
- Finally, any free program is threatened constantly by software
51
- patents. We wish to avoid the danger that redistributors of a free
52
- program will individually obtain patent licenses, in effect making the
53
- program proprietary. To prevent this, we have made it clear that any
54
- patent must be licensed for everyone's free use or not licensed at all.
55
-
56
- The precise terms and conditions for copying, distribution and
57
- modification follow.
58
-
59
- GNU GENERAL PUBLIC LICENSE
60
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
-
62
- 0. This License applies to any program or other work which contains
63
- a notice placed by the copyright holder saying it may be distributed
64
- under the terms of this General Public License. The "Program", below,
65
- refers to any such program or work, and a "work based on the Program"
66
- means either the Program or any derivative work under copyright law:
67
- that is to say, a work containing the Program or a portion of it,
68
- either verbatim or with modifications and/or translated into another
69
- language. (Hereinafter, translation is included without limitation in
70
- the term "modification".) Each licensee is addressed as "you".
71
-
72
- Activities other than copying, distribution and modification are not
73
- covered by this License; they are outside its scope. The act of
74
- running the Program is not restricted, and the output from the Program
75
- is covered only if its contents constitute a work based on the
76
- Program (independent of having been made by running the Program).
77
- Whether that is true depends on what the Program does.
78
-
79
- 1. You may copy and distribute verbatim copies of the Program's
80
- source code as you receive it, in any medium, provided that you
81
- conspicuously and appropriately publish on each copy an appropriate
82
- copyright notice and disclaimer of warranty; keep intact all the
83
- notices that refer to this License and to the absence of any warranty;
84
- and give any other recipients of the Program a copy of this License
85
- along with the Program.
86
-
87
- You may charge a fee for the physical act of transferring a copy, and
88
- you may at your option offer warranty protection in exchange for a fee.
89
-
90
- 2. You may modify your copy or copies of the Program or any portion
91
- of it, thus forming a work based on the Program, and copy and
92
- distribute such modifications or work under the terms of Section 1
93
- above, provided that you also meet all of these conditions:
94
-
95
- a) You must cause the modified files to carry prominent notices
96
- stating that you changed the files and the date of any change.
97
-
98
- b) You must cause any work that you distribute or publish, that in
99
- whole or in part contains or is derived from the Program or any
100
- part thereof, to be licensed as a whole at no charge to all third
101
- parties under the terms of this License.
102
-
103
- c) If the modified program normally reads commands interactively
104
- when run, you must cause it, when started running for such
105
- interactive use in the most ordinary way, to print or display an
106
- announcement including an appropriate copyright notice and a
107
- notice that there is no warranty (or else, saying that you provide
108
- a warranty) and that users may redistribute the program under
109
- these conditions, and telling the user how to view a copy of this
110
- License. (Exception: if the Program itself is interactive but
111
- does not normally print such an announcement, your work based on
112
- the Program is not required to print an announcement.)
113
-
114
- These requirements apply to the modified work as a whole. If
115
- identifiable sections of that work are not derived from the Program,
116
- and can be reasonably considered independent and separate works in
117
- themselves, then this License, and its terms, do not apply to those
118
- sections when you distribute them as separate works. But when you
119
- distribute the same sections as part of a whole which is a work based
120
- on the Program, the distribution of the whole must be on the terms of
121
- this License, whose permissions for other licensees extend to the
122
- entire whole, and thus to each and every part regardless of who wrote it.
123
-
124
- Thus, it is not the intent of this section to claim rights or contest
125
- your rights to work written entirely by you; rather, the intent is to
126
- exercise the right to control the distribution of derivative or
127
- collective works based on the Program.
128
-
129
- In addition, mere aggregation of another work not based on the Program
130
- with the Program (or with a work based on the Program) on a volume of
131
- a storage or distribution medium does not bring the other work under
132
- the scope of this License.
133
-
134
- 3. You may copy and distribute the Program (or a work based on it,
135
- under Section 2) in object code or executable form under the terms of
136
- Sections 1 and 2 above provided that you also do one of the following:
137
-
138
- a) Accompany it with the complete corresponding machine-readable
139
- source code, which must be distributed under the terms of Sections
140
- 1 and 2 above on a medium customarily used for software interchange; or,
141
-
142
- b) Accompany it with a written offer, valid for at least three
143
- years, to give any third party, for a charge no more than your
144
- cost of physically performing source distribution, a complete
145
- machine-readable copy of the corresponding source code, to be
146
- distributed under the terms of Sections 1 and 2 above on a medium
147
- customarily used for software interchange; or,
148
-
149
- c) Accompany it with the information you received as to the offer
150
- to distribute corresponding source code. (This alternative is
151
- allowed only for noncommercial distribution and only if you
152
- received the program in object code or executable form with such
153
- an offer, in accord with Subsection b above.)
154
-
155
- The source code for a work means the preferred form of the work for
156
- making modifications to it. For an executable work, complete source
157
- code means all the source code for all modules it contains, plus any
158
- associated interface definition files, plus the scripts used to
159
- control compilation and installation of the executable. However, as a
160
- special exception, the source code distributed need not include
161
- anything that is normally distributed (in either source or binary
162
- form) with the major components (compiler, kernel, and so on) of the
163
- operating system on which the executable runs, unless that component
164
- itself accompanies the executable.
165
-
166
- If distribution of executable or object code is made by offering
167
- access to copy from a designated place, then offering equivalent
168
- access to copy the source code from the same place counts as
169
- distribution of the source code, even though third parties are not
170
- compelled to copy the source along with the object code.
171
-
172
- 4. You may not copy, modify, sublicense, or distribute the Program
173
- except as expressly provided under this License. Any attempt
174
- otherwise to copy, modify, sublicense or distribute the Program is
175
- void, and will automatically terminate your rights under this License.
176
- However, parties who have received copies, or rights, from you under
177
- this License will not have their licenses terminated so long as such
178
- parties remain in full compliance.
179
-
180
- 5. You are not required to accept this License, since you have not
181
- signed it. However, nothing else grants you permission to modify or
182
- distribute the Program or its derivative works. These actions are
183
- prohibited by law if you do not accept this License. Therefore, by
184
- modifying or distributing the Program (or any work based on the
185
- Program), you indicate your acceptance of this License to do so, and
186
- all its terms and conditions for copying, distributing or modifying
187
- the Program or works based on it.
188
-
189
- 6. Each time you redistribute the Program (or any work based on the
190
- Program), the recipient automatically receives a license from the
191
- original licensor to copy, distribute or modify the Program subject to
192
- these terms and conditions. You may not impose any further
193
- restrictions on the recipients' exercise of the rights granted herein.
194
- You are not responsible for enforcing compliance by third parties to
195
- this License.
196
-
197
- 7. If, as a consequence of a court judgment or allegation of patent
198
- infringement or for any other reason (not limited to patent issues),
199
- conditions are imposed on you (whether by court order, agreement or
200
- otherwise) that contradict the conditions of this License, they do not
201
- excuse you from the conditions of this License. If you cannot
202
- distribute so as to satisfy simultaneously your obligations under this
203
- License and any other pertinent obligations, then as a consequence you
204
- may not distribute the Program at all. For example, if a patent
205
- license would not permit royalty-free redistribution of the Program by
206
- all those who receive copies directly or indirectly through you, then
207
- the only way you could satisfy both it and this License would be to
208
- refrain entirely from distribution of the Program.
209
-
210
- If any portion of this section is held invalid or unenforceable under
211
- any particular circumstance, the balance of the section is intended to
212
- apply and the section as a whole is intended to apply in other
213
- circumstances.
214
-
215
- It is not the purpose of this section to induce you to infringe any
216
- patents or other property right claims or to contest validity of any
217
- such claims; this section has the sole purpose of protecting the
218
- integrity of the free software distribution system, which is
219
- implemented by public license practices. Many people have made
220
- generous contributions to the wide range of software distributed
221
- through that system in reliance on consistent application of that
222
- system; it is up to the author/donor to decide if he or she is willing
223
- to distribute software through any other system and a licensee cannot
224
- impose that choice.
225
-
226
- This section is intended to make thoroughly clear what is believed to
227
- be a consequence of the rest of this License.
228
-
229
- 8. If the distribution and/or use of the Program is restricted in
230
- certain countries either by patents or by copyrighted interfaces, the
231
- original copyright holder who places the Program under this License
232
- may add an explicit geographical distribution limitation excluding
233
- those countries, so that distribution is permitted only in or among
234
- countries not thus excluded. In such case, this License incorporates
235
- the limitation as if written in the body of this License.
236
-
237
- 9. The Free Software Foundation may publish revised and/or new versions
238
- of the General Public License from time to time. Such new versions will
239
- be similar in spirit to the present version, but may differ in detail to
240
- address new problems or concerns.
241
-
242
- Each version is given a distinguishing version number. If the Program
243
- specifies a version number of this License which applies to it and "any
244
- later version", you have the option of following the terms and conditions
245
- either of that version or of any later version published by the Free
246
- Software Foundation. If the Program does not specify a version number of
247
- this License, you may choose any version ever published by the Free Software
248
- Foundation.
249
-
250
- 10. If you wish to incorporate parts of the Program into other free
251
- programs whose distribution conditions are different, write to the author
252
- to ask for permission. For software which is copyrighted by the Free
253
- Software Foundation, write to the Free Software Foundation; we sometimes
254
- make exceptions for this. Our decision will be guided by the two goals
255
- of preserving the free status of all derivatives of our free software and
256
- of promoting the sharing and reuse of software generally.
257
-
258
- NO WARRANTY
259
-
260
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
- REPAIR OR CORRECTION.
269
-
270
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
- POSSIBILITY OF SUCH DAMAGES.
279
-
280
- END OF TERMS AND CONDITIONS
281
-
282
- How to Apply These Terms to Your New Programs
283
-
284
- If you develop a new program, and you want it to be of the greatest
285
- possible use to the public, the best way to achieve this is to make it
286
- free software which everyone can redistribute and change under these terms.
287
-
288
- To do so, attach the following notices to the program. It is safest
289
- to attach them to the start of each source file to most effectively
290
- convey the exclusion of warranty; and each file should have at least
291
- the "copyright" line and a pointer to where the full notice is found.
292
-
293
- {description}
294
- Copyright (C) {year} {fullname}
295
-
296
- This program is free software; you can redistribute it and/or modify
297
- it under the terms of the GNU General Public License as published by
298
- the Free Software Foundation; either version 2 of the License, or
299
- (at your option) any later version.
300
-
301
- This program is distributed in the hope that it will be useful,
302
- but WITHOUT ANY WARRANTY; without even the implied warranty of
303
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
- GNU General Public License for more details.
305
-
306
- You should have received a copy of the GNU General Public License along
307
- with this program; if not, write to the Free Software Foundation, Inc.,
308
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
-
310
- Also add information on how to contact you by electronic and paper mail.
311
-
312
- If the program is interactive, make it output a short notice like this
313
- when it starts in an interactive mode:
314
-
315
- Gnomovision version 69, Copyright (C) year name of author
316
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
- This is free software, and you are welcome to redistribute it
318
- under certain conditions; type `show c' for details.
319
-
320
- The hypothetical commands `show w' and `show c' should show the appropriate
321
- parts of the General Public License. Of course, the commands you use may
322
- be called something other than `show w' and `show c'; they could even be
323
- mouse-clicks or menu items--whatever suits your program.
324
-
325
- You should also get your employer (if you work as a programmer) or your
326
- school, if any, to sign a "copyright disclaimer" for the program, if
327
- necessary. Here is a sample; alter the names:
328
-
329
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
-
332
- {signature of Ty Coon}, 1 April 1989
333
- Ty Coon, President of Vice
334
-
335
- This General Public License does not permit incorporating your program into
336
- proprietary programs. If your program is a subroutine library, you may
337
- consider it more useful to permit linking proprietary applications with the
338
- library. If this is what you want to do, use the GNU Lesser General
339
- Public License instead of this License.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: blueliquiddesigns
3
  Donate link: https://gravitypdf.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
- Tested up to: 4.2
7
- Stable tag: 3.7.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
@@ -86,8 +86,11 @@ All FAQs can be [viewed on the Gravity PDF website](https://gravitypdf.com/#faqs
86
 
87
  == Changelog ==
88
 
 
 
 
89
  = 3.7.4 =
90
- * Housekpeeing - Revert patch made in last update as Gravity Forms 1.9.9 fixes the issue internally.
91
 
92
  = 3.7.3 =
93
  * Bug - Gravity Forms 1.9 didn't automatically nl2br paragraph text mergetags. Fixed this issue in custom PDF templates.
3
  Donate link: https://gravitypdf.com
4
  Tags: gravity, forms, pdf, automation, attachment
5
  Requires at least: 3.9
6
+ Tested up to: 4.4
7
+ Stable tag: 3.7.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl.txt
10
 
86
 
87
  == Changelog ==
88
 
89
+ = 3.7.5 =
90
+ * Housekeeping - Tweak mPDF package to be PHP7 compatible.
91
+
92
  = 3.7.4 =
93
+ * Housekeeping - Revert patch made in last update as Gravity Forms 1.9.9 fixes the issue internally.
94
 
95
  = 3.7.3 =
96
  * Bug - Gravity Forms 1.9 didn't automatically nl2br paragraph text mergetags. Fixed this issue in custom PDF templates.
mPDF/classes/barcode.php CHANGED
@@ -10,24 +10,24 @@
10
  // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
11
  // ----------------------------------------------------------------------------
12
  // Copyright (C) 2008-2009 Nicola Asuni - Tecnick.com S.r.l.
13
- //
14
  // This program is free software: you can redistribute it and/or modify
15
  // it under the terms of the GNU Lesser General Public License as published by
16
  // the Free Software Foundation, either version 2.1 of the License, or
17
  // (at your option) any later version.
18
- //
19
  // This program is distributed in the hope that it will be useful,
20
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
  // GNU Lesser General Public License for more details.
23
- //
24
  // You should have received a copy of the GNU Lesser General Public License
25
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
26
- //
27
  // See LICENSE.TXT file for more information.
28
  // ----------------------------------------------------------------------------
29
  //
30
- // Description : PHP class to creates array representations for
31
  // common 1D barcodes to be used with TCPDF.
32
  //
33
  // Author: Nicola Asuni
@@ -123,11 +123,11 @@ class PDFBarcode {
123
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
124
  $bpi = 22; // Bars per inch
125
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
126
- $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
127
  $this->daft = array('D'=>2, 'A'=>2, 'F'=>3, 'T'=>1); // Descender; Ascender; Full; Tracker bar heights
128
  $arrcode = $this->barcode_imb($code);
129
  $arrcode['nom-X'] = $xdim ;
130
- $arrcode['nom-H'] = 3.68; // Nominal value for Height of Full bar in mm (spec.)
131
  // USPS-B-3200 Revision C = 4.623
132
  // USPS-B-3200 Revision E = 3.68
133
  $arrcode['quietL'] = 3.175; // LEFT Quiet margin = mm (spec.)
@@ -139,7 +139,7 @@ class PDFBarcode {
139
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
140
  $bpi = 22; // Bars per inch
141
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
142
- $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
143
  $this->daft = array('D'=>5, 'A'=>5, 'F'=>8, 'T'=>2); // Descender; Ascender; Full; Tracker bar heights
144
  $arrcode = $this->barcode_rm4scc($code, false);
145
  $arrcode['nom-X'] = $xdim ;
@@ -153,7 +153,7 @@ class PDFBarcode {
153
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
154
  $bpi = 22; // Bars per inch
155
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
156
- $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
157
  $this->daft = array('D'=>5, 'A'=>5, 'F'=>8, 'T'=>2); // Descender; Ascender; Full; Tracker bar heights
158
  $arrcode = $this->barcode_rm4scc($code, true);
159
  $arrcode['nom-X'] = $xdim ;
@@ -167,7 +167,7 @@ class PDFBarcode {
167
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
168
  $bpi = 22; // Bars per inch
169
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
170
- $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
171
  $arrcode = $this->barcode_postnet($code, false);
172
  $arrcode['nom-X'] = $xdim ;
173
  $arrcode['nom-H'] = 3.175; // Nominal value for Height of Full bar in mm (spec.)
@@ -180,7 +180,7 @@ class PDFBarcode {
180
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
181
  $bpi = 22; // Bars per inch
182
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
183
- $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
184
  $arrcode = $this->barcode_postnet($code, true);
185
  $arrcode['nom-X'] = $xdim ;
186
  $arrcode['nom-H'] = 3.175; // Nominal value for Height of Full bar in mm (spec.)
@@ -611,7 +611,7 @@ class PDFBarcode {
611
  }
612
  $bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0);
613
  $bararray['maxw'] += 1;
614
- ++$k;
615
  $bararray['checkdigit'] = $checkdigit;
616
  return $bararray;
617
  }
@@ -626,7 +626,7 @@ class PDFBarcode {
626
  'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
627
  'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
628
  // translate special characters
629
- $code = strtr($code, chr(128).chr(129).chr(130).chr(131), '$/+%');
630
  $len = strlen($code);
631
  // calculate check digit C
632
  $p = 1;
@@ -680,7 +680,7 @@ class PDFBarcode {
680
 
681
  /**
682
  * MSI.
683
- * Variation of Plessey code, with similar applications
684
  * Contains digits (0 to 9) and encodes the data only in the width of bars.
685
  */
686
  protected function barcode_msi($code, $checksum=false) {
@@ -728,7 +728,7 @@ class PDFBarcode {
728
  return false;
729
  }
730
  $seq .= $chr[$digit];
731
- }
732
  $seq .= '1001'; // right guard
733
  $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
734
  $bararray['checkdigit'] = $checkdigit;
@@ -769,7 +769,7 @@ class PDFBarcode {
769
  return false;
770
  }
771
  $seq .= $chr[$digit];
772
- }
773
  $seq .= '1101011';
774
  $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
775
  $bararray['checkdigit'] = $checkdigit;
@@ -867,7 +867,7 @@ class PDFBarcode {
867
  }
868
 
869
  /**
870
- * C128 barcodes.
871
  * Very capable code, excellent density, high reliability; in very wide use world-wide
872
  */
873
  protected function barcode_c128($code, $type='B', $ean=false) {
@@ -1059,7 +1059,7 @@ class PDFBarcode {
1059
  }
1060
  }
1061
  $bararray['checkdigit'] = $checkdigit;
1062
- return $bararray;
1063
  }
1064
 
1065
  /**
@@ -1322,7 +1322,7 @@ class PDFBarcode {
1322
  '7'=>array('A','B','A','B','A'),
1323
  '8'=>array('A','B','A','A','B'),
1324
  '9'=>array('A','A','B','A','B')
1325
- );
1326
  $p = $parities[$len][$r];
1327
  $seq = '1011'; // left guard bar
1328
  $seq .= $codes[$p[0]][$code{0}];
@@ -1392,11 +1392,11 @@ class PDFBarcode {
1392
  for ($j = 0; $j < 5; ++$j) {
1393
  $bh = $barlen[$code[$i]][$j];
1394
  if ($bh == 2) {
1395
- $h = 5;
1396
  $p = 0;
1397
  }
1398
  else {
1399
- $h = 2;
1400
  $p = 3;
1401
  }
1402
  $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
@@ -1459,7 +1459,7 @@ class PDFBarcode {
1459
  'W' => array(1,2,4,3),
1460
  'X' => array(2,1,3,4),
1461
  'Y' => array(2,1,4,3),
1462
- 'Z' => array(2,2,3,3)
1463
  );
1464
  $code = strtoupper($code);
1465
  $len = strlen($code);
@@ -1665,7 +1665,7 @@ class PDFBarcode {
1665
  $check %= 11;
1666
  if ($check == 10) {
1667
  $check = '-';
1668
- }
1669
  $code .= $check;
1670
  $checkdigit = $check;
1671
  if ($len > 10) {
@@ -1718,7 +1718,7 @@ class PDFBarcode {
1718
 
1719
  /**
1720
  * IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
1721
- * (requires PHP bcmath extension)
1722
  * Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
1723
  * The fields are described as follows:<ul><li>The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0-4. The allowable encoding ranges shall be 00-04, 10-14, 20-24, 30-34, 40-44, 50-54, 60-64, 70-74, 80-84, and 90-94.</li><li>The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000-999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.</li><li>The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.</li><li>The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000-999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000-99999, 000000000-999999999, and 00000000000-99999999999.</li></ul>
1724
  */
@@ -1843,7 +1843,7 @@ class PDFBarcode {
1843
 
1844
  /**
1845
  * Convert large integer number to hexadecimal representation.
1846
- * (requires PHP bcmath extension)
1847
  */
1848
  public function dec_to_hex($number) {
1849
  $i = 0;
@@ -1865,7 +1865,7 @@ class PDFBarcode {
1865
 
1866
  /**
1867
  * Convert large hexadecimal number to decimal representation (string).
1868
- * (requires PHP bcmath extension)
1869
  */
1870
  public function hex_to_dec($hex) {
1871
  $dec = 0;
@@ -1876,7 +1876,7 @@ class PDFBarcode {
1876
  $bitval = bcmul($bitval, 16);
1877
  }
1878
  return $dec;
1879
- }
1880
 
1881
  /**
1882
  * Intelligent Mail Barcode calculation of Frame Check Sequence
@@ -1908,7 +1908,7 @@ class PDFBarcode {
1908
  $data <<= 1;
1909
  }
1910
  }
1911
- return $fcs;
1912
  }
1913
 
1914
  /**
@@ -1961,6 +1961,5 @@ class PDFBarcode {
1961
  } // end of class
1962
 
1963
  //============================================================+
1964
- // END OF FILE
1965
  //============================================================+
1966
- ?>
10
  // License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
11
  // ----------------------------------------------------------------------------
12
  // Copyright (C) 2008-2009 Nicola Asuni - Tecnick.com S.r.l.
13
+ //
14
  // This program is free software: you can redistribute it and/or modify
15
  // it under the terms of the GNU Lesser General Public License as published by
16
  // the Free Software Foundation, either version 2.1 of the License, or
17
  // (at your option) any later version.
18
+ //
19
  // This program is distributed in the hope that it will be useful,
20
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
  // GNU Lesser General Public License for more details.
23
+ //
24
  // You should have received a copy of the GNU Lesser General Public License
25
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
26
+ //
27
  // See LICENSE.TXT file for more information.
28
  // ----------------------------------------------------------------------------
29
  //
30
+ // Description : PHP class to creates array representations for
31
  // common 1D barcodes to be used with TCPDF.
32
  //
33
  // Author: Nicola Asuni
123
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
124
  $bpi = 22; // Bars per inch
125
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
126
+ $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
127
  $this->daft = array('D'=>2, 'A'=>2, 'F'=>3, 'T'=>1); // Descender; Ascender; Full; Tracker bar heights
128
  $arrcode = $this->barcode_imb($code);
129
  $arrcode['nom-X'] = $xdim ;
130
+ $arrcode['nom-H'] = 3.68; // Nominal value for Height of Full bar in mm (spec.)
131
  // USPS-B-3200 Revision C = 4.623
132
  // USPS-B-3200 Revision E = 3.68
133
  $arrcode['quietL'] = 3.175; // LEFT Quiet margin = mm (spec.)
139
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
140
  $bpi = 22; // Bars per inch
141
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
142
+ $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
143
  $this->daft = array('D'=>5, 'A'=>5, 'F'=>8, 'T'=>2); // Descender; Ascender; Full; Tracker bar heights
144
  $arrcode = $this->barcode_rm4scc($code, false);
145
  $arrcode['nom-X'] = $xdim ;
153
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
154
  $bpi = 22; // Bars per inch
155
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
156
+ $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
157
  $this->daft = array('D'=>5, 'A'=>5, 'F'=>8, 'T'=>2); // Descender; Ascender; Full; Tracker bar heights
158
  $arrcode = $this->barcode_rm4scc($code, true);
159
  $arrcode['nom-X'] = $xdim ;
167
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
168
  $bpi = 22; // Bars per inch
169
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
170
+ $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
171
  $arrcode = $this->barcode_postnet($code, false);
172
  $arrcode['nom-X'] = $xdim ;
173
  $arrcode['nom-H'] = 3.175; // Nominal value for Height of Full bar in mm (spec.)
180
  $xdim = 0.508; // Nominal value for X-dim (bar width) in mm (spec.)
181
  $bpi = 22; // Bars per inch
182
  // Ratio of Nominal value for width of spaces in mm / Nominal value for X-dim (bar width) in mm based on bars per inch
183
+ $this->gapwidth = ((25.4/$bpi) - $xdim)/$xdim;
184
  $arrcode = $this->barcode_postnet($code, true);
185
  $arrcode['nom-X'] = $xdim ;
186
  $arrcode['nom-H'] = 3.175; // Nominal value for Height of Full bar in mm (spec.)
611
  }
612
  $bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0);
613
  $bararray['maxw'] += 1;
614
+ ++$k;
615
  $bararray['checkdigit'] = $checkdigit;
616
  return $bararray;
617
  }
626
  'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
627
  'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
628
  // translate special characters
629
+ $code = strtr($code, chr(128).chr(129).chr(130).chr(131), '$/+%');
630
  $len = strlen($code);
631
  // calculate check digit C
632
  $p = 1;
680
 
681
  /**
682
  * MSI.
683
+ * Variation of Plessey code, with similar applications
684
  * Contains digits (0 to 9) and encodes the data only in the width of bars.
685
  */
686
  protected function barcode_msi($code, $checksum=false) {
728
  return false;
729
  }
730
  $seq .= $chr[$digit];
731
+ }
732
  $seq .= '1001'; // right guard
733
  $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
734
  $bararray['checkdigit'] = $checkdigit;
769
  return false;
770
  }
771
  $seq .= $chr[$digit];
772
+ }
773
  $seq .= '1101011';
774
  $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
775
  $bararray['checkdigit'] = $checkdigit;
867
  }
868
 
869
  /**
870
+ * C128 barcodes.
871
  * Very capable code, excellent density, high reliability; in very wide use world-wide
872
  */
873
  protected function barcode_c128($code, $type='B', $ean=false) {
1059
  }
1060
  }
1061
  $bararray['checkdigit'] = $checkdigit;
1062
+ return $bararray;
1063
  }
1064
 
1065
  /**
1322
  '7'=>array('A','B','A','B','A'),
1323
  '8'=>array('A','B','A','A','B'),
1324
  '9'=>array('A','A','B','A','B')
1325
+ );
1326
  $p = $parities[$len][$r];
1327
  $seq = '1011'; // left guard bar
1328
  $seq .= $codes[$p[0]][$code{0}];
1392
  for ($j = 0; $j < 5; ++$j) {
1393
  $bh = $barlen[$code[$i]][$j];
1394
  if ($bh == 2) {
1395
+ $h = 5;
1396
  $p = 0;
1397
  }
1398
  else {
1399
+ $h = 2;
1400
  $p = 3;
1401
  }
1402
  $bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
1459
  'W' => array(1,2,4,3),
1460
  'X' => array(2,1,3,4),
1461
  'Y' => array(2,1,4,3),
1462
+ 'Z' => array(2,2,3,3)
1463
  );
1464
  $code = strtoupper($code);
1465
  $len = strlen($code);
1665
  $check %= 11;
1666
  if ($check == 10) {
1667
  $check = '-';
1668
+ }
1669
  $code .= $check;
1670
  $checkdigit = $check;
1671
  if ($len > 10) {
1718
 
1719
  /**
1720
  * IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
1721
+ * (requires PHP bcmath extension)
1722
  * Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
1723
  * The fields are described as follows:<ul><li>The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0-4. The allowable encoding ranges shall be 00-04, 10-14, 20-24, 30-34, 40-44, 50-54, 60-64, 70-74, 80-84, and 90-94.</li><li>The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000-999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.</li><li>The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.</li><li>The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000-999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000-99999, 000000000-999999999, and 00000000000-99999999999.</li></ul>
1724
  */
1843
 
1844
  /**
1845
  * Convert large integer number to hexadecimal representation.
1846
+ * (requires PHP bcmath extension)
1847
  */
1848
  public function dec_to_hex($number) {
1849
  $i = 0;
1865
 
1866
  /**
1867
  * Convert large hexadecimal number to decimal representation (string).
1868
+ * (requires PHP bcmath extension)
1869
  */
1870
  public function hex_to_dec($hex) {
1871
  $dec = 0;
1876
  $bitval = bcmul($bitval, 16);
1877
  }
1878
  return $dec;
1879
+ }
1880
 
1881
  /**
1882
  * Intelligent Mail Barcode calculation of Frame Check Sequence
1908
  $data <<= 1;
1909
  }
1910
  }
1911
+ return $fcs;
1912
  }
1913
 
1914
  /**
1961
  } // end of class
1962
 
1963
  //============================================================+
1964
+ // END OF FILE
1965
  //============================================================+
 
mPDF/classes/bmp.php CHANGED
@@ -4,7 +4,7 @@ class bmp {
4
 
5
  var $mpdf = null;
6
 
7
- function bmp(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
@@ -19,7 +19,7 @@ function _getBMPimage($data, $file) {
19
  $flip = ($height<0);
20
  if ($flip) $height =-$height;
21
  $biBitCount=$this->_twobytes2int_le(substr($data,28,2));
22
- $biCompression=$this->_fourbytes2int_le(substr($data,30,4));
23
  $info = array('w'=>$width, 'h'=>$height);
24
  if ($biBitCount<16){
25
  $info['cs'] = 'Indexed';
@@ -40,14 +40,14 @@ function _getBMPimage($data, $file) {
40
 
41
  if ($this->mpdf->restrictColorSpace==1 || $this->mpdf->PDFX || $this->mpdf->restrictColorSpace==3) {
42
  if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $this->mpdf->PDFAXwarnings[] = "Image cannot be converted to suitable colour space for PDFA or PDFX file - ".$file." - (Image replaced by 'no-image'.)"; }
43
- return array('error' => "BMP Image cannot be converted to suitable colour space - ".$file." - (Image replaced by 'no-image'.)");
44
  }
45
 
46
  $biXPelsPerMeter=$this->_fourbytes2int_le(substr($data,38,4)); // horizontal pixels per meter, usually set to zero
47
  //$biYPelsPerMeter=$this->_fourbytes2int_le(substr($data,42,4)); // vertical pixels per meter, usually set to zero
48
  $biXPelsPerMeter=round($biXPelsPerMeter/1000 *25.4);
49
  //$biYPelsPerMeter=round($biYPelsPerMeter/1000 *25.4);
50
- $info['set-dpi'] = $biXPelsPerMeter;
51
 
52
  switch ($biCompression){
53
  case 0:
@@ -131,12 +131,12 @@ function _getBMPimage($data, $file) {
131
  break;
132
 
133
  default:
134
- return array('error' => 'Error parsing BMP image - Unsupported image biBitCount');
135
  }
136
  if ($this->mpdf->compress) {
137
  $bmpdata=gzcompress($bmpdata);
138
  $info['f']='FlateDecode';
139
- }
140
  $info['data']=$bmpdata;
141
  $info['type']='bmp';
142
  return $info;
@@ -194,7 +194,7 @@ function rle8_decode ($str, $width){
194
  # see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
195
  function rle4_decode ($str, $width){
196
  $w = floor($width/2) + ($width % 2);
197
- $lineWidth = $w + (3 - ( ($width-1) / 2) % 4);
198
  $pixels = array();
199
  $cnt = strlen($str);
200
  for ($i=0;$i<$cnt;$i++){
@@ -203,7 +203,7 @@ function rle4_decode ($str, $width){
203
  case 0: # ESCAPE
204
  $i++;
205
  switch (ord($str[$i])){
206
- case 0: # NEW LINE
207
  while (count($pixels)%$lineWidth!=0)
208
  $pixels[]=0;
209
  break;
@@ -239,10 +239,8 @@ function rle4_decode ($str, $width){
239
  for ($i=0;$i<$cnt;$i++)
240
  $out .= chr(16*$pixels[2*$i] + $pixels[2*$i+1]);
241
  return $out;
242
- }
243
 
244
 
245
 
246
  }
247
-
248
- ?>
4
 
5
  var $mpdf = null;
6
 
7
+ function __construct(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
19
  $flip = ($height<0);
20
  if ($flip) $height =-$height;
21
  $biBitCount=$this->_twobytes2int_le(substr($data,28,2));
22
+ $biCompression=$this->_fourbytes2int_le(substr($data,30,4));
23
  $info = array('w'=>$width, 'h'=>$height);
24
  if ($biBitCount<16){
25
  $info['cs'] = 'Indexed';
40
 
41
  if ($this->mpdf->restrictColorSpace==1 || $this->mpdf->PDFX || $this->mpdf->restrictColorSpace==3) {
42
  if (($this->mpdf->PDFA && !$this->mpdf->PDFAauto) || ($this->mpdf->PDFX && !$this->mpdf->PDFXauto)) { $this->mpdf->PDFAXwarnings[] = "Image cannot be converted to suitable colour space for PDFA or PDFX file - ".$file." - (Image replaced by 'no-image'.)"; }
43
+ return array('error' => "BMP Image cannot be converted to suitable colour space - ".$file." - (Image replaced by 'no-image'.)");
44
  }
45
 
46
  $biXPelsPerMeter=$this->_fourbytes2int_le(substr($data,38,4)); // horizontal pixels per meter, usually set to zero
47
  //$biYPelsPerMeter=$this->_fourbytes2int_le(substr($data,42,4)); // vertical pixels per meter, usually set to zero
48
  $biXPelsPerMeter=round($biXPelsPerMeter/1000 *25.4);
49
  //$biYPelsPerMeter=round($biYPelsPerMeter/1000 *25.4);
50
+ $info['set-dpi'] = $biXPelsPerMeter;
51
 
52
  switch ($biCompression){
53
  case 0:
131
  break;
132
 
133
  default:
134
+ return array('error' => 'Error parsing BMP image - Unsupported image biBitCount');
135
  }
136
  if ($this->mpdf->compress) {
137
  $bmpdata=gzcompress($bmpdata);
138
  $info['f']='FlateDecode';
139
+ }
140
  $info['data']=$bmpdata;
141
  $info['type']='bmp';
142
  return $info;
194
  # see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6x0u.asp
195
  function rle4_decode ($str, $width){
196
  $w = floor($width/2) + ($width % 2);
197
+ $lineWidth = $w + (3 - ( ($width-1) / 2) % 4);
198
  $pixels = array();
199
  $cnt = strlen($str);
200
  for ($i=0;$i<$cnt;$i++){
203
  case 0: # ESCAPE
204
  $i++;
205
  switch (ord($str[$i])){
206
+ case 0: # NEW LINE
207
  while (count($pixels)%$lineWidth!=0)
208
  $pixels[]=0;
209
  break;
239
  for ($i=0;$i<$cnt;$i++)
240
  $out .= chr(16*$pixels[2*$i] + $pixels[2*$i+1]);
241
  return $out;
242
+ }
243
 
244
 
245
 
246
  }
 
 
mPDF/classes/cssmgr.php CHANGED
@@ -12,7 +12,7 @@ var $tbCSSlvl;
12
  var $listCSSlvl;
13
 
14
 
15
- function cssmgr(&$mpdf) {
16
  $this->mpdf = $mpdf;
17
  $this->tablecascadeCSS = array();
18
  $this->listcascadeCSS = array();
@@ -75,13 +75,13 @@ function ReadDefaultCSS($CSSstr) {
75
  function ReadCSS($html) {
76
  preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
77
  for($i=0; $i<count($m[0]); $i++) {
78
- if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
79
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
80
  }
81
  }
82
  preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
83
  for($i=0; $i<count($m[0]); $i++) {
84
- if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
85
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
86
  }
87
  }
@@ -93,9 +93,9 @@ function ReadCSS($html) {
93
  // case so we can use str_replace later.
94
  preg_replace('/<\/style>/i', '</style>', $html);
95
  preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
96
- if (count($m[1])) {
97
  for($i=0;$i<count($m[1]);$i++) {
98
- // Remove comment tags
99
  $sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
100
  $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
101
  $html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
@@ -109,20 +109,20 @@ function ReadCSS($html) {
109
 
110
  $match = 0; // no match for instance
111
  $regexp = ''; // This helps debugging: showing what is the REAL string being processed
112
- $CSSext = array();
113
 
114
  //CSS inside external files
115
  $regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
116
  $x = preg_match_all($regexp,$html,$cxt);
117
- if ($x) {
118
- $match += $x;
119
  $CSSext = $cxt[1];
120
  }
121
 
122
  $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
123
  $x = preg_match_all($regexp,$html,$cxt);
124
- if ($x) {
125
- $match += $x;
126
  $CSSext = array_merge($CSSext,$cxt[1]);
127
  }
128
 
@@ -130,8 +130,8 @@ function ReadCSS($html) {
130
  //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
131
  $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
132
  $x = preg_match_all($regexp,$html,$cxt);
133
- if ($x) {
134
- $match += $x;
135
  $CSSext = array_merge($CSSext,$cxt[1]);
136
  }
137
 
@@ -139,8 +139,8 @@ function ReadCSS($html) {
139
  //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
140
  $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
141
  $x = preg_match_all($regexp,$html,$cxt);
142
- if ($x) {
143
- $match += $x;
144
  $CSSext = array_merge($CSSext,$cxt[1]);
145
  }
146
 
@@ -151,7 +151,7 @@ function ReadCSS($html) {
151
 
152
  while($match){
153
  $path = $CSSext[$ind];
154
- $this->mpdf->GetFullPath($path);
155
  $CSSextblock = $this->mpdf->_get_file($path);
156
  if ($CSSextblock) {
157
  // look for embedded @import stylesheets in other stylesheets
@@ -160,17 +160,17 @@ function ReadCSS($html) {
160
  $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
161
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
162
  $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
163
- if ($xem) {
164
  foreach($cxtem[1] AS $cxtembedded) {
165
  // path is relative to original stlyesheet!!
166
  $this->mpdf->GetFullPath($cxtembedded, $cssBasePath );
167
- $match++;
168
  $CSSext[] = $cxtembedded;
169
  }
170
  }
171
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
172
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
173
- if ($xem) {
174
  for ($i=0;$i<count($cxtem[0]);$i++) {
175
  // path is relative to original stlyesheet!!
176
  $embedded = $cxtem[2][$i];
@@ -188,13 +188,13 @@ function ReadCSS($html) {
188
 
189
  $match = 0; // reset value, if needed
190
  // CSS as <style> in HTML document
191
- $regexp = '/<style.*?>(.*?)<\/style>/si';
192
  $match = preg_match_all($regexp,$html,$CSSblock);
193
  if ($match) {
194
  $tmpCSSstr = implode(' ',$CSSblock[1]);
195
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
196
  $xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
197
- if ($xem) {
198
  for ($i=0;$i<count($cxtem[0]);$i++) {
199
  $embedded = $cxtem[2][$i];
200
  if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
@@ -209,10 +209,10 @@ function ReadCSS($html) {
209
  $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
210
  $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
211
 
212
- if (preg_match('/@media/',$CSSstr)) {
213
  preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
214
  for($i=0; $i<count($m[0]); $i++) {
215
- if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
216
  $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
217
  }
218
  else {
@@ -223,7 +223,7 @@ function ReadCSS($html) {
223
 
224
  // Replace any background: url(data:image... with temporary image file reference
225
  preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2
226
- if (count($idata[0])) {
227
  for($i=0;$i<count($idata[0]);$i++) {
228
  $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
229
  //Save to local file
@@ -241,7 +241,7 @@ function ReadCSS($html) {
241
  $stylestr= trim($styles[2][$i]);
242
  $stylearr = explode(';',$stylestr);
243
  foreach($stylearr AS $sta) {
244
- if (trim($sta)) {
245
  // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
246
  list($property,$value) = explode(':',$sta,2);
247
  $property = trim($property);
@@ -249,8 +249,8 @@ function ReadCSS($html) {
249
  $value = trim($value);
250
  if ($property && ($value || $value==='0')) {
251
  // Ignores -webkit-gradient so doesn't override -moz-
252
- if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) {
253
- continue;
254
  }
255
  $classproperties[strtoupper($property)] = $value;
256
  }
@@ -276,13 +276,13 @@ function ReadCSS($html) {
276
  if (isset($tags[2])) { $t3 = trim($tags[2]); }
277
  $tag = '';
278
  if ($level==1) { $tag = $t; }
279
- else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) {
280
- $tag = $t.'>>PSEUDO>>'.$m[1];
281
- if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
282
  }
283
  else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
284
- else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) {
285
- $tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1];
286
  if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
287
  }
288
  if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
@@ -323,9 +323,9 @@ function ReadCSS($html) {
323
  }
324
 
325
  if ($tag) {
326
- $x = &$this->cascadeCSS;
327
  foreach($tmp AS $tp) { $x = &$x[$tp]; }
328
- $x = $this->array_merge_recursive_unique($x, $classproperties);
329
  $x['depth'] = $level;
330
  }
331
  }
@@ -337,7 +337,7 @@ function ReadCSS($html) {
337
  }
338
  } // end of if
339
  //Remove CSS (tags and content), if any
340
- $regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
341
  $html = preg_replace($regexp,'',$html);
342
  //print_r($this->CSS); exit;
343
  //print_r($this->cascadeCSS); exit;
@@ -359,8 +359,8 @@ function readInlineCSS($html) {
359
  $classproperties = array();
360
  for($i = 0; $i < count($properties) ; $i++) {
361
  // Ignores -webkit-gradient so doesn't override -moz-
362
- if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
363
- continue;
364
  }
365
  $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
366
  }
@@ -371,10 +371,10 @@ function readInlineCSS($html) {
371
 
372
  function _fix_borderStr($bd) {
373
  preg_match_all("/\((.*?)\)/", $bd, $m);
374
- if (count($m[1])) {
375
  for($i=0;$i<count($m[1]);$i++) {
376
  $sub = preg_replace("/ /", "", $m[1][$i]);
377
- $bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd);
378
  }
379
  }
380
 
@@ -383,20 +383,20 @@ function _fix_borderStr($bd) {
383
  $c = '#000000';
384
  $s = 'none';
385
 
386
- if ( count($prop) == 1 ) {
387
  // solid
388
  if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
389
  // #000000
390
  else if (is_array($this->mpdf->ConvertColor($prop[0]))) { $c = $prop[0]; }
391
- // 1px
392
  else { $w = $prop[0]; }
393
  }
394
- else if (count($prop) == 2 ) {
395
- // 1px solid
396
  if (in_array($prop[1],$this->mpdf->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
397
- // solid #000000
398
  else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
399
- // 1px #000000
400
  else { $w = $prop[0]; $c = $prop[1]; }
401
  }
402
  else if ( count($prop) == 3 ) {
@@ -405,12 +405,12 @@ function _fix_borderStr($bd) {
405
  // Change solid #000000 1px to 1px solid #000000 (proper)
406
  else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
407
  // Change solid 1px #000000 to 1px solid #000000 (proper)
408
- else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
409
- $s = $prop[0]; $w = $prop[1]; $c = $prop[2];
410
  }
411
  else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
412
  }
413
- else { return ''; }
414
  $s = strtolower($s);
415
  return $w.' '.$s.' '.$c;
416
  }
@@ -418,8 +418,8 @@ function _fix_borderStr($bd) {
418
 
419
 
420
  function fixCSS($prop) {
421
- if (!is_array($prop) || (count($prop)==0)) return array();
422
- $newprop = array();
423
  foreach($prop AS $k => $v) {
424
  if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
425
  $v = strtolower($v);
@@ -429,28 +429,28 @@ function fixCSS($prop) {
429
  $s = trim($v);
430
  preg_match_all('/\"(.*?)\"/',$s,$ff);
431
  if (count($ff[1])) {
432
- foreach($ff[1] AS $ffp) {
433
  $w = preg_split('/\s+/',$ffp);
434
- $s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
435
  }
436
  }
437
  preg_match_all('/\'(.*?)\'/',$s,$ff);
438
  if (count($ff[1])) {
439
- foreach($ff[1] AS $ffp) {
440
  $w = preg_split('/\s+/',$ffp);
441
- $s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
442
  }
443
  }
444
- $s = preg_replace('/\s*,\s*/',',',$s);
445
  $bits = preg_split('/\s+/',$s);
446
  if (count($bits)>1) {
447
  $k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
448
  $fs = $bits[(count($bits)-2)];
449
- if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
450
  $newprop['FONT-SIZE'] = $fsp[1];
451
  $newprop['LINE-HEIGHT'] = $fsp[2];
452
  }
453
- else { $newprop['FONT-SIZE'] = $fs; }
454
  if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
455
  else { $newprop['FONT-STYLE'] = 'normal'; }
456
  if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
@@ -467,11 +467,11 @@ function fixCSS($prop) {
467
  $fonttype = preg_replace('/ /','',$fonttype);
468
  $v = strtolower(trim($fonttype));
469
  if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
470
- if ((!$this->mpdf->onlyCoreFonts && in_array($v,$this->mpdf->available_unifonts)) ||
471
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
472
- ($this->mpdf->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
473
- in_array($v, array('sjis','uhc','big5','gb'))) {
474
- $newprop[$k] = $v;
475
  $found = 1;
476
  break;
477
  }
@@ -483,7 +483,7 @@ function fixCSS($prop) {
483
  $fonttype = preg_replace('/ /','',$fonttype);
484
  $v = strtolower(trim($fonttype));
485
  if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
486
- if (in_array($v,$this->mpdf->sans_fonts) || in_array($v,$this->mpdf->serif_fonts) || in_array($v,$this->mpdf->mono_fonts) ) {
487
  $newprop[$k] = $v;
488
  break;
489
  }
@@ -561,25 +561,25 @@ function fixCSS($prop) {
561
 
562
  else if ($k == 'BORDER-SPACING') {
563
  $prop = preg_split('/\s+/',trim($v));
564
- if (count($prop) == 1 ) {
565
  $newprop['BORDER-SPACING-H'] = $prop[0];
566
  $newprop['BORDER-SPACING-V'] = $prop[0];
567
  }
568
- else if (count($prop) == 2 ) {
569
  $newprop['BORDER-SPACING-H'] = $prop[0];
570
  $newprop['BORDER-SPACING-V'] = $prop[1];
571
  }
572
  }
573
  else if ($k == 'TEXT-OUTLINE') { // mPDF 5.6.07
574
  $prop = preg_split('/\s+/',trim($v));
575
- if (trim(strtolower($v)) == 'none' ) {
576
  $newprop['TEXT-OUTLINE'] = 'none';
577
  }
578
- else if (count($prop) == 2 ) {
579
  $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
580
  $newprop['TEXT-OUTLINE-COLOR'] = $prop[1];
581
  }
582
- else if (count($prop) == 3 ) {
583
  $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
584
  $newprop['TEXT-OUTLINE-COLOR'] = $prop[2];
585
  }
@@ -617,8 +617,8 @@ function fixCSS($prop) {
617
  if ($bg['c']) { $newprop['BACKGROUND-COLOR'] = $bg['c']; }
618
  else { $newprop['BACKGROUND-COLOR'] = 'transparent'; }
619
  /*-- BACKGROUNDS --*/
620
- if ($bg['i']) {
621
- $newprop['BACKGROUND-IMAGE'] = $bg['i'];
622
  if ($bg['r']) { $newprop['BACKGROUND-REPEAT'] = $bg['r']; }
623
  if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
624
  }
@@ -639,7 +639,7 @@ function fixCSS($prop) {
639
 
640
  }
641
  else if ($k == 'BACKGROUND-REPEAT') {
642
- if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) {
643
  $newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
644
  }
645
  }
@@ -654,11 +654,11 @@ function fixCSS($prop) {
654
  }
655
  else if (count($bits)==2) {
656
  // Can be either right center or center right
657
- if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
658
- $bg['p'] = $bits[1] . ' '.$bits[0];
659
  }
660
- else {
661
- $bg['p'] = $bits[0] . ' '.$bits[1];
662
  }
663
  }
664
  if ($bg['p']) {
@@ -682,18 +682,18 @@ function fixCSS($prop) {
682
  $angle = ($angle % 360);
683
  $angle /= 90;
684
  $angle = round($angle) * 90;
685
- $newprop['IMAGE-ORIENTATION'] = $angle;
686
  }
687
  }
688
  // mPDF 5.6.13
689
  else if ($k == 'TEXT-ALIGN') {
690
- if (preg_match('/["\'](.){1}["\']/i',$v,$m)) {
691
  $d = array_search($m[1],$this->mpdf->decimal_align);
692
  if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
693
  if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
694
  else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R
695
  }
696
- else if (preg_match('/["\'](\\\[a-fA-F0-9]{1,6})["\']/i',$v,$m)) {
697
  $utf8 = codeHex2utf(substr($m[1],1,6));
698
  $d = array_search($utf8,$this->mpdf->decimal_align);
699
  if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
@@ -704,14 +704,14 @@ function fixCSS($prop) {
704
  }
705
  else if ($k == 'LIST-STYLE') { // mPDF 5.7.2
706
  if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|none|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$v,$m)
707
- || preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) {
708
  $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
709
  }
710
  }
711
 
712
 
713
- else {
714
- $newprop[$k] = $v;
715
  }
716
  }
717
 
@@ -734,12 +734,12 @@ function setCSSboxshadow($v) {
734
  if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
735
  if (isset($p[2])) {
736
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
737
- $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
738
  }
739
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
740
  if (isset($p[3])) {
741
  if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
742
- $new['spread'] = $this->mpdf->ConvertSize(trim($p[3]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
743
  }
744
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); }
745
  if (isset($p[4])) {
@@ -768,7 +768,7 @@ function setCSStextshadow($v) {
768
  if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
769
  if (isset($p[2])) {
770
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
771
- $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
772
  }
773
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
774
  if (isset($p[3])) {
@@ -800,7 +800,7 @@ function parseCSSbackground($s) {
800
  if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) {
801
  $bg['i'] = $m[1];
802
  $s = strtolower($m[2]);
803
- if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',$s,$m)) {
804
  $bg['r'] = $m[1];
805
  }
806
  // Remove repeat, attachment (discarded) and also any inherit
@@ -814,11 +814,11 @@ function parseCSSbackground($s) {
814
  }
815
  else if (count($bits)==2) {
816
  // Can be either right center or center right
817
- if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
818
- $bg['p'] = $bits[1] . ' '.$bits[0];
819
  }
820
- else {
821
- $bg['p'] = $bits[0] . ' '.$bits[1];
822
  }
823
  }
824
  if ($bg['p']) {
@@ -839,20 +839,20 @@ function parseCSSbackground($s) {
839
 
840
  function expand24($mp) {
841
  $prop = preg_split('/\s+/',trim($mp));
842
- if (count($prop) == 1 ) {
843
  return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
844
  }
845
- if (count($prop) == 2 ) {
846
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
847
  }
848
 
849
- if (count($prop) == 3 ) {
850
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
851
  }
852
- if (count($prop) == 4 ) {
853
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
854
  }
855
- return array();
856
  }
857
 
858
  /*-- BORDER-RADIUS --*/
@@ -940,7 +940,7 @@ function border_radius_expand($val,$k) {
940
  function _mergeCSS($p, &$t) {
941
  // Save Cascading CSS e.g. "div.topic p" at this block level
942
  if (isset($p) && $p) {
943
- if ($t) {
944
  $t = $this->array_merge_recursive_unique($t, $p);
945
  }
946
  else { $t = $p; }
@@ -965,7 +965,7 @@ function array_merge_recursive_unique($array1, $array2) {
965
  $ret[$key] = $value;
966
  }
967
  }
968
- }
969
  }
970
  return $ret;
971
  }
@@ -1029,8 +1029,8 @@ function _set_mergedCSS(&$m, &$p, $d=true, $bd=false) {
1029
  if (isset($m)) {
1030
  if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
1031
  if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
1032
- if (is_array($m)) {
1033
- $p = array_merge($p,$m);
1034
  $this->_mergeBorders($p,$m);
1035
  }
1036
  }
@@ -1067,7 +1067,7 @@ function _mergeBorders(&$b, &$a) { // Merges $a['BORDER-TOP-STYLE'] to $b['BORDE
1067
 
1068
  function MergeCSS($inherit,$tag,$attr) {
1069
  $p = array();
1070
- $zp = array();
1071
 
1072
  $classes = array();
1073
  if (isset($attr['CLASS'])) {
@@ -1099,7 +1099,7 @@ function MergeCSS($inherit,$tag,$attr) {
1099
  }
1100
  $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
1101
  //===============================================
1102
- // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
1103
  //===============================================
1104
  // STYLESHEET TAG e.g. table
1105
  $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
@@ -1130,7 +1130,7 @@ function MergeCSS($inherit,$tag,$attr) {
1130
  }
1131
  $this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
1132
  //===============================================
1133
- // Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS
1134
  //===============================================
1135
  // STYLESHEET TAG e.g. table
1136
  $this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
@@ -1161,13 +1161,13 @@ function MergeCSS($inherit,$tag,$attr) {
1161
 
1162
  if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) { $p['DIRECTION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']; }
1163
 
1164
- if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['align']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['align']) {
1165
- if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
1166
- else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
1167
- else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
1168
- else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
1169
  }
1170
- if ($this->mpdf->ColActive || $this->mpdf->keep_block_together) {
1171
  if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
1172
  $cor = $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolorarray' ];
1173
  $p['BACKGROUND-COLOR'] = $this->mpdf->_colAtoString($cor);
@@ -1183,7 +1183,7 @@ function MergeCSS($inherit,$tag,$attr) {
1183
  if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
1184
  if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; }
1185
  if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
1186
- if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) {
1187
  $cor = $biilp[ 'colorarray' ];
1188
  $p['COLOR'] = $this->mpdf->_colAtoString($cor);
1189
  }
@@ -1192,11 +1192,11 @@ function MergeCSS($inherit,$tag,$attr) {
1192
  else { $p['FONT-KERNING'] = 'none'; }
1193
  }
1194
  if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; }
1195
- if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; }
1196
  if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
1197
  else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
1198
  else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
1199
- // CSS says text-decoration is not inherited, but IE7 does??
1200
  if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
1201
  if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
1202
 
@@ -1212,7 +1212,7 @@ function MergeCSS($inherit,$tag,$attr) {
1212
  if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
1213
  if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; }
1214
  if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
1215
- if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) {
1216
  $cor = $bilp[ 'colorarray' ];
1217
  $p['COLOR'] = $this->mpdf->_colAtoString($cor);
1218
  }
@@ -1238,7 +1238,7 @@ function MergeCSS($inherit,$tag,$attr) {
1238
  //===============================================
1239
  //===============================================
1240
  // DEFAULT for this TAG set in DefaultCSS
1241
- if (isset($this->mpdf->defaultCSS[$tag])) {
1242
  $zp = $this->fixCSS($this->mpdf->defaultCSS[$tag]);
1243
  if (is_array($zp)) { // Default overwrites Inherited
1244
  $p = array_merge($p,$zp); // !! Note other way round !!
@@ -1262,11 +1262,11 @@ function MergeCSS($inherit,$tag,$attr) {
1262
  /*-- END TABLES --*/
1263
  //===============================================
1264
  // STYLESHEET TAG e.g. h1 p div table
1265
- if (isset($this->CSS[$tag]) && $this->CSS[$tag]) {
1266
  $zp = $this->CSS[$tag];
1267
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1268
- if (is_array($zp)) {
1269
- $p = array_merge($p,$zp);
1270
  $this->_mergeBorders($p,$zp);
1271
  }
1272
  }
@@ -1276,8 +1276,8 @@ function MergeCSS($inherit,$tag,$attr) {
1276
  $zp = array();
1277
  if (isset($this->CSS['CLASS>>'.$class]) && $this->CSS['CLASS>>'.$class]) { $zp = $this->CSS['CLASS>>'.$class]; }
1278
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1279
- if (is_array($zp)) {
1280
- $p = array_merge($p,$zp);
1281
  $this->_mergeBorders($p,$zp);
1282
  }
1283
  }
@@ -1306,8 +1306,8 @@ function MergeCSS($inherit,$tag,$attr) {
1306
  if ($select) {
1307
  $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
1308
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); }
1309
- if (is_array($zp)) {
1310
- $p = array_merge($p,$zp);
1311
  $this->_mergeBorders($p,$zp);
1312
  }
1313
  }
@@ -1320,8 +1320,8 @@ function MergeCSS($inherit,$tag,$attr) {
1320
  if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) {
1321
  $zp = $this->CSS['ID>>'.$attr['ID']];
1322
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1323
- if (is_array($zp)) {
1324
- $p = array_merge($p,$zp);
1325
  $this->_mergeBorders($p,$zp);
1326
  }
1327
  }
@@ -1331,8 +1331,8 @@ function MergeCSS($inherit,$tag,$attr) {
1331
  $zp = array();
1332
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class]) && $this->CSS[$tag.'>>CLASS>>'.$class]) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
1333
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1334
- if (is_array($zp)) {
1335
- $p = array_merge($p,$zp);
1336
  $this->_mergeBorders($p,$zp);
1337
  }
1338
  }
@@ -1341,8 +1341,8 @@ function MergeCSS($inherit,$tag,$attr) {
1341
  if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) {
1342
  $zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
1343
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1344
- if (is_array($zp)) {
1345
- $p = array_merge($p,$zp);
1346
  $this->_mergeBorders($p,$zp);
1347
  }
1348
  }
@@ -1413,7 +1413,7 @@ function MergeCSS($inherit,$tag,$attr) {
1413
  //===============================================
1414
  /*-- LISTS --*/
1415
  else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS
1416
- // false = don't check for 'depth'
1417
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false);
1418
  foreach($classes AS $class) {
1419
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false);
@@ -1431,8 +1431,8 @@ function MergeCSS($inherit,$tag,$attr) {
1431
  if (isset($attr['STYLE'])) {
1432
  $zp = $this->readInlineCSS($attr['STYLE']);
1433
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1434
- if (is_array($zp)) {
1435
- $p = array_merge($p,$zp);
1436
  $this->_mergeBorders($p,$zp);
1437
  }
1438
  }
@@ -1489,24 +1489,24 @@ function MergeCSS($inherit,$tag,$attr) {
1489
  function PreviewBlockCSS($tag,$attr) {
1490
  // Looks ahead from current block level to a new level
1491
  $p = array();
1492
- $zp = array();
1493
  $oldcascadeCSS = $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'];
1494
  $classes = array();
1495
  if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
1496
  //===============================================
1497
  // DEFAULT for this TAG set in DefaultCSS
1498
- if (isset($this->mpdf->defaultCSS[$tag])) {
1499
  $zp = $this->fixCSS($this->mpdf->defaultCSS[$tag]);
1500
  if (is_array($zp)) { $p = array_merge($zp,$p); } // Inherited overwrites default
1501
  }
1502
  // STYLESHEET TAG e.g. h1 p div table
1503
- if (isset($this->CSS[$tag])) {
1504
  $zp = $this->CSS[$tag];
1505
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1506
  }
1507
  // STYLESHEET CLASS e.g. .smallone{} .redletter{}
1508
  foreach($classes AS $class) {
1509
- $zp = array();
1510
  if (isset($this->CSS['CLASS>>'.$class])) { $zp = $this->CSS['CLASS>>'.$class]; }
1511
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1512
  }
@@ -1517,7 +1517,7 @@ function PreviewBlockCSS($tag,$attr) {
1517
  }
1518
  // STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
1519
  foreach($classes AS $class) {
1520
- $zp = array();
1521
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class])) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
1522
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1523
  }
@@ -1569,27 +1569,27 @@ function _nthchild($f, $c) {
1569
  $a=1; $b=1;
1570
  if ($f[0]=='ODD') { $a=2; $b=1; }
1571
  else if ($f[0]=='EVEN') { $a=2; $b=0; }
1572
- else if (count($f)==2) { $a=0; $b=$f[1]+0; } // e.g. (+6)
1573
  else if (count($f)==3) { // e.g. (2N)
1574
  if ($f[2]=='') { $a=1; }
1575
  else if ($f[2]=='-') { $a=-1; }
1576
  else { $a=$f[2]+0; }
1577
- $b=0;
1578
  }
1579
  else if (count($f)==4) { // e.g. (2N+6)
1580
  if ($f[2]=='') { $a=1; }
1581
  else if ($f[2]=='-') { $a=-1; }
1582
  else { $a=$f[2]+0; }
1583
- $b=$f[3]+0;
1584
  }
1585
  else { return false; }
1586
- if ($a>0) {
1587
  if (((($c % $a) - $b) % $a) == 0 && $c >= $b) { $select = true; }
1588
  }
1589
- else if ($a==0) {
1590
  if ($c == $b) { $select = true; }
1591
  }
1592
- else { // if ($a<0)
1593
  if (((($c % $a) - $b) % $a) == 0 && $c <= $b) { $select = true; }
1594
  }
1595
  return $select;
@@ -1598,5 +1598,3 @@ function _nthchild($f, $c) {
1598
 
1599
 
1600
  } // end of class
1601
-
1602
- ?>
12
  var $listCSSlvl;
13
 
14
 
15
+ function __construct(&$mpdf) {
16
  $this->mpdf = $mpdf;
17
  $this->tablecascadeCSS = array();
18
  $this->listcascadeCSS = array();
75
  function ReadCSS($html) {
76
  preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
77
  for($i=0; $i<count($m[0]); $i++) {
78
+ if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
79
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
80
  }
81
  }
82
  preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
83
  for($i=0; $i<count($m[0]); $i++) {
84
+ if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
85
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
86
  }
87
  }
93
  // case so we can use str_replace later.
94
  preg_replace('/<\/style>/i', '</style>', $html);
95
  preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
96
+ if (count($m[1])) {
97
  for($i=0;$i<count($m[1]);$i++) {
98
+ // Remove comment tags
99
  $sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
100
  $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
101
  $html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
109
 
110
  $match = 0; // no match for instance
111
  $regexp = ''; // This helps debugging: showing what is the REAL string being processed
112
+ $CSSext = array();
113
 
114
  //CSS inside external files
115
  $regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
116
  $x = preg_match_all($regexp,$html,$cxt);
117
+ if ($x) {
118
+ $match += $x;
119
  $CSSext = $cxt[1];
120
  }
121
 
122
  $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
123
  $x = preg_match_all($regexp,$html,$cxt);
124
+ if ($x) {
125
+ $match += $x;
126
  $CSSext = array_merge($CSSext,$cxt[1]);
127
  }
128
 
130
  //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
131
  $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
132
  $x = preg_match_all($regexp,$html,$cxt);
133
+ if ($x) {
134
+ $match += $x;
135
  $CSSext = array_merge($CSSext,$cxt[1]);
136
  }
137
 
139
  //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
140
  $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
141
  $x = preg_match_all($regexp,$html,$cxt);
142
+ if ($x) {
143
+ $match += $x;
144
  $CSSext = array_merge($CSSext,$cxt[1]);
145
  }
146
 
151
 
152
  while($match){
153
  $path = $CSSext[$ind];
154
+ $this->mpdf->GetFullPath($path);
155
  $CSSextblock = $this->mpdf->_get_file($path);
156
  if ($CSSextblock) {
157
  // look for embedded @import stylesheets in other stylesheets
160
  $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
161
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
162
  $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
163
+ if ($xem) {
164
  foreach($cxtem[1] AS $cxtembedded) {
165
  // path is relative to original stlyesheet!!
166
  $this->mpdf->GetFullPath($cxtembedded, $cssBasePath );
167
+ $match++;
168
  $CSSext[] = $cxtembedded;
169
  }
170
  }
171
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
172
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
173
+ if ($xem) {
174
  for ($i=0;$i<count($cxtem[0]);$i++) {
175
  // path is relative to original stlyesheet!!
176
  $embedded = $cxtem[2][$i];
188
 
189
  $match = 0; // reset value, if needed
190
  // CSS as <style> in HTML document
191
+ $regexp = '/<style.*?>(.*?)<\/style>/si';
192
  $match = preg_match_all($regexp,$html,$CSSblock);
193
  if ($match) {
194
  $tmpCSSstr = implode(' ',$CSSblock[1]);
195
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
196
  $xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
197
+ if ($xem) {
198
  for ($i=0;$i<count($cxtem[0]);$i++) {
199
  $embedded = $cxtem[2][$i];
200
  if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
209
  $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
210
  $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
211
 
212
+ if (preg_match('/@media/',$CSSstr)) {
213
  preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
214
  for($i=0; $i<count($m[0]); $i++) {
215
+ if ($this->mpdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) {
216
  $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
217
  }
218
  else {
223
 
224
  // Replace any background: url(data:image... with temporary image file reference
225
  preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*?)\))/si", $CSSstr, $idata); // mPDF 5.7.2
226
+ if (count($idata[0])) {
227
  for($i=0;$i<count($idata[0]);$i++) {
228
  $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
229
  //Save to local file
241
  $stylestr= trim($styles[2][$i]);
242
  $stylearr = explode(';',$stylestr);
243
  foreach($stylearr AS $sta) {
244
+ if (trim($sta)) {
245
  // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
246
  list($property,$value) = explode(':',$sta,2);
247
  $property = trim($property);
249
  $value = trim($value);
250
  if ($property && ($value || $value==='0')) {
251
  // Ignores -webkit-gradient so doesn't override -moz-
252
+ if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) {
253
+ continue;
254
  }
255
  $classproperties[strtoupper($property)] = $value;
256
  }
276
  if (isset($tags[2])) { $t3 = trim($tags[2]); }
277
  $tag = '';
278
  if ($level==1) { $tag = $t; }
279
+ else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) {
280
+ $tag = $t.'>>PSEUDO>>'.$m[1];
281
+ if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
282
  }
283
  else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
284
+ else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) {
285
+ $tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1];
286
  if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mpdf->mirrorMargins
287
  }
288
  if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
323
  }
324
 
325
  if ($tag) {
326
+ $x = &$this->cascadeCSS;
327
  foreach($tmp AS $tp) { $x = &$x[$tp]; }
328
+ $x = $this->array_merge_recursive_unique($x, $classproperties);
329
  $x['depth'] = $level;
330
  }
331
  }
337
  }
338
  } // end of if
339
  //Remove CSS (tags and content), if any
340
+ $regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
341
  $html = preg_replace($regexp,'',$html);
342
  //print_r($this->CSS); exit;
343
  //print_r($this->cascadeCSS); exit;
359
  $classproperties = array();
360
  for($i = 0; $i < count($properties) ; $i++) {
361
  // Ignores -webkit-gradient so doesn't override -moz-
362
+ if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
363
+ continue;
364
  }
365
  $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
366
  }
371
 
372
  function _fix_borderStr($bd) {
373
  preg_match_all("/\((.*?)\)/", $bd, $m);
374
+ if (count($m[1])) {
375
  for($i=0;$i<count($m[1]);$i++) {
376
  $sub = preg_replace("/ /", "", $m[1][$i]);
377
+ $bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd);
378
  }
379
  }
380
 
383
  $c = '#000000';
384
  $s = 'none';
385
 
386
+ if ( count($prop) == 1 ) {
387
  // solid
388
  if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
389
  // #000000
390
  else if (is_array($this->mpdf->ConvertColor($prop[0]))) { $c = $prop[0]; }
391
+ // 1px
392
  else { $w = $prop[0]; }
393
  }
394
+ else if (count($prop) == 2 ) {
395
+ // 1px solid
396
  if (in_array($prop[1],$this->mpdf->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
397
+ // solid #000000
398
  else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
399
+ // 1px #000000
400
  else { $w = $prop[0]; $c = $prop[1]; }
401
  }
402
  else if ( count($prop) == 3 ) {
405
  // Change solid #000000 1px to 1px solid #000000 (proper)
406
  else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
407
  // Change solid 1px #000000 to 1px solid #000000 (proper)
408
+ else if (in_array($prop[0],$this->mpdf->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
409
+ $s = $prop[0]; $w = $prop[1]; $c = $prop[2];
410
  }
411
  else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
412
  }
413
+ else { return ''; }
414
  $s = strtolower($s);
415
  return $w.' '.$s.' '.$c;
416
  }
418
 
419
 
420
  function fixCSS($prop) {
421
+ if (!is_array($prop) || (count($prop)==0)) return array();
422
+ $newprop = array();
423
  foreach($prop AS $k => $v) {
424
  if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
425
  $v = strtolower($v);
429
  $s = trim($v);
430
  preg_match_all('/\"(.*?)\"/',$s,$ff);
431
  if (count($ff[1])) {
432
+ foreach($ff[1] AS $ffp) {
433
  $w = preg_split('/\s+/',$ffp);
434
+ $s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
435
  }
436
  }
437
  preg_match_all('/\'(.*?)\'/',$s,$ff);
438
  if (count($ff[1])) {
439
+ foreach($ff[1] AS $ffp) {
440
  $w = preg_split('/\s+/',$ffp);
441
+ $s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
442
  }
443
  }
444
+ $s = preg_replace('/\s*,\s*/',',',$s);
445
  $bits = preg_split('/\s+/',$s);
446
  if (count($bits)>1) {
447
  $k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
448
  $fs = $bits[(count($bits)-2)];
449
+ if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
450
  $newprop['FONT-SIZE'] = $fsp[1];
451
  $newprop['LINE-HEIGHT'] = $fsp[2];
452
  }
453
+ else { $newprop['FONT-SIZE'] = $fs; }
454
  if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
455
  else { $newprop['FONT-STYLE'] = 'normal'; }
456
  if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
467
  $fonttype = preg_replace('/ /','',$fonttype);
468
  $v = strtolower(trim($fonttype));
469
  if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
470
+ if ((!$this->mpdf->onlyCoreFonts && in_array($v,$this->mpdf->available_unifonts)) ||
471
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
472
+ ($this->mpdf->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
473
+ in_array($v, array('sjis','uhc','big5','gb'))) {
474
+ $newprop[$k] = $v;
475
  $found = 1;
476
  break;
477
  }
483
  $fonttype = preg_replace('/ /','',$fonttype);
484
  $v = strtolower(trim($fonttype));
485
  if (isset($this->mpdf->fonttrans[$v]) && $this->mpdf->fonttrans[$v]) { $v = $this->mpdf->fonttrans[$v]; }
486
+ if (in_array($v,$this->mpdf->sans_fonts) || in_array($v,$this->mpdf->serif_fonts) || in_array($v,$this->mpdf->mono_fonts) ) {
487
  $newprop[$k] = $v;
488
  break;
489
  }
561
 
562
  else if ($k == 'BORDER-SPACING') {
563
  $prop = preg_split('/\s+/',trim($v));
564
+ if (count($prop) == 1 ) {
565
  $newprop['BORDER-SPACING-H'] = $prop[0];
566
  $newprop['BORDER-SPACING-V'] = $prop[0];
567
  }
568
+ else if (count($prop) == 2 ) {
569
  $newprop['BORDER-SPACING-H'] = $prop[0];
570
  $newprop['BORDER-SPACING-V'] = $prop[1];
571
  }
572
  }
573
  else if ($k == 'TEXT-OUTLINE') { // mPDF 5.6.07
574
  $prop = preg_split('/\s+/',trim($v));
575
+ if (trim(strtolower($v)) == 'none' ) {
576
  $newprop['TEXT-OUTLINE'] = 'none';
577
  }
578
+ else if (count($prop) == 2 ) {
579
  $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
580
  $newprop['TEXT-OUTLINE-COLOR'] = $prop[1];
581
  }
582
+ else if (count($prop) == 3 ) {
583
  $newprop['TEXT-OUTLINE-WIDTH'] = $prop[0];
584
  $newprop['TEXT-OUTLINE-COLOR'] = $prop[2];
585
  }
617
  if ($bg['c']) { $newprop['BACKGROUND-COLOR'] = $bg['c']; }
618
  else { $newprop['BACKGROUND-COLOR'] = 'transparent'; }
619
  /*-- BACKGROUNDS --*/
620
+ if ($bg['i']) {
621
+ $newprop['BACKGROUND-IMAGE'] = $bg['i'];
622
  if ($bg['r']) { $newprop['BACKGROUND-REPEAT'] = $bg['r']; }
623
  if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
624
  }
639
 
640
  }
641
  else if ($k == 'BACKGROUND-REPEAT') {
642
+ if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) {
643
  $newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
644
  }
645
  }
654
  }
655
  else if (count($bits)==2) {
656
  // Can be either right center or center right
657
+ if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
658
+ $bg['p'] = $bits[1] . ' '.$bits[0];
659
  }
660
+ else {
661
+ $bg['p'] = $bits[0] . ' '.$bits[1];
662
  }
663
  }
664
  if ($bg['p']) {
682
  $angle = ($angle % 360);
683
  $angle /= 90;
684
  $angle = round($angle) * 90;
685
+ $newprop['IMAGE-ORIENTATION'] = $angle;
686
  }
687
  }
688
  // mPDF 5.6.13
689
  else if ($k == 'TEXT-ALIGN') {
690
+ if (preg_match('/["\'](.){1}["\']/i',$v,$m)) {
691
  $d = array_search($m[1],$this->mpdf->decimal_align);
692
  if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
693
  if (preg_match('/(center|left|right)/i',$v,$m)) { $newprop['TEXT-ALIGN'] .= strtoupper(substr($m[1],0,1)); }
694
  else { $newprop['TEXT-ALIGN'] .= 'R'; } // default = R
695
  }
696
+ else if (preg_match('/["\'](\\\[a-fA-F0-9]{1,6})["\']/i',$v,$m)) {
697
  $utf8 = codeHex2utf(substr($m[1],1,6));
698
  $d = array_search($utf8,$this->mpdf->decimal_align);
699
  if ($d !== false) { $newprop['TEXT-ALIGN'] = $d; }
704
  }
705
  else if ($k == 'LIST-STYLE') { // mPDF 5.7.2
706
  if (preg_match('/(lower-roman|upper-roman|lower-latin|lower-alpha|upper-latin|upper-alpha|none|decimal|disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu|cambodian|khmer|lao)/i',$v,$m)
707
+ || preg_match('/U\+([a-fA-F0-9]+)/i',$v,$m)) {
708
  $newprop['LIST-STYLE-TYPE'] = strtolower(trim($m[1]));
709
  }
710
  }
711
 
712
 
713
+ else {
714
+ $newprop[$k] = $v;
715
  }
716
  }
717
 
734
  if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
735
  if (isset($p[2])) {
736
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
737
+ $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
738
  }
739
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
740
  if (isset($p[3])) {
741
  if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
742
+ $new['spread'] = $this->mpdf->ConvertSize(trim($p[3]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
743
  }
744
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[3])); }
745
  if (isset($p[4])) {
768
  if (isset($p[1])) { $new['y'] = $this->mpdf->ConvertSize(trim($p[1]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false); }
769
  if (isset($p[2])) {
770
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
771
+ $new['blur'] = $this->mpdf->ConvertSize(trim($p[2]),$this->mpdf->blk[$this->mpdf->blklvl-1]['inner_width'],$this->mpdf->FontSize,false);
772
  }
773
  else { $new['col'] = $this->mpdf->ConvertColor(preg_replace('/\*/',',',$p[2])); }
774
  if (isset($p[3])) {
800
  if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) {
801
  $bg['i'] = $m[1];
802
  $s = strtolower($m[2]);
803
+ if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',$s,$m)) {
804
  $bg['r'] = $m[1];
805
  }
806
  // Remove repeat, attachment (discarded) and also any inherit
814
  }
815
  else if (count($bits)==2) {
816
  // Can be either right center or center right
817
+ if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
818
+ $bg['p'] = $bits[1] . ' '.$bits[0];
819
  }
820
+ else {
821
+ $bg['p'] = $bits[0] . ' '.$bits[1];
822
  }
823
  }
824
  if ($bg['p']) {
839
 
840
  function expand24($mp) {
841
  $prop = preg_split('/\s+/',trim($mp));
842
+ if (count($prop) == 1 ) {
843
  return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
844
  }
845
+ if (count($prop) == 2 ) {
846
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
847
  }
848
 
849
+ if (count($prop) == 3 ) {
850
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
851
  }
852
+ if (count($prop) == 4 ) {
853
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
854
  }
855
+ return array();
856
  }
857
 
858
  /*-- BORDER-RADIUS --*/
940
  function _mergeCSS($p, &$t) {
941
  // Save Cascading CSS e.g. "div.topic p" at this block level
942
  if (isset($p) && $p) {
943
+ if ($t) {
944
  $t = $this->array_merge_recursive_unique($t, $p);
945
  }
946
  else { $t = $p; }
965
  $ret[$key] = $value;
966
  }
967
  }
968
+ }
969
  }
970
  return $ret;
971
  }
1029
  if (isset($m)) {
1030
  if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
1031
  if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
1032
+ if (is_array($m)) {
1033
+ $p = array_merge($p,$m);
1034
  $this->_mergeBorders($p,$m);
1035
  }
1036
  }
1067
 
1068
  function MergeCSS($inherit,$tag,$attr) {
1069
  $p = array();
1070
+ $zp = array();
1071
 
1072
  $classes = array();
1073
  if (isset($attr['CLASS'])) {
1099
  }
1100
  $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
1101
  //===============================================
1102
+ // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
1103
  //===============================================
1104
  // STYLESHEET TAG e.g. table
1105
  $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
1130
  }
1131
  $this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
1132
  //===============================================
1133
+ // Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS
1134
  //===============================================
1135
  // STYLESHEET TAG e.g. table
1136
  $this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
1161
 
1162
  if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']) { $p['DIRECTION'] = $this->mpdf->blk[$this->mpdf->blklvl-1]['direction']; }
1163
 
1164
+ if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['align']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['align']) {
1165
+ if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
1166
+ else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
1167
+ else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
1168
+ else if ($this->mpdf->blk[$this->mpdf->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
1169
  }
1170
+ if ($this->mpdf->ColActive || $this->mpdf->keep_block_together) {
1171
  if (isset($this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) && $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
1172
  $cor = $this->mpdf->blk[$this->mpdf->blklvl-1]['bgcolorarray' ];
1173
  $p['BACKGROUND-COLOR'] = $this->mpdf->_colAtoString($cor);
1183
  if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
1184
  if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; }
1185
  if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
1186
+ if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) {
1187
  $cor = $biilp[ 'colorarray' ];
1188
  $p['COLOR'] = $this->mpdf->_colAtoString($cor);
1189
  }
1192
  else { $p['FONT-KERNING'] = 'none'; }
1193
  }
1194
  if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; }
1195
+ if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; }
1196
  if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
1197
  else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
1198
  else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
1199
+ // CSS says text-decoration is not inherited, but IE7 does??
1200
  if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
1201
  if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
1202
 
1212
  if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
1213
  if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; }
1214
  if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
1215
+ if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) {
1216
  $cor = $bilp[ 'colorarray' ];
1217
  $p['COLOR'] = $this->mpdf->_colAtoString($cor);
1218
  }
1238
  //===============================================
1239
  //===============================================
1240
  // DEFAULT for this TAG set in DefaultCSS
1241
+ if (isset($this->mpdf->defaultCSS[$tag])) {
1242
  $zp = $this->fixCSS($this->mpdf->defaultCSS[$tag]);
1243
  if (is_array($zp)) { // Default overwrites Inherited
1244
  $p = array_merge($p,$zp); // !! Note other way round !!
1262
  /*-- END TABLES --*/
1263
  //===============================================
1264
  // STYLESHEET TAG e.g. h1 p div table
1265
+ if (isset($this->CSS[$tag]) && $this->CSS[$tag]) {
1266
  $zp = $this->CSS[$tag];
1267
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1268
+ if (is_array($zp)) {
1269
+ $p = array_merge($p,$zp);
1270
  $this->_mergeBorders($p,$zp);
1271
  }
1272
  }
1276
  $zp = array();
1277
  if (isset($this->CSS['CLASS>>'.$class]) && $this->CSS['CLASS>>'.$class]) { $zp = $this->CSS['CLASS>>'.$class]; }
1278
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1279
+ if (is_array($zp)) {
1280
+ $p = array_merge($p,$zp);
1281
  $this->_mergeBorders($p,$zp);
1282
  }
1283
  }
1306
  if ($select) {
1307
  $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
1308
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); }
1309
+ if (is_array($zp)) {
1310
+ $p = array_merge($p,$zp);
1311
  $this->_mergeBorders($p,$zp);
1312
  }
1313
  }
1320
  if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) {
1321
  $zp = $this->CSS['ID>>'.$attr['ID']];
1322
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1323
+ if (is_array($zp)) {
1324
+ $p = array_merge($p,$zp);
1325
  $this->_mergeBorders($p,$zp);
1326
  }
1327
  }
1331
  $zp = array();
1332
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class]) && $this->CSS[$tag.'>>CLASS>>'.$class]) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
1333
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1334
+ if (is_array($zp)) {
1335
+ $p = array_merge($p,$zp);
1336
  $this->_mergeBorders($p,$zp);
1337
  }
1338
  }
1341
  if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) {
1342
  $zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
1343
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1344
+ if (is_array($zp)) {
1345
+ $p = array_merge($p,$zp);
1346
  $this->_mergeBorders($p,$zp);
1347
  }
1348
  }
1413
  //===============================================
1414
  /*-- LISTS --*/
1415
  else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS
1416
+ // false = don't check for 'depth'
1417
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false);
1418
  foreach($classes AS $class) {
1419
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false);
1431
  if (isset($attr['STYLE'])) {
1432
  $zp = $this->readInlineCSS($attr['STYLE']);
1433
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
1434
+ if (is_array($zp)) {
1435
+ $p = array_merge($p,$zp);
1436
  $this->_mergeBorders($p,$zp);
1437
  }
1438
  }
1489
  function PreviewBlockCSS($tag,$attr) {
1490
  // Looks ahead from current block level to a new level
1491
  $p = array();
1492
+ $zp = array();
1493
  $oldcascadeCSS = $this->mpdf->blk[$this->mpdf->blklvl]['cascadeCSS'];
1494
  $classes = array();
1495
  if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
1496
  //===============================================
1497
  // DEFAULT for this TAG set in DefaultCSS
1498
+ if (isset($this->mpdf->defaultCSS[$tag])) {
1499
  $zp = $this->fixCSS($this->mpdf->defaultCSS[$tag]);
1500
  if (is_array($zp)) { $p = array_merge($zp,$p); } // Inherited overwrites default
1501
  }
1502
  // STYLESHEET TAG e.g. h1 p div table
1503
+ if (isset($this->CSS[$tag])) {
1504
  $zp = $this->CSS[$tag];
1505
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1506
  }
1507
  // STYLESHEET CLASS e.g. .smallone{} .redletter{}
1508
  foreach($classes AS $class) {
1509
+ $zp = array();
1510
  if (isset($this->CSS['CLASS>>'.$class])) { $zp = $this->CSS['CLASS>>'.$class]; }
1511
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1512
  }
1517
  }
1518
  // STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
1519
  foreach($classes AS $class) {
1520
+ $zp = array();
1521
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class])) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
1522
  if (is_array($zp)) { $p = array_merge($p,$zp); }
1523
  }
1569
  $a=1; $b=1;
1570
  if ($f[0]=='ODD') { $a=2; $b=1; }
1571
  else if ($f[0]=='EVEN') { $a=2; $b=0; }
1572
+ else if (count($f)==2) { $a=0; $b=$f[1]+0; } // e.g. (+6)
1573
  else if (count($f)==3) { // e.g. (2N)
1574
  if ($f[2]=='') { $a=1; }
1575
  else if ($f[2]=='-') { $a=-1; }
1576
  else { $a=$f[2]+0; }
1577
+ $b=0;
1578
  }
1579
  else if (count($f)==4) { // e.g. (2N+6)
1580
  if ($f[2]=='') { $a=1; }
1581
  else if ($f[2]=='-') { $a=-1; }
1582
  else { $a=$f[2]+0; }
1583
+ $b=$f[3]+0;
1584
  }
1585
  else { return false; }
1586
+ if ($a>0) {
1587
  if (((($c % $a) - $b) % $a) == 0 && $c >= $b) { $select = true; }
1588
  }
1589
+ else if ($a==0) {
1590
  if ($c == $b) { $select = true; }
1591
  }
1592
+ else { // if ($a<0)
1593
  if (((($c % $a) - $b) % $a) == 0 && $c <= $b) { $select = true; }
1594
  }
1595
  return $select;
1598
 
1599
 
1600
  } // end of class
 
 
mPDF/classes/directw.php CHANGED
@@ -4,19 +4,19 @@ class directw {
4
 
5
  var $mpdf = null;
6
 
7
- function directw(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
11
 
12
  function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
13
- if (!$align) {
14
  if ($directionality=='rtl') { $align = 'R'; }
15
  else { $align = 'L'; }
16
  }
17
  if ($h == 0) { $this->mpdf->SetLineHeight(); $h = $this->mpdf->lineheight; }
18
  //Output text in flowing mode
19
- $w = $this->mpdf->w - $this->mpdf->rMargin - $this->mpdf->x;
20
 
21
  $wmax = ($w - ($this->mpdf->cMarginL+$this->mpdf->cMarginR));
22
  $s=str_replace("\r",'',$txt);
@@ -97,10 +97,10 @@ function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
97
  // JUSTIFY J using Unicode fonts (Word spacing doesn't work)
98
  // WORD SPACING
99
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
100
- $tmp = str_replace(chr(194).chr(160),chr(32),$tmp );
101
  $len_ligne = $this->mpdf->GetStringWidth($tmp );
102
- $nb_carac = mb_strlen( $tmp , $this->mpdf->mb_enc ) ;
103
- $nb_spaces = mb_substr_count( $tmp ,' ', $this->mpdf->mb_enc ) ;
104
  $inclCursive=false;
105
  if ($checkCursive) {
106
  if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $tmp)) { $inclCursive = true; } // *RTL*
@@ -182,8 +182,8 @@ function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
182
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
183
  $tmp = str_replace(chr(160),chr(32),$tmp );
184
  $len_ligne = $this->mpdf->GetStringWidth($tmp );
185
- $nb_carac = strlen( $tmp ) ;
186
- $nb_spaces = substr_count( $tmp ,' ' ) ;
187
  list($charspacing,$ws) = $this->mpdf->GetJspacing($nb_carac,$nb_spaces,((($w-2) - $len_ligne) * _MPDFK),$false);
188
  $this->mpdf->SetSpacing($charspacing,$ws);
189
  //////////////////////////////////////////
@@ -212,7 +212,7 @@ function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
212
  //Last chunk
213
  if($i!=$j) {
214
  if ($currentx != 0) $this->mpdf->x=$currentx;
215
- else $this->mpdf->x=$this->mpdf->lMargin;
216
  if ($this->mpdf->usingCoreFont) { $tmp = substr($s,$j,$i-$j); }
217
  else {
218
  $tmp = mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc);
@@ -227,7 +227,7 @@ function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
227
  function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsizePt=0, $fontstyle='', $kerning=120, $fontwidth=100, $divider='') { // mPDF 5.5.23
228
  if ($font || $fontstyle || $fontsizePt) $this->mpdf->SetFont($fontfamily,$fontstyle,$fontsizePt);
229
  $kerning/=100;
230
- $fontwidth/=100;
231
  if($kerning==0) $this->mpdf->Error('Please use values unequal to zero for kerning (CircularText)');
232
  if($fontwidth==0) $this->mpdf->Error('Please use values unequal to zero for font width (CircularText)');
233
  $text=str_replace("\r",'',$text);
@@ -240,15 +240,15 @@ function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsize
240
  $t=0;
241
  $w = array();
242
  if ($this->mpdf->usingCoreFont) {
243
- $nb=strlen($text);
244
  for($i=0; $i<$nb; $i++){
245
  $w[$i]=$this->mpdf->GetStringWidth($text[$i]);
246
  $w[$i]*=$kerning*$fontwidth;
247
  $t+=$w[$i];
248
  }
249
  }
250
- else {
251
- $nb=mb_strlen($text, $this->mpdf->mb_enc );
252
  $lastchar = '';
253
  $unicode = $this->mpdf->UTF8StringToArray($text);
254
  for($i=0; $i<$nb; $i++){
@@ -257,8 +257,8 @@ function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsize
257
  $w[$i]*=$kerning*$fontwidth;
258
  $char = $unicode[$i];
259
  if ($this->mpdf->useKerning && $lastchar) {
260
- if (isset($this->mpdf->CurrentFont['kerninfo'][$lastchar][$char])) {
261
- $tk = $this->mpdf->CurrentFont['kerninfo'][$lastchar][$char] * ($this->mpdf->FontSize/ 1000) * $kerning * $fontwidth;
262
  $w[$i] += $tk/2;
263
  $w[$i-1] += $tk/2;
264
  $t+=$tk;
@@ -275,7 +275,7 @@ function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsize
275
  $t+=$this->mpdf->GetStringWidth(' ');
276
  if ($fontsizePt==-2)
277
  $fontsizePt = $this->mpdf->FontSizePt * 0.5 * $u/$t;
278
- else
279
  $fontsizePt = $this->mpdf->FontSizePt * $u/$t;
280
  $this->mpdf->SetFontSize($fontsizePt);
281
  $autoset = true;
@@ -405,4 +405,3 @@ function Shaded_box( $text,$font='',$fontstyle='B',$szfont='',$width='70%',$styl
405
 
406
  }
407
 
408
- ?>
4
 
5
  var $mpdf = null;
6
 
7
+ function __construct(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
11
 
12
  function Write($h,$txt,$currentx=0,$link='',$directionality='ltr',$align='') {
13
+ if (!$align) {
14
  if ($directionality=='rtl') { $align = 'R'; }
15
  else { $align = 'L'; }
16
  }
17
  if ($h == 0) { $this->mpdf->SetLineHeight(); $h = $this->mpdf->lineheight; }
18
  //Output text in flowing mode
19
+ $w = $this->mpdf->w - $this->mpdf->rMargin - $this->mpdf->x;
20
 
21
  $wmax = ($w - ($this->mpdf->cMarginL+$this->mpdf->cMarginR));
22
  $s=str_replace("\r",'',$txt);
97
  // JUSTIFY J using Unicode fonts (Word spacing doesn't work)
98
  // WORD SPACING
99
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
100
+ $tmp = str_replace(chr(194).chr(160),chr(32),$tmp );
101
  $len_ligne = $this->mpdf->GetStringWidth($tmp );
102
+ $nb_carac = mb_strlen( $tmp , $this->mpdf->mb_enc ) ;
103
+ $nb_spaces = mb_substr_count( $tmp ,' ', $this->mpdf->mb_enc ) ;
104
  $inclCursive=false;
105
  if ($checkCursive) {
106
  if (preg_match("/([".$this->mpdf->pregRTLchars."])/u", $tmp)) { $inclCursive = true; } // *RTL*
182
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
183
  $tmp = str_replace(chr(160),chr(32),$tmp );
184
  $len_ligne = $this->mpdf->GetStringWidth($tmp );
185
+ $nb_carac = strlen( $tmp ) ;
186
+ $nb_spaces = substr_count( $tmp ,' ' ) ;
187
  list($charspacing,$ws) = $this->mpdf->GetJspacing($nb_carac,$nb_spaces,((($w-2) - $len_ligne) * _MPDFK),$false);
188
  $this->mpdf->SetSpacing($charspacing,$ws);
189
  //////////////////////////////////////////
212
  //Last chunk
213
  if($i!=$j) {
214
  if ($currentx != 0) $this->mpdf->x=$currentx;
215
+ else $this->mpdf->x=$this->mpdf->lMargin;
216
  if ($this->mpdf->usingCoreFont) { $tmp = substr($s,$j,$i-$j); }
217
  else {
218
  $tmp = mb_substr($s,$j,$i-$j,$this->mpdf->mb_enc);
227
  function CircularText($x, $y, $r, $text, $align='top', $fontfamily='', $fontsizePt=0, $fontstyle='', $kerning=120, $fontwidth=100, $divider='') { // mPDF 5.5.23
228
  if ($font || $fontstyle || $fontsizePt) $this->mpdf->SetFont($fontfamily,$fontstyle,$fontsizePt);
229
  $kerning/=100;
230
+ $fontwidth/=100;
231
  if($kerning==0) $this->mpdf->Error('Please use values unequal to zero for kerning (CircularText)');
232
  if($fontwidth==0) $this->mpdf->Error('Please use values unequal to zero for font width (CircularText)');
233
  $text=str_replace("\r",'',$text);
240
  $t=0;
241
  $w = array();
242
  if ($this->mpdf->usingCoreFont) {
243
+ $nb=strlen($text);
244
  for($i=0; $i<$nb; $i++){
245
  $w[$i]=$this->mpdf->GetStringWidth($text[$i]);
246
  $w[$i]*=$kerning*$fontwidth;
247
  $t+=$w[$i];
248
  }
249
  }
250
+ else {
251
+ $nb=mb_strlen($text, $this->mpdf->mb_enc );
252
  $lastchar = '';
253
  $unicode = $this->mpdf->UTF8StringToArray($text);
254
  for($i=0; $i<$nb; $i++){
257
  $w[$i]*=$kerning*$fontwidth;
258
  $char = $unicode[$i];
259
  if ($this->mpdf->useKerning && $lastchar) {
260
+ if (isset($this->mpdf->CurrentFont['kerninfo'][$lastchar][$char])) {
261
+ $tk = $this->mpdf->CurrentFont['kerninfo'][$lastchar][$char] * ($this->mpdf->FontSize/ 1000) * $kerning * $fontwidth;
262
  $w[$i] += $tk/2;
263
  $w[$i-1] += $tk/2;
264
  $t+=$tk;
275
  $t+=$this->mpdf->GetStringWidth(' ');
276
  if ($fontsizePt==-2)
277
  $fontsizePt = $this->mpdf->FontSizePt * 0.5 * $u/$t;
278
+ else
279
  $fontsizePt = $this->mpdf->FontSizePt * $u/$t;
280
  $this->mpdf->SetFontSize($fontsizePt);
281
  $autoset = true;
405
 
406
  }
407
 
 
mPDF/classes/form.php CHANGED
@@ -13,16 +13,16 @@ 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
 
@@ -49,7 +49,7 @@ var $form_button_icon;
49
  // FORMS
50
  var $textarea_lineheight;
51
 
52
- function form(&$mpdf) {
53
  $this->mpdf = $mpdf;
54
 
55
  // ACTIVE FORMS
@@ -66,12 +66,12 @@ function form(&$mpdf) {
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;
@@ -114,7 +114,7 @@ function print_ob_text($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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; }
@@ -142,14 +142,14 @@ function print_ob_text($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
  }
@@ -195,11 +195,11 @@ function print_ob_textarea($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
  }
@@ -237,7 +237,7 @@ function print_ob_select($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
  }
@@ -263,7 +263,7 @@ function print_ob_select($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
  }
@@ -301,7 +301,7 @@ function print_ob_select($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
@@ -319,15 +319,15 @@ function print_ob_imageinput($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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;
@@ -356,8 +356,8 @@ function print_ob_button($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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));
@@ -368,7 +368,7 @@ function print_ob_button($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir) {
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
@@ -388,12 +388,12 @@ function print_ob_checkbox($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
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
  }
@@ -418,7 +418,7 @@ function print_ob_checkbox($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
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
@@ -429,7 +429,7 @@ function print_ob_radio($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
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;
@@ -438,9 +438,9 @@ function print_ob_radio($objattr,$w,$h,$texto,$rtlalign,$k,$blockdir,$x,$y) {
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
  }
@@ -474,8 +474,8 @@ function countPageForms($n, &$totaladdnum) {
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; }
@@ -505,8 +505,8 @@ function addFormIds($n, &$s, &$annotid) {
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; }
@@ -582,7 +582,7 @@ function _putFormsCatalog() {
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('>>');
@@ -622,7 +622,7 @@ function SetFormTextJS( $name, $js) {
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),
@@ -642,14 +642,14 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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
@@ -657,7 +657,7 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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; }
@@ -691,16 +691,16 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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;
@@ -712,16 +712,16 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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
@@ -755,16 +755,16 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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;
@@ -793,11 +793,11 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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
  }
@@ -817,23 +817,23 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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;
@@ -845,39 +845,39 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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(),
@@ -891,7 +891,7 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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; }
@@ -930,16 +930,16 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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
 
@@ -952,33 +952,33 @@ function SetFormText( $w, $h, $name, $value = '', $default = '', $title = '', $f
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
  }
@@ -1024,9 +1024,9 @@ 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
  }
@@ -1046,9 +1046,9 @@ function _put_button_icon( $array , $w, $h ) {
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']);
@@ -1082,7 +1082,7 @@ function _putform_bt( $form, $hPt ) {
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 ');
@@ -1099,12 +1099,12 @@ function _putform_bt( $form, $hPt ) {
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 = '';
@@ -1125,7 +1125,7 @@ function _putform_bt( $form, $hPt ) {
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']).' ]');
@@ -1133,12 +1133,12 @@ function _putform_bt( $form, $hPt ) {
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 ');
@@ -1227,7 +1227,7 @@ function _putform_bt( $form, $hPt ) {
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
  }
@@ -1237,9 +1237,9 @@ function _putform_bt( $form, $hPt ) {
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 ) {
@@ -1263,7 +1263,7 @@ function _putform_bt( $form, $hPt ) {
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
  }
@@ -1378,7 +1378,7 @@ function _putform_ch( $form, $hPt ) {
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
 
@@ -1447,21 +1447,21 @@ function _putform_tx( $form, $hPt ) {
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.' >>');
@@ -1471,20 +1471,20 @@ function _putform_tx( $form, $hPt ) {
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
  }
@@ -1494,5 +1494,3 @@ function _putform_tx( $form, $hPt ) {
1494
 
1495
 
1496
  }
1497
-
1498
- ?>
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
 
49
  // FORMS
50
  var $textarea_lineheight;
51
 
52
+ function __construct(&$mpdf) {
53
  $this->mpdf = $mpdf;
54
 
55
  // ACTIVE FORMS
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;
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; }
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
  }
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
  }
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
  }
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
  }
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
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;
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));
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
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
  }
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
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;
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
  }
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; }
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; }
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('>>');
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),
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
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; }
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;
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
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;
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
  }
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;
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(),
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; }
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
 
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
  }
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
  }
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']);
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 ');
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 = '';
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']).' ]');
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 ');
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
  }
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 ) {
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
  }
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
 
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.' >>');
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
  }
1494
 
1495
 
1496
  }
 
 
mPDF/classes/gif.php CHANGED
@@ -9,7 +9,7 @@
9
  // condition to leave the original address (Yamasoft, http://www.yamasoft.com) and this header.
10
  ///////////////////////////////////////////////////////////////////////////////////////////////////
11
  ///////////////////////////////////////////////////////////////////////////////////////////////////
12
- // 2009-12-22 Adapted INB
13
  // Functions calling functionname($x, $len = 0) were not working on PHP5.1.5 as pass by reference
14
  // All edited to $len = 0; then call function.
15
  ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -26,7 +26,7 @@ class CGIFLZW
26
  ///////////////////////////////////////////////////////////////////////////
27
 
28
  // CONSTRUCTOR
29
- function CGIFLZW()
30
  {
31
  $this->MAX_LZW_BITS = 12;
32
  unSet($this->Next);
@@ -696,5 +696,3 @@ class CGIF
696
  }
697
 
698
  ///////////////////////////////////////////////////////////////////////////////////////////////////
699
-
700
- ?>
9
  // condition to leave the original address (Yamasoft, http://www.yamasoft.com) and this header.
10
  ///////////////////////////////////////////////////////////////////////////////////////////////////
11
  ///////////////////////////////////////////////////////////////////////////////////////////////////
12
+ // 2009-12-22 Adapted INB
13
  // Functions calling functionname($x, $len = 0) were not working on PHP5.1.5 as pass by reference
14
  // All edited to $len = 0; then call function.
15
  ///////////////////////////////////////////////////////////////////////////////////////////////////
26
  ///////////////////////////////////////////////////////////////////////////
27
 
28
  // CONSTRUCTOR
29
+ function __construct()
30
  {
31
  $this->MAX_LZW_BITS = 12;
32
  unSet($this->Next);
696
  }
697
 
698
  ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 
mPDF/classes/grad.php CHANGED
@@ -4,7 +4,7 @@ class grad {
4
 
5
  var $mpdf = null;
6
 
7
- function grad(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
@@ -57,7 +57,7 @@ function CoonsPatchMesh($x, $y, $w, $h, $patch_array=array(), $x_min=0, $x_max=1
57
  }
58
  }
59
  // TRANSPARENCY
60
- if ($trans) {
61
  $this->mpdf->gradients[$n]['stream_trans']='';
62
  for($i=0;$i<count($patch_array);$i++){
63
  $this->mpdf->gradients[$n]['stream_trans'].=chr($patch_array[$i]['f']);
@@ -79,7 +79,7 @@ function CoonsPatchMesh($x, $y, $w, $h, $patch_array=array(), $x_min=0, $x_max=1
79
  }
80
  }
81
  }
82
- $this->mpdf->gradients[$n]['trans'] = true;
83
  $s .= ' /TGS'.$n.' gs ';
84
  }
85
  //paint the gradient
@@ -92,10 +92,10 @@ function CoonsPatchMesh($x, $y, $w, $h, $patch_array=array(), $x_min=0, $x_max=1
92
 
93
 
94
  // type = linear:2; radial: 3;
95
- // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
96
  // The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
97
- // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
98
- // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
99
  // (fx, fy) should be inside the circle, otherwise some areas will not be defined
100
  // $col = array(R,G,B/255); or array(G/255); or array(C,M,Y,K/100)
101
  // $stops = array('col'=>$col [, 'opacity'=>0-1] [, 'offset'=>0-1])
@@ -112,16 +112,16 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
112
  $usew = $bboxw;
113
  $useh = $bboxh;
114
  if ($type < 1) { $type = 2; }
115
- if ($coords[0]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[0],$m)) {
116
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
117
  if ($tmp) { $coords[0] = $tmp/$w; }
118
  }
119
- if ($coords[1]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[1],$m)) {
120
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
121
  if ($tmp) { $coords[1] = 1-($tmp/$h); }
122
  }
123
  // LINEAR
124
- if ($type == 2) {
125
  $angle = $coords[4];
126
  $repeat = $coords[5];
127
  // ALL POINTS SET (default for custom mPDF linear gradient) - no -moz
@@ -129,7 +129,7 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
129
  // do nothing - coords used as they are
130
  }
131
 
132
- // If both a <point> and <angle> are defined, the gradient axis starts from the point and runs along the angle. The end point is
133
  // defined as before - in this case start points may not be in corners, and axis may not correctly fall in the right quadrant.
134
  // NO end points (Angle defined & Start points)
135
  else if ($angle!==false && $coords[0]!==false && $coords[1]!==false && $coords[2]===false && $coords[3]===false) {
@@ -138,17 +138,17 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
138
  else if ($angle==180) { if ($coords[4]==0) $coords[2]=-1; else $coords[2]=0; $coords[3]=$coords[1]; }
139
  else if ($angle==270) { $coords[2]=$coords[0]; if ($coords[1]==0) $coords[3]=-1; else $coords[3]=0; }
140
  else {
141
- $endx=1; $endy=1;
142
- if ($angle <=90) {
143
  if ($angle <=45) { $endy=tan(deg2rad($angle)); }
144
  else { $endx=tan(deg2rad(90-$angle)); }
145
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
146
  $ny = 1 - $coords[1] - (tan($b) * (1-$coords[0]));
147
  $tx = sin($b) * cos($b) * $ny;
148
  $ty = cos($b) * cos($b) * $ny;
149
- $coords[2] = 1+$tx; $coords[3] = 1-$ty;
150
  }
151
- else if ($angle <=180) {
152
  if ($angle <=135) { $endx=tan(deg2rad($angle-90)); }
153
  else { $endy=tan(deg2rad(180-$angle)); }
154
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
@@ -157,30 +157,30 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
157
  $ty = cos($b) * cos($b) * $ny;
158
  $coords[2] = -$tx; $coords[3] = 1-$ty;
159
  }
160
- else if ($angle <=270) {
161
  if ($angle <=225) { $endy=tan(deg2rad($angle-180)); }
162
  else { $endx=tan(deg2rad(270-$angle)); }
163
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
164
  $ny = $coords[1] - (tan($b) * ($coords[0]));
165
  $tx = sin($b) * cos($b) * $ny;
166
  $ty = cos($b) * cos($b) * $ny;
167
- $coords[2] = -$tx; $coords[3] = $ty;
168
  }
169
- else {
170
  if ($angle <=315) { $endx=tan(deg2rad($angle-270)); }
171
  else { $endy=tan(deg2rad(360-$angle)); }
172
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
173
  $ny = $coords[1] - (tan($b) * (1-$coords[0]));
174
  $tx = sin($b) * cos($b) * $ny;
175
  $ty = cos($b) * cos($b) * $ny;
176
- $coords[2] = 1+$tx; $coords[3] = $ty;
177
 
178
  }
179
  }
180
  }
181
 
182
- // -moz If the first parameter is only an <angle>, the gradient axis starts from the box's corner that would ensure the
183
- // axis goes through the box. The axis runs along the specified angle. The end point of the axis is defined such that the
184
  // farthest corner of the box from the starting point is perpendicular to the gradient axis at that point.
185
  // NO end points or Start points (Angle defined)
186
  else if ($angle!==false && $coords[0]===false && $coords[1]===false) {
@@ -189,23 +189,23 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
189
  else if ($angle==180) { $coords[0]=1; $coords[1]=0; $coords[2]=0; $coords[3]=0; }
190
  else if ($angle==270) { $coords[0]=0; $coords[1]=1; $coords[2]=0; $coords[3]=0; }
191
  else {
192
- if ($angle <=90) {
193
- $coords[0]=0; $coords[1]=0;
194
  if ($angle <=45) { $endx=1; $endy=tan(deg2rad($angle)); }
195
  else { $endx=tan(deg2rad(90-$angle)); $endy=1; }
196
  }
197
- else if ($angle <=180) {
198
- $coords[0]=1; $coords[1]=0;
199
  if ($angle <=135) { $endx=tan(deg2rad($angle-90)); $endy=1; }
200
  else { $endx=1; $endy=tan(deg2rad(180-$angle)); }
201
  }
202
- else if ($angle <=270) {
203
- $coords[0]=1; $coords[1]=1;
204
  if ($angle <=225) { $endx=1; $endy=tan(deg2rad($angle-180)); }
205
  else { $endx=tan(deg2rad(270-$angle)); $endy=1; }
206
  }
207
- else {
208
- $coords[0]=0; $coords[1]=1;
209
  if ($angle <=315) { $endx=tan(deg2rad($angle-270)); $endy=1; }
210
  else { $endx=1; $endy=tan(deg2rad(360-$angle)); }
211
  }
@@ -221,8 +221,8 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
221
  else { $coords[2] = $x1; $coords[3] = 1-$y1; }
222
  }
223
  }
224
- // -moz If the first parameter to the gradient function is only a <point>, the gradient axis starts from the specified point,
225
- // and ends at the point you would get if you rotated the starting point by 180 degrees about the center of the box that the
226
  // gradient is to be applied to.
227
  // NO angle and NO end points (Start points defined)
228
  else if ((!isset($angle) || $angle===false) && $coords[0]!==false && $coords[1]!==false) { // should have start and end defined
@@ -230,7 +230,7 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
230
  $angle = rad2deg(atan2($coords[3]-$coords[1],$coords[2]-$coords[0]));
231
  if ($angle < 0) { $angle += 360; }
232
  else if ($angle > 360) { $angle -= 360; }
233
- if ($angle!=0 && $angle!=360 && $angle!=90 && $angle!=180 && $angle!=270) {
234
  if ($w >= $h) {
235
  $coords[1] *= $h/$w ;
236
  $coords[3] *= $h/$w ;
@@ -245,7 +245,7 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
245
  }
246
  }
247
 
248
- // -moz If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values, the gradient
249
  // axis starts from the top of the box and runs vertically downwards, ending at the bottom of the box.
250
  else { // default values T2B
251
  // All values are set in parseMozGradient - so won't appear here
@@ -257,7 +257,7 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
257
  }
258
 
259
  // RADIAL
260
- else if ($type == 3) {
261
  $radius = $coords[4];
262
  $angle = $coords[5]; // ?? no effect
263
  $shape = $coords[6];
@@ -311,11 +311,11 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
311
  }
312
  }
313
  if ($radius==0) { $radius=0.001; } // to prevent error
314
- $coords[4] = $radius;
315
  }
316
 
317
  // -moz If entire function consists of only <stop> values
318
- else { // default values
319
  // All values are set in parseMozGradient - so won't appear here
320
  $coords = array(0.5,0.5,0.5,0.5); // default for radial gradient (centred)
321
  }
@@ -343,24 +343,24 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
343
  else { $axis_length = $coords[4]*$usew; } // Absolute lengths are meaningless for an ellipse - Firefox uses Width as reference
344
 
345
  for($i=0;$i<count($stops);$i++) {
346
- if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$stops[$i]['offset'],$m)) {
347
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
348
  $stops[$i]['offset'] = $tmp/$axis_length;
349
  }
350
  }
351
 
352
 
353
- if (isset($stops[0]['offset']) && $stops[0]['offset']>0) {
354
- $firststop = $stops[0];
355
  $firststop['offset'] = 0;
356
- array_unshift($stops, $firststop);
357
  }
358
  if (!$repeat && isset($stops[(count($stops)-1)]['offset']) && $stops[(count($stops)-1)]['offset']<1) {
359
- $endstop = $stops[(count($stops)-1)];
360
  $endstop['offset'] = 1;
361
- $stops[] = $endstop;
362
  }
363
- if ($stops[0]['offset'] > $stops[(count($stops)-1)]['offset']) {
364
  $stops[0]['offset'] = 0;
365
  $stops[(count($stops)-1)]['offset'] = 1;
366
  }
@@ -376,17 +376,17 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
376
  else {
377
  $this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F', (ord($stops[$i]['col']{1})/255), (ord($stops[$i]['col']{2})/255), (ord($stops[$i]['col']{3})/255));
378
  }
379
- if (!isset($stops[$i]['opacity'])) { $stops[$i]['opacity'] = 1; }
380
- else if ($stops[$i]['opacity'] > 1 || $stops[$i]['opacity'] < 0) { $stops[$i]['opacity'] = 1; }
381
- else if ($stops[$i]['opacity'] < 1) {
382
- $trans = true;
383
  }
384
  $this->mpdf->gradients[$n]['stops'][$i]['opacity'] = $stops[$i]['opacity'];
385
  // OFFSET
386
  if ($i>0 && $i<(count($stops)-1)) {
387
- if (!isset($stops[$i]['offset']) || (isset($stops[$i+1]['offset']) && $stops[$i]['offset']>$stops[$i+1]['offset']) || $stops[$i]['offset']<$stops[$i-1]['offset']) {
388
- if (isset($stops[$i-1]['offset']) && isset($stops[$i+1]['offset'])) {
389
- $stops[$i]['offset'] = ($stops[$i-1]['offset']+$stops[$i+1]['offset'])/2;
390
  }
391
  else {
392
  for($j=($i+1);$j<count($stops);$j++) {
@@ -426,11 +426,11 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
426
  }
427
  }
428
 
429
- if ($trans) {
430
- $this->mpdf->gradients[$n]['trans'] = true;
431
  $s .= ' /TGS'.$n.' gs ';
432
  }
433
- if (!is_array($extend) || count($extend) <1) {
434
  $extend=array('true', 'true'); // These are supposed to be quoted - appear in PDF file as text
435
  }
436
  $this->mpdf->gradients[$n]['coords'] = $coords;
@@ -445,7 +445,7 @@ function Gradient($x, $y, $w, $h, $type, $stops=array(), $colorspace='RGB', $coo
445
 
446
 
447
  function parseMozGradient($bg) {
448
- // background[-image]: -moz-linear-gradient(left, #c7Fdde 20%, #FF0000 );
449
  // background[-image]: linear-gradient(left, #c7Fdde 20%, #FF0000 ); // CSS3
450
  if (preg_match('/repeating-/',$bg)) { $repeat = true; }
451
  else { $repeat = false; }
@@ -464,15 +464,15 @@ function parseMozGradient($bg) {
464
  // Is first part $bgr[0] a valid point/angle?
465
  $first = preg_split('/\s+/',trim($bgr[0]));
466
  if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
467
- $startStops = 1;
468
  }
469
  else if (trim($first[(count($first)-1)]) === "0") {
470
  $startStops = 1;
471
  }
472
  else {
473
  $check = $this->mpdf->ConvertColor($first[0]);
474
- if ($check) $startStops = 0;
475
- else $startStops = 1;
476
  }
477
  // first part a valid point/angle?
478
  if ($startStops == 1) { // default values
@@ -492,12 +492,12 @@ function parseMozGradient($bg) {
492
  else if (preg_match('/bottom/i',$bgr[0])) { $starty = 0; }
493
  // Check for %? ?% or %%
494
  if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
495
- else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) {
496
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
497
  if ($tmp) { $startx = $m[1]; }
498
  }
499
  if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
500
- else if (!isset($starty) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) {
501
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
502
  if ($tmp) { $starty = $m[1]; }
503
  }
@@ -532,11 +532,11 @@ function parseMozGradient($bg) {
532
  else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; } // transparency from cmyka()
533
  else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; } // transparency converted from rgba or cmyka()
534
 
535
- if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) {
536
  $stop['offset'] = $m[1]/100;
537
  if ($stop['offset']>1) { unset($stop['offset']); }
538
  }
539
- else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) {
540
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
541
  if ($tmp) { $stop['offset'] = $m[1]; }
542
  }
@@ -558,13 +558,13 @@ function parseMozGradient($bg) {
558
  for($i=0;$i<count($bgr);$i++) { $bgr[$i] = preg_replace('/@/', ',', $bgr[$i]); }
559
 
560
  // Is first part $bgr[0] a valid point/angle?
561
- $startStops = 0;
562
  $pos_angle = false;
563
  $shape_size = false;
564
  $first = preg_split('/\s+/',trim($bgr[0]));
565
  $checkCol = $this->mpdf->ConvertColor($first[0]);
566
  if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
567
- $startStops=1;
568
  $pos_angle = $bgr[0];
569
  }
570
  else if (trim($first[(count($first)-1)]) === "0") {
@@ -572,7 +572,7 @@ function parseMozGradient($bg) {
572
  $pos_angle = $bgr[0];
573
  }
574
  else if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[0])) {
575
- $startStops=1;
576
  $shape_size = $bgr[0];
577
  }
578
  else if (!$checkCol) {
@@ -580,7 +580,7 @@ function parseMozGradient($bg) {
580
  $pos_angle = $bgr[0];
581
  }
582
  if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[1])) {
583
- $startStops=2;
584
  $shape_size = $bgr[1];
585
  }
586
 
@@ -593,12 +593,12 @@ function parseMozGradient($bg) {
593
  else if (preg_match('/bottom/i',$pos_angle)) { $starty = 0; }
594
  // Check for %? ?% or %%
595
  if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
596
- else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) {
597
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
598
  if ($tmp) { $startx = $m[1]; }
599
  }
600
  if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
601
- else if (!isset($starty) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) {
602
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
603
  if ($tmp) { $starty = $m[1]; }
604
  }
@@ -662,11 +662,11 @@ function parseMozGradient($bg) {
662
  else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; } // transparency from cmyka()
663
  else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; } // transparency converted from rgba or cmyka()
664
 
665
- if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) {
666
  $stop['offset'] = $m[1]/100;
667
  if ($stop['offset']>1) { unset($stop['offset']); }
668
  }
669
- else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) {
670
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
671
  $stop['offset'] = $el[1];
672
  }
@@ -675,7 +675,7 @@ function parseMozGradient($bg) {
675
  if (count($g['stops'] )) { return $g; }
676
  }
677
  return array();
678
- }
679
 
680
  function parseBackgroundGradient($bg) {
681
  // background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5; or
@@ -684,18 +684,18 @@ function parseBackgroundGradient($bg) {
684
  $v = trim($bg);
685
  $bgr = preg_split('/\s+/',$v);
686
  $g = array();
687
- if (count($bgr)> 6) {
688
  if (strtoupper(substr($bgr[0],0,1)) == 'L' && count($bgr)==7) { // linear
689
  $g['type'] = 2;
690
  //$coords = array(0,0,1,1 ); // 0 0 1 0 or 0 1 1 1 is L 2 R; 1,1,0,1 is R2L; 1,1,1,0 is T2B; 1,0,1,1 is B2T
691
- // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
692
  // The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
693
  $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6]);
694
  }
695
  else if (count($bgr)==8) { // radial
696
  $g['type'] = 3;
697
- // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
698
- // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
699
  // (fx, fy) should be inside the circle, otherwise some areas will not be defined
700
  $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6], $bgr[7]);
701
  }
@@ -719,5 +719,3 @@ function parseBackgroundGradient($bg) {
719
 
720
 
721
  }
722
-
723
- ?>
4
 
5
  var $mpdf = null;
6
 
7
+ function __construct(&$mpdf) {
8
  $this->mpdf = $mpdf;
9
  }
10
 
57
  }
58
  }
59
  // TRANSPARENCY
60
+ if ($trans) {
61
  $this->mpdf->gradients[$n]['stream_trans']='';
62
  for($i=0;$i<count($patch_array);$i++){
63
  $this->mpdf->gradients[$n]['stream_trans'].=chr($patch_array[$i]['f']);
79
  }
80
  }
81
  }
82
+ $this->mpdf->gradients[$n]['trans'] = true;
83
  $s .= ' /TGS'.$n.' gs ';
84
  }
85
  //paint the gradient
92
 
93
 
94
  // type = linear:2; radial: 3;
95
+ // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
96
  // The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
97
+ // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
98
+ // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
99
  // (fx, fy) should be inside the circle, otherwise some areas will not be defined
100
  // $col = array(R,G,B/255); or array(G/255); or array(C,M,Y,K/100)
101
  // $stops = array('col'=>$col [, 'opacity'=>0-1] [, 'offset'=>0-1])
112
  $usew = $bboxw;
113
  $useh = $bboxh;
114
  if ($type < 1) { $type = 2; }
115
+ if ($coords[0]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[0],$m)) {
116
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
117
  if ($tmp) { $coords[0] = $tmp/$w; }
118
  }
119
+ if ($coords[1]!==false && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$coords[1],$m)) {
120
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
121
  if ($tmp) { $coords[1] = 1-($tmp/$h); }
122
  }
123
  // LINEAR
124
+ if ($type == 2) {
125
  $angle = $coords[4];
126
  $repeat = $coords[5];
127
  // ALL POINTS SET (default for custom mPDF linear gradient) - no -moz
129
  // do nothing - coords used as they are
130
  }
131
 
132
+ // If both a <point> and <angle> are defined, the gradient axis starts from the point and runs along the angle. The end point is
133
  // defined as before - in this case start points may not be in corners, and axis may not correctly fall in the right quadrant.
134
  // NO end points (Angle defined & Start points)
135
  else if ($angle!==false && $coords[0]!==false && $coords[1]!==false && $coords[2]===false && $coords[3]===false) {
138
  else if ($angle==180) { if ($coords[4]==0) $coords[2]=-1; else $coords[2]=0; $coords[3]=$coords[1]; }
139
  else if ($angle==270) { $coords[2]=$coords[0]; if ($coords[1]==0) $coords[3]=-1; else $coords[3]=0; }
140
  else {
141
+ $endx=1; $endy=1;
142
+ if ($angle <=90) {
143
  if ($angle <=45) { $endy=tan(deg2rad($angle)); }
144
  else { $endx=tan(deg2rad(90-$angle)); }
145
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
146
  $ny = 1 - $coords[1] - (tan($b) * (1-$coords[0]));
147
  $tx = sin($b) * cos($b) * $ny;
148
  $ty = cos($b) * cos($b) * $ny;
149
+ $coords[2] = 1+$tx; $coords[3] = 1-$ty;
150
  }
151
+ else if ($angle <=180) {
152
  if ($angle <=135) { $endx=tan(deg2rad($angle-90)); }
153
  else { $endy=tan(deg2rad(180-$angle)); }
154
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
157
  $ty = cos($b) * cos($b) * $ny;
158
  $coords[2] = -$tx; $coords[3] = 1-$ty;
159
  }
160
+ else if ($angle <=270) {
161
  if ($angle <=225) { $endy=tan(deg2rad($angle-180)); }
162
  else { $endx=tan(deg2rad(270-$angle)); }
163
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
164
  $ny = $coords[1] - (tan($b) * ($coords[0]));
165
  $tx = sin($b) * cos($b) * $ny;
166
  $ty = cos($b) * cos($b) * $ny;
167
+ $coords[2] = -$tx; $coords[3] = $ty;
168
  }
169
+ else {
170
  if ($angle <=315) { $endx=tan(deg2rad($angle-270)); }
171
  else { $endy=tan(deg2rad(360-$angle)); }
172
  $b = atan2(($endy*$bboxh), ($endx*$bboxw));
173
  $ny = $coords[1] - (tan($b) * (1-$coords[0]));
174
  $tx = sin($b) * cos($b) * $ny;
175
  $ty = cos($b) * cos($b) * $ny;
176
+ $coords[2] = 1+$tx; $coords[3] = $ty;
177
 
178
  }
179
  }
180
  }
181
 
182
+ // -moz If the first parameter is only an <angle>, the gradient axis starts from the box's corner that would ensure the
183
+ // axis goes through the box. The axis runs along the specified angle. The end point of the axis is defined such that the
184
  // farthest corner of the box from the starting point is perpendicular to the gradient axis at that point.
185
  // NO end points or Start points (Angle defined)
186
  else if ($angle!==false && $coords[0]===false && $coords[1]===false) {
189
  else if ($angle==180) { $coords[0]=1; $coords[1]=0; $coords[2]=0; $coords[3]=0; }
190
  else if ($angle==270) { $coords[0]=0; $coords[1]=1; $coords[2]=0; $coords[3]=0; }
191
  else {
192
+ if ($angle <=90) {
193
+ $coords[0]=0; $coords[1]=0;
194
  if ($angle <=45) { $endx=1; $endy=tan(deg2rad($angle)); }
195
  else { $endx=tan(deg2rad(90-$angle)); $endy=1; }
196
  }
197
+ else if ($angle <=180) {
198
+ $coords[0]=1; $coords[1]=0;
199
  if ($angle <=135) { $endx=tan(deg2rad($angle-90)); $endy=1; }
200
  else { $endx=1; $endy=tan(deg2rad(180-$angle)); }
201
  }
202
+ else if ($angle <=270) {
203
+ $coords[0]=1; $coords[1]=1;
204
  if ($angle <=225) { $endx=1; $endy=tan(deg2rad($angle-180)); }
205
  else { $endx=tan(deg2rad(270-$angle)); $endy=1; }
206
  }
207
+ else {
208
+ $coords[0]=0; $coords[1]=1;
209
  if ($angle <=315) { $endx=tan(deg2rad($angle-270)); $endy=1; }
210
  else { $endx=1; $endy=tan(deg2rad(360-$angle)); }
211
  }
221
  else { $coords[2] = $x1; $coords[3] = 1-$y1; }
222
  }
223
  }
224
+ // -moz If the first parameter to the gradient function is only a <point>, the gradient axis starts from the specified point,
225
+ // and ends at the point you would get if you rotated the starting point by 180 degrees about the center of the box that the
226
  // gradient is to be applied to.
227
  // NO angle and NO end points (Start points defined)
228
  else if ((!isset($angle) || $angle===false) && $coords[0]!==false && $coords[1]!==false) { // should have start and end defined
230
  $angle = rad2deg(atan2($coords[3]-$coords[1],$coords[2]-$coords[0]));
231
  if ($angle < 0) { $angle += 360; }
232
  else if ($angle > 360) { $angle -= 360; }
233
+ if ($angle!=0 && $angle!=360 && $angle!=90 && $angle!=180 && $angle!=270) {
234
  if ($w >= $h) {
235
  $coords[1] *= $h/$w ;
236
  $coords[3] *= $h/$w ;
245
  }
246
  }
247
 
248
+ // -moz If neither a <point> or <angle> is specified, i.e. the entire function consists of only <stop> values, the gradient
249
  // axis starts from the top of the box and runs vertically downwards, ending at the bottom of the box.
250
  else { // default values T2B
251
  // All values are set in parseMozGradient - so won't appear here
257
  }
258
 
259
  // RADIAL
260
+ else if ($type == 3) {
261
  $radius = $coords[4];
262
  $angle = $coords[5]; // ?? no effect
263
  $shape = $coords[6];
311
  }
312
  }
313
  if ($radius==0) { $radius=0.001; } // to prevent error
314
+ $coords[4] = $radius;
315
  }
316
 
317
  // -moz If entire function consists of only <stop> values
318
+ else { // default values
319
  // All values are set in parseMozGradient - so won't appear here
320
  $coords = array(0.5,0.5,0.5,0.5); // default for radial gradient (centred)
321
  }
343
  else { $axis_length = $coords[4]*$usew; } // Absolute lengths are meaningless for an ellipse - Firefox uses Width as reference
344
 
345
  for($i=0;$i<count($stops);$i++) {
346
+ if (isset($stops[$i]['offset']) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$stops[$i]['offset'],$m)) {
347
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
348
  $stops[$i]['offset'] = $tmp/$axis_length;
349
  }
350
  }
351
 
352
 
353
+ if (isset($stops[0]['offset']) && $stops[0]['offset']>0) {
354
+ $firststop = $stops[0];
355
  $firststop['offset'] = 0;
356
+ array_unshift($stops, $firststop);
357
  }
358
  if (!$repeat && isset($stops[(count($stops)-1)]['offset']) && $stops[(count($stops)-1)]['offset']<1) {
359
+ $endstop = $stops[(count($stops)-1)];
360
  $endstop['offset'] = 1;
361
+ $stops[] = $endstop;
362
  }
363
+ if ($stops[0]['offset'] > $stops[(count($stops)-1)]['offset']) {
364
  $stops[0]['offset'] = 0;
365
  $stops[(count($stops)-1)]['offset'] = 1;
366
  }
376
  else {
377
  $this->mpdf->gradients[$n]['stops'][$i]['col'] = sprintf('%.3F %.3F %.3F', (ord($stops[$i]['col']{1})/255), (ord($stops[$i]['col']{2})/255), (ord($stops[$i]['col']{3})/255));
378
  }
379
+ if (!isset($stops[$i]['opacity'])) { $stops[$i]['opacity'] = 1; }
380
+ else if ($stops[$i]['opacity'] > 1 || $stops[$i]['opacity'] < 0) { $stops[$i]['opacity'] = 1; }
381
+ else if ($stops[$i]['opacity'] < 1) {
382
+ $trans = true;
383
  }
384
  $this->mpdf->gradients[$n]['stops'][$i]['opacity'] = $stops[$i]['opacity'];
385
  // OFFSET
386
  if ($i>0 && $i<(count($stops)-1)) {
387
+ if (!isset($stops[$i]['offset']) || (isset($stops[$i+1]['offset']) && $stops[$i]['offset']>$stops[$i+1]['offset']) || $stops[$i]['offset']<$stops[$i-1]['offset']) {
388
+ if (isset($stops[$i-1]['offset']) && isset($stops[$i+1]['offset'])) {
389
+ $stops[$i]['offset'] = ($stops[$i-1]['offset']+$stops[$i+1]['offset'])/2;
390
  }
391
  else {
392
  for($j=($i+1);$j<count($stops);$j++) {
426
  }
427
  }
428
 
429
+ if ($trans) {
430
+ $this->mpdf->gradients[$n]['trans'] = true;
431
  $s .= ' /TGS'.$n.' gs ';
432
  }
433
+ if (!is_array($extend) || count($extend) <1) {
434
  $extend=array('true', 'true'); // These are supposed to be quoted - appear in PDF file as text
435
  }
436
  $this->mpdf->gradients[$n]['coords'] = $coords;
445
 
446
 
447
  function parseMozGradient($bg) {
448
+ // background[-image]: -moz-linear-gradient(left, #c7Fdde 20%, #FF0000 );
449
  // background[-image]: linear-gradient(left, #c7Fdde 20%, #FF0000 ); // CSS3
450
  if (preg_match('/repeating-/',$bg)) { $repeat = true; }
451
  else { $repeat = false; }
464
  // Is first part $bgr[0] a valid point/angle?
465
  $first = preg_split('/\s+/',trim($bgr[0]));
466
  if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
467
+ $startStops = 1;
468
  }
469
  else if (trim($first[(count($first)-1)]) === "0") {
470
  $startStops = 1;
471
  }
472
  else {
473
  $check = $this->mpdf->ConvertColor($first[0]);
474
+ if ($check) $startStops = 0;
475
+ else $startStops = 1;
476
  }
477
  // first part a valid point/angle?
478
  if ($startStops == 1) { // default values
492
  else if (preg_match('/bottom/i',$bgr[0])) { $starty = 0; }
493
  // Check for %? ?% or %%
494
  if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
495
+ else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) {
496
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
497
  if ($tmp) { $startx = $m[1]; }
498
  }
499
  if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
500
+ else if (!isset($starty) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) {
501
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
502
  if ($tmp) { $starty = $m[1]; }
503
  }
532
  else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; } // transparency from cmyka()
533
  else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; } // transparency converted from rgba or cmyka()
534
 
535
+ if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) {
536
  $stop['offset'] = $m[1]/100;
537
  if ($stop['offset']>1) { unset($stop['offset']); }
538
  }
539
+ else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) {
540
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
541
  if ($tmp) { $stop['offset'] = $m[1]; }
542
  }
558
  for($i=0;$i<count($bgr);$i++) { $bgr[$i] = preg_replace('/@/', ',', $bgr[$i]); }
559
 
560
  // Is first part $bgr[0] a valid point/angle?
561
+ $startStops = 0;
562
  $pos_angle = false;
563
  $shape_size = false;
564
  $first = preg_split('/\s+/',trim($bgr[0]));
565
  $checkCol = $this->mpdf->ConvertColor($first[0]);
566
  if (preg_match('/(left|center|right|bottom|top|deg|grad|rad)/i',$bgr[0]) && !preg_match('/(<#|rgb|rgba|hsl|hsla)/i',$bgr[0])) {
567
+ $startStops=1;
568
  $pos_angle = $bgr[0];
569
  }
570
  else if (trim($first[(count($first)-1)]) === "0") {
572
  $pos_angle = $bgr[0];
573
  }
574
  else if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[0])) {
575
+ $startStops=1;
576
  $shape_size = $bgr[0];
577
  }
578
  else if (!$checkCol) {
580
  $pos_angle = $bgr[0];
581
  }
582
  if (preg_match('/(circle|ellipse|closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/i',$bgr[1])) {
583
+ $startStops=2;
584
  $shape_size = $bgr[1];
585
  }
586
 
593
  else if (preg_match('/bottom/i',$pos_angle)) { $starty = 0; }
594
  // Check for %? ?% or %%
595
  if (preg_match('/(\d+)[%]/i',$first[0],$m)) { $startx = $m[1]/100; }
596
+ else if (!isset($startx) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[0],$m)) {
597
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
598
  if ($tmp) { $startx = $m[1]; }
599
  }
600
  if (isset($first[1]) && preg_match('/(\d+)[%]/i',$first[1],$m)) { $starty = 1 - ($m[1]/100); }
601
+ else if (!isset($starty) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$first[1],$m)) {
602
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
603
  if ($tmp) { $starty = $m[1]; }
604
  }
662
  else if ($col{0}==6) { $stop['opacity'] = ord($col{5})/100; } // transparency from cmyka()
663
  else if ($col{0}==1 && $col{2}==1) { $stop['opacity'] = ord($col{3})/100; } // transparency converted from rgba or cmyka()
664
 
665
+ if (isset($el[1]) && preg_match('/(\d+)[%]/',$el[1],$m)) {
666
  $stop['offset'] = $m[1]/100;
667
  if ($stop['offset']>1) { unset($stop['offset']); }
668
  }
669
+ else if (isset($el[1]) && preg_match('/([0-9.]+(px|em|ex|pc|pt|cm|mm|in))/i',$el[1],$m)) {
670
  $tmp = $this->mpdf->ConvertSize($m[1],$this->mpdf->w,$this->mpdf->FontSize,false);
671
  $stop['offset'] = $el[1];
672
  }
675
  if (count($g['stops'] )) { return $g; }
676
  }
677
  return array();
678
+ }
679
 
680
  function parseBackgroundGradient($bg) {
681
  // background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5; or
684
  $v = trim($bg);
685
  $bgr = preg_split('/\s+/',$v);
686
  $g = array();
687
+ if (count($bgr)> 6) {
688
  if (strtoupper(substr($bgr[0],0,1)) == 'L' && count($bgr)==7) { // linear
689
  $g['type'] = 2;
690
  //$coords = array(0,0,1,1 ); // 0 0 1 0 or 0 1 1 1 is L 2 R; 1,1,0,1 is R2L; 1,1,1,0 is T2B; 1,0,1,1 is B2T
691
+ // Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
692
  // The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
693
  $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6]);
694
  }
695
  else if (count($bgr)==8) { // radial
696
  $g['type'] = 3;
697
+ // Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
698
+ // (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
699
  // (fx, fy) should be inside the circle, otherwise some areas will not be defined
700
  $g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6], $bgr[7]);
701
  }
719
 
720
 
721
  }
 
 
mPDF/classes/indic.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  class indic {
4
 
5
- function indic() {
6
 
7
  }
8
 
@@ -16,7 +16,7 @@ function substituteIndic($earr, $lang, $font) {
16
  }
17
 
18
  foreach($earr as $eid=>$char) {
19
- $earr[$eid] = sprintf("%04s", strtoupper(dechex($char)));
20
  }
21
  $vstr = "0020 ".implode(" ",$earr)." 0020";
22
  //============================
@@ -69,7 +69,7 @@ function substituteIndic($earr, $lang, $font) {
69
  // mPDF 5.0.044
70
  // If left-based vowel has now been shifted to left of RA/Halant (09B0/09CD)
71
  // Convert here to above-line form (E068) as it would get missed later
72
- // e.g. 09B0 09CD 09AD 09C7 would be changed above =>
73
  // e.g. 09C7 09B0 09CD 09AD. The 09B0 09CD should => E068
74
  // ??? need to add 09BF as well (09BF|09C7|09C8)
75
  $vstr = preg_replace('/(09C7|09C8) 09B0 09CD/', '\\1 E068', $vstr);
@@ -92,7 +92,7 @@ function substituteIndic($earr, $lang, $font) {
92
  $nukta = "0A3C";
93
  $halant = "0A4D";
94
  $vstr = preg_replace('/([A-F0-9]{4}) '.$prebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
95
- $vstr = preg_replace('/([A-F0-9]{4}) '.$prebasedvowels.' '.$nukta.'/','\\2 \\1 '.$nukta, $vstr); // before NUKTA
96
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$prebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
97
  }
98
 
@@ -121,7 +121,7 @@ function substituteIndic($earr, $lang, $font) {
121
  $vstr = str_replace('0B4C','0B47 0B57', $vstr); // 2-part Vowel
122
  $orprebasedvowels = "(0B47)";
123
  // No nukta
124
- $halant = "0B4D";
125
  $vstr = preg_replace('/([A-F0-9]{4}) '.$orprebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
126
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$orprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
127
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$orprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
@@ -130,14 +130,14 @@ function substituteIndic($earr, $lang, $font) {
130
  // MALAYALAM
131
  else if ($lang=='ml') {
132
  // Chillus - old forms - remove ZWNJ after
133
- // This font Volt rules recognises e.g. "Na Halant(Virama)" as ChilluN
134
  $vstr = preg_replace('/(0D23 0D4D|0D28 0D4D|0D30 0D4D|0D32 0D4D|0D33 0D4D) 200D/','\\1', $vstr);
135
  // See Chillus in Unicode [http://en.wikipedia.org/wiki/Malayalam_script]
136
- $vstr = str_replace('0D7A','0D23 0D4D', $vstr); // [mlymChilluNn]
137
- $vstr = str_replace('0D7B','0D28 0D4D', $vstr); // [mlymChilluN]
138
- $vstr = str_replace('0D7C','0D30 0D4D', $vstr); // [mlymChilluR]
139
- $vstr = str_replace('0D7D','0D32 0D4D', $vstr); // [mlymChilluL]
140
- $vstr = str_replace('0D7E','0D33 0D4D', $vstr); // [mlymChilluLl]
141
  /*
142
  // Chillus - 0D7A-0D7E not in font directly, but as E005-E009
143
  $vstr = preg_replace('/0D23 0D4D 200D/','0D7A', $vstr);
@@ -146,12 +146,12 @@ function substituteIndic($earr, $lang, $font) {
146
  $vstr = preg_replace('/0D32 0D4D 200D/','0D7D', $vstr);
147
  $vstr = preg_replace('/0D33 0D4D 200D/','0D7E', $vstr);
148
 
149
- $vstr = preg_replace('/0D7F/','E004', $vstr); // [mlymChilluK]
150
- $vstr = preg_replace('/0D7A/','E005', $vstr); // [mlymChilluNn]
151
- $vstr = preg_replace('/0D7B/','E006', $vstr); // [mlymChilluN]
152
- $vstr = preg_replace('/0D7C/','E007', $vstr); // [mlymChilluR]
153
- $vstr = preg_replace('/0D7D/','E008', $vstr); // [mlymChilluL]
154
- $vstr = preg_replace('/0D7E/','E009', $vstr); // [mlymChilluLl]
155
  */
156
 
157
  // MALAYALAM double-part vowels []
@@ -160,19 +160,19 @@ function substituteIndic($earr, $lang, $font) {
160
  $vstr = str_replace('0D4C','0D46 0D57', $vstr); // 2-part Vowel
161
  $mlprebasedvowels = "(0D46|0D47|0D48)";
162
  // No nukta
163
- $halant = "0D4D";
164
  $vstr = preg_replace('/([A-F0-9]{4}) '.$mlprebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
165
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$mlprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
166
  }
167
 
168
- // TELUGU
169
  else if ($lang=='te') {
170
  // TELUGU double-part vowels [0C48 -> 0C46 0C56]
171
- $vstr = str_replace('0C48','0C46 0C56', $vstr); // 2-part Vowel
172
  $prebasedvowels = "(0C46)";
173
  $abvvowels = "(0C3E|0C3F|0C40|0C46|0C47|0C4A|0C4B|0C4C|0C55)";
174
  // No nukta
175
- $halant = "0C4D";
176
  $tefullforms = "0C15|0C17|0C18|0C1A|0C1B|0C1C|0C1D|0C20|0C21|0C22|0C24|0C25|0C26|0C27|0C28|0C2A|0C2B|0C2D|0C2E|0C2F|0C30|0C33|0C35|0C36|0C37|0C38|0C39|E028|E029|E02A|E02B|E078|E07A|E07B";
177
  $vstr = preg_replace('/('.$tefullforms .') '.$halant.' ('.$tefullforms .') '.$abvvowels .'/','\\1 \\3 '.$halant.' \\2', $vstr); // before HALANT
178
  }
@@ -181,13 +181,13 @@ function substituteIndic($earr, $lang, $font) {
181
  // KANNADA
182
  else if ($lang=='kn') {
183
  // KANNADA double-part vowels [0CC8 -> 0CC6 0CD6]
184
- $vstr = str_replace('0CC0','0CBF 0CD5', $vstr); // 2-part Vowel
185
- $vstr = str_replace('0CC7','0CC6 0CD5', $vstr); // 2-part Vowel
186
  $vstr = str_replace('0CC8','0CC6 0CD6', $vstr); // 2-part Vowel AI - no glyph for single
187
- $vstr = str_replace('0CCA','0CC6 0CC2', $vstr); // 2-part Vowel
188
- $vstr = str_replace('0CCB','0CC6 0CC2 0CD5', $vstr); // 2-part Vowel
189
  $prebasedvowels = "(0CBF|0CC6)";
190
- $halant = "0CCD";
191
  }
192
 
193
 
@@ -205,12 +205,12 @@ function substituteIndic($earr, $lang, $font) {
205
  $vstr = str_replace('0AB0 0AC2','E02E', $vstr); // Ra VowelUu => SpecialForm RaUu
206
  }
207
 
208
- // TELUGU Ra Halant <Consonant> Halant => halfRa Halant<Consonant> Halant
209
  if ($lang=='te') {
210
- $vstr = preg_replace('/0C30 0C4D ([A-F0-9]{4}) 0C4D/','E021 0C4D \\1 0C4D', $vstr);
211
  }
212
 
213
- // KANNADA
214
  // Reph at end of word becomes E0CC instead of E00B
215
  if ($lang=='kn') {
216
  $vstr = str_replace('0CB0 0CCD 0020','E0CC 0020', $vstr); // mPDF 5.3.87
@@ -222,7 +222,7 @@ function substituteIndic($earr, $lang, $font) {
222
  foreach($voltdata[$font] AS $rid=>$reps) {
223
  //echo $rid . ': ' . $vstr.'<br />';
224
  $vstr = preg_replace('/'.$reps['match'].'/',$reps['replace'], $vstr);
225
- }
226
  //echo $vstr.'<br />'; exit;
227
 
228
 
@@ -230,7 +230,7 @@ function substituteIndic($earr, $lang, $font) {
230
 
231
  // SPECIALS
232
 
233
- // KANNADA
234
  // <Base> <BelowBase1> [<BelowBase2> ] MatraI -> <Base/MatraI ligature> <Belowbase1> etc
235
  if ($lang=='kn') {
236
  $matraI = "0CBF";
@@ -244,13 +244,13 @@ function substituteIndic($earr, $lang, $font) {
244
  }
245
  }
246
 
247
- // KANNADA
248
- // [KanTtaFull] [matraI] => [KanTtaPartial] [matraI]
249
  if ($lang=='kn') {
250
  $vstr = preg_replace('/0C9F '.$matraI.'/', 'E015 '.$matraI, $vstr);
251
  }
252
 
253
- // ORIYA
254
  if ($lang=='or') {
255
  // SpecialCase Ra[0B30] Halant still left before [oryaFullNnNna] => E00F
256
  $vstr = preg_replace('/0B30 '.$halant.' E00F/','E00F E069', $vstr); // convert to Reph
@@ -358,7 +358,7 @@ function substituteIndic($earr, $lang, $font) {
358
 
359
  // MALAYALAM Shift Reph to LEFT [E00E] (mlylmRaVattu)
360
  else if ($lang=='ml') {
361
- $halant = "0D4D";
362
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' 0D30/','E00E \\1', $vstr); // 0D30 = Ra
363
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$mlprebasedvowels .' 0D30/','\\2 E00E \\1', $vstr); // 0D30 = Ra
364
 
@@ -376,7 +376,7 @@ function substituteIndic($earr, $lang, $font) {
376
 
377
  // SHIFT post-based vowels to Left of SmallForms (NOT to left of full forms)
378
 
379
- // TELUGU Shift
380
  if ($lang=='te') {
381
  // NB $tevowels defined above
382
  // NB $tefullforms defined above
@@ -387,7 +387,7 @@ function substituteIndic($earr, $lang, $font) {
387
  }
388
 
389
 
390
- // KANNADA Shift
391
  else if ($lang=='kn') {
392
  $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6"
393
  // mPDF 5.3.87 Shouldn't swop E082 and E047 (belowbase1) below
@@ -409,7 +409,7 @@ function substituteIndic($earr, $lang, $font) {
409
  //============================
410
  // Clear unwanted ZWJ, ZWNJ
411
  // MALAYALAM
412
- if ($lang=='ml') {
413
  $vstr = preg_replace('/(200C|200D) /','', $vstr);
414
  }
415
 
@@ -429,5 +429,3 @@ function substituteIndic($earr, $lang, $font) {
429
 
430
 
431
  }
432
-
433
- ?>
2
 
3
  class indic {
4
 
5
+ function __construct() {
6
 
7
  }
8
 
16
  }
17
 
18
  foreach($earr as $eid=>$char) {
19
+ $earr[$eid] = sprintf("%04s", strtoupper(dechex($char)));
20
  }
21
  $vstr = "0020 ".implode(" ",$earr)." 0020";
22
  //============================
69
  // mPDF 5.0.044
70
  // If left-based vowel has now been shifted to left of RA/Halant (09B0/09CD)
71
  // Convert here to above-line form (E068) as it would get missed later
72
+ // e.g. 09B0 09CD 09AD 09C7 would be changed above =>
73
  // e.g. 09C7 09B0 09CD 09AD. The 09B0 09CD should => E068
74
  // ??? need to add 09BF as well (09BF|09C7|09C8)
75
  $vstr = preg_replace('/(09C7|09C8) 09B0 09CD/', '\\1 E068', $vstr);
92
  $nukta = "0A3C";
93
  $halant = "0A4D";
94
  $vstr = preg_replace('/([A-F0-9]{4}) '.$prebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
95
+ $vstr = preg_replace('/([A-F0-9]{4}) '.$prebasedvowels.' '.$nukta.'/','\\2 \\1 '.$nukta, $vstr); // before NUKTA
96
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$prebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
97
  }
98
 
121
  $vstr = str_replace('0B4C','0B47 0B57', $vstr); // 2-part Vowel
122
  $orprebasedvowels = "(0B47)";
123
  // No nukta
124
+ $halant = "0B4D";
125
  $vstr = preg_replace('/([A-F0-9]{4}) '.$orprebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
126
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$orprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
127
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$orprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
130
  // MALAYALAM
131
  else if ($lang=='ml') {
132
  // Chillus - old forms - remove ZWNJ after
133
+ // This font Volt rules recognises e.g. "Na Halant(Virama)" as ChilluN
134
  $vstr = preg_replace('/(0D23 0D4D|0D28 0D4D|0D30 0D4D|0D32 0D4D|0D33 0D4D) 200D/','\\1', $vstr);
135
  // See Chillus in Unicode [http://en.wikipedia.org/wiki/Malayalam_script]
136
+ $vstr = str_replace('0D7A','0D23 0D4D', $vstr); // [mlymChilluNn]
137
+ $vstr = str_replace('0D7B','0D28 0D4D', $vstr); // [mlymChilluN]
138
+ $vstr = str_replace('0D7C','0D30 0D4D', $vstr); // [mlymChilluR]
139
+ $vstr = str_replace('0D7D','0D32 0D4D', $vstr); // [mlymChilluL]
140
+ $vstr = str_replace('0D7E','0D33 0D4D', $vstr); // [mlymChilluLl]
141
  /*
142
  // Chillus - 0D7A-0D7E not in font directly, but as E005-E009
143
  $vstr = preg_replace('/0D23 0D4D 200D/','0D7A', $vstr);
146
  $vstr = preg_replace('/0D32 0D4D 200D/','0D7D', $vstr);
147
  $vstr = preg_replace('/0D33 0D4D 200D/','0D7E', $vstr);
148
 
149
+ $vstr = preg_replace('/0D7F/','E004', $vstr); // [mlymChilluK]
150
+ $vstr = preg_replace('/0D7A/','E005', $vstr); // [mlymChilluNn]
151
+ $vstr = preg_replace('/0D7B/','E006', $vstr); // [mlymChilluN]
152
+ $vstr = preg_replace('/0D7C/','E007', $vstr); // [mlymChilluR]
153
+ $vstr = preg_replace('/0D7D/','E008', $vstr); // [mlymChilluL]
154
+ $vstr = preg_replace('/0D7E/','E009', $vstr); // [mlymChilluLl]
155
  */
156
 
157
  // MALAYALAM double-part vowels []
160
  $vstr = str_replace('0D4C','0D46 0D57', $vstr); // 2-part Vowel
161
  $mlprebasedvowels = "(0D46|0D47|0D48)";
162
  // No nukta
163
+ $halant = "0D4D";
164
  $vstr = preg_replace('/([A-F0-9]{4}) '.$mlprebasedvowels.'/','\\2 \\1', $vstr); // vowel sign pre-based shift left
165
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$mlprebasedvowels.'/','\\2 \\1 '.$halant, $vstr); // before CHAR HALANT
166
  }
167
 
168
+ // TELUGU
169
  else if ($lang=='te') {
170
  // TELUGU double-part vowels [0C48 -> 0C46 0C56]
171
+ $vstr = str_replace('0C48','0C46 0C56', $vstr); // 2-part Vowel
172
  $prebasedvowels = "(0C46)";
173
  $abvvowels = "(0C3E|0C3F|0C40|0C46|0C47|0C4A|0C4B|0C4C|0C55)";
174
  // No nukta
175
+ $halant = "0C4D";
176
  $tefullforms = "0C15|0C17|0C18|0C1A|0C1B|0C1C|0C1D|0C20|0C21|0C22|0C24|0C25|0C26|0C27|0C28|0C2A|0C2B|0C2D|0C2E|0C2F|0C30|0C33|0C35|0C36|0C37|0C38|0C39|E028|E029|E02A|E02B|E078|E07A|E07B";
177
  $vstr = preg_replace('/('.$tefullforms .') '.$halant.' ('.$tefullforms .') '.$abvvowels .'/','\\1 \\3 '.$halant.' \\2', $vstr); // before HALANT
178
  }
181
  // KANNADA
182
  else if ($lang=='kn') {
183
  // KANNADA double-part vowels [0CC8 -> 0CC6 0CD6]
184
+ $vstr = str_replace('0CC0','0CBF 0CD5', $vstr); // 2-part Vowel
185
+ $vstr = str_replace('0CC7','0CC6 0CD5', $vstr); // 2-part Vowel
186
  $vstr = str_replace('0CC8','0CC6 0CD6', $vstr); // 2-part Vowel AI - no glyph for single
187
+ $vstr = str_replace('0CCA','0CC6 0CC2', $vstr); // 2-part Vowel
188
+ $vstr = str_replace('0CCB','0CC6 0CC2 0CD5', $vstr); // 2-part Vowel
189
  $prebasedvowels = "(0CBF|0CC6)";
190
+ $halant = "0CCD";
191
  }
192
 
193
 
205
  $vstr = str_replace('0AB0 0AC2','E02E', $vstr); // Ra VowelUu => SpecialForm RaUu
206
  }
207
 
208
+ // TELUGU Ra Halant <Consonant> Halant => halfRa Halant<Consonant> Halant
209
  if ($lang=='te') {
210
+ $vstr = preg_replace('/0C30 0C4D ([A-F0-9]{4}) 0C4D/','E021 0C4D \\1 0C4D', $vstr);
211
  }
212
 
213
+ // KANNADA
214
  // Reph at end of word becomes E0CC instead of E00B
215
  if ($lang=='kn') {
216
  $vstr = str_replace('0CB0 0CCD 0020','E0CC 0020', $vstr); // mPDF 5.3.87
222
  foreach($voltdata[$font] AS $rid=>$reps) {
223
  //echo $rid . ': ' . $vstr.'<br />';
224
  $vstr = preg_replace('/'.$reps['match'].'/',$reps['replace'], $vstr);
225
+ }
226
  //echo $vstr.'<br />'; exit;
227
 
228
 
230
 
231
  // SPECIALS
232
 
233
+ // KANNADA
234
  // <Base> <BelowBase1> [<BelowBase2> ] MatraI -> <Base/MatraI ligature> <Belowbase1> etc
235
  if ($lang=='kn') {
236
  $matraI = "0CBF";
244
  }
245
  }
246
 
247
+ // KANNADA
248
+ // [KanTtaFull] [matraI] => [KanTtaPartial] [matraI]
249
  if ($lang=='kn') {
250
  $vstr = preg_replace('/0C9F '.$matraI.'/', 'E015 '.$matraI, $vstr);
251
  }
252
 
253
+ // ORIYA
254
  if ($lang=='or') {
255
  // SpecialCase Ra[0B30] Halant still left before [oryaFullNnNna] => E00F
256
  $vstr = preg_replace('/0B30 '.$halant.' E00F/','E00F E069', $vstr); // convert to Reph
358
 
359
  // MALAYALAM Shift Reph to LEFT [E00E] (mlylmRaVattu)
360
  else if ($lang=='ml') {
361
+ $halant = "0D4D";
362
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' 0D30/','E00E \\1', $vstr); // 0D30 = Ra
363
  $vstr = preg_replace('/([A-F0-9]{4}) '.$halant.' '.$mlprebasedvowels .' 0D30/','\\2 E00E \\1', $vstr); // 0D30 = Ra
364
 
376
 
377
  // SHIFT post-based vowels to Left of SmallForms (NOT to left of full forms)
378
 
379
+ // TELUGU Shift
380
  if ($lang=='te') {
381
  // NB $tevowels defined above
382
  // NB $tefullforms defined above
387
  }
388
 
389
 
390
+ // KANNADA Shift
391
  else if ($lang=='kn') {
392
  $knvowels = "0CBE|0CC0|0CC1|0CC2|0CC3|0CC4|0CC7|0CC8|0CCA|0CCB|0CD5|0CD6"
393
  // mPDF 5.3.87 Shouldn't swop E082 and E047 (belowbase1) below
409
  //============================
410
  // Clear unwanted ZWJ, ZWNJ
411
  // MALAYALAM
412
+ if ($lang=='ml') {
413
  $vstr = preg_replace('/(200C|200D) /','', $vstr);
414
  }
415
 
429
 
430
 
431
  }
 
 
mPDF/classes/meter.php CHANGED
@@ -220,5 +220,3 @@ function makeSVG($tag, $type, $value, $max, $min, $optimum, $low, $high) {
220
 
221
 
222
  } // end of class
223
-
224
- ?>
220
 
221
 
222
  } // end of class
 
 
mPDF/classes/svg.php CHANGED
@@ -31,7 +31,7 @@ class SVG {
31
  var $kp; // mPDF 4.4.003 convert pixels to PDF units
32
  var $pathBBox; // mPDF 5.0.039
33
 
34
- function SVG(&$mpdf){
35
  $this->svg_gradient = array();
36
  $this->svg_shadinglist = array();
37
  $this->txt_data = array();
@@ -2595,6 +2595,3 @@ function _testIntersect($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4) {
2595
  return false;
2596
  }
2597
 
2598
-
2599
-
2600
- ?>
31
  var $kp; // mPDF 4.4.003 convert pixels to PDF units
32
  var $pathBBox; // mPDF 5.0.039
33
 
34
+ function __construct(&$mpdf){
35
  $this->svg_gradient = array();
36
  $this->svg_shadinglist = array();
37
  $this->txt_data = array();
2595
  return false;
2596
  }
2597
 
 
 
 
mPDF/classes/tocontents.php CHANGED
@@ -27,9 +27,9 @@ var $TOC_even_header_value;
27
  var $TOC_odd_footer_value;
28
  var $TOC_even_footer_value;
29
  var $TOC_page_selector;
30
- var $m_TOC;
31
 
32
- function tocontents(&$mpdf) {
33
  $this->mpdf = $mpdf;
34
  $this->_toc=array();
35
  $this->TOCmark = 0;
@@ -45,7 +45,7 @@ function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging
45
  else { $TOCusePaging = true; }
46
  if (!$TOCuseLinking) { $TOCuseLinking = false; }
47
  if ($toc_id) {
48
- $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
49
  $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
50
  $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
51
  $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
@@ -73,7 +73,7 @@ function TOCpagebreak($tocfont='', $tocfontsize='', $tocindent='', $TOCusePaging
73
  $this->m_TOC[$toc_id]['TOCsheetsize'] = $toc_sheetsize;
74
  }
75
  else {
76
- $this->TOCmark = $this->mpdf->page;
77
  $this->TOCoutdent = $tocoutdent;
78
  $this->TOCorientation = $toc_orientation;
79
  $this->TOCuseLinking = $TOCuseLinking;
@@ -115,18 +115,18 @@ function TOC($tocfont='', $tocfontsize=0, $tocindent=0, $resetpagenum='', $pagen
115
  }
116
  $this->mpdf->AddPage($this->mpdf->CurOrientation,'',$resetpagenum, $pagenumstyle, $suppress);
117
  }
118
- else {
119
  $this->mpdf->PageNumSubstitutions[] = array('from'=>$this->mpdf->page, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=>$suppress);
120
  }
121
  if ($toc_id) {
122
- $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
123
  $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
124
  $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
125
  $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
126
  $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
127
  }
128
  else {
129
- $this->TOCmark = $this->mpdf->page;
130
  $this->TOCoutdent = $tocoutdent;
131
  $this->TOCorientation = $toc_orientation;
132
  $this->TOCuseLinking = $TOCuseLinking;
@@ -155,7 +155,7 @@ function insertTOC() {
155
  for ($toci = 0; $toci<$notocs; $toci++) {
156
  if ($toci==0 && $this->TOCmark) {
157
  $toc_id = 0;
158
- $toc_page = $this->TOCmark;
159
  $tocoutdent = $this->TOCoutdent;
160
  $toc_orientation = $this->TOCorientation;
161
  $TOCuseLinking = $this->TOCuseLinking;
@@ -240,7 +240,7 @@ function insertTOC() {
240
  if ($TOCuseLinking) { $html .= '</a>'; }
241
  }
242
  $html .= '</div>';
243
- }
244
  }
245
  $html .= '</div>';
246
  $this->mpdf->WriteHTML($html);
@@ -283,7 +283,7 @@ function insertTOC() {
283
  for ($toci = 0; $toci<$notocs; $toci++) {
284
  if ($toci==0 && $this->TOCmark) {
285
  $toc_id = 0;
286
- $toc_page = $this->TOCmark + $added_toc_pages;
287
  $toc_orientation = $this->TOCorientation;
288
  $TOCuseLinking = $this->TOCuseLinking;
289
  $TOCusePaging = $this->TOCusePaging;
@@ -438,14 +438,14 @@ function openTagTOCPAGEBREAK($attr) {
438
 
439
  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
440
  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
441
- if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); }
442
  }
443
 
444
- if ($this->mpdf->y == $this->mpdf->tMargin && (!$this->mpdf->mirrorMargins ||($this->mpdf->mirrorMargins && $this->mpdf->page % 2==1))) {
445
  if ($toc_id) { $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; }
446
  else { $this->TOCmark = $this->mpdf->page; }
447
  // Don't add a page
448
- if ($this->mpdf->page==1 && count($this->mpdf->PageNumSubstitutions)==0) {
449
  $resetpagenum = '';
450
  $pagenumstyle = '';
451
  $suppress = '';
@@ -464,5 +464,3 @@ function openTagTOCPAGEBREAK($attr) {
464
 
465
 
466
  }
467
-
468
- ?>
27
  var $TOC_odd_footer_value;
28
  var $TOC_even_footer_value;
29
  var $TOC_page_selector;
30
+ var $m_TOC;
31
 
32
+ function __construct(&$mpdf) {
33
  $this->mpdf = $mpdf;
34
  $this->_toc=array();
35
  $this->TOCmark = 0;
45
  else { $TOCusePaging = true; }
46
  if (!$TOCuseLinking) { $TOCuseLinking = false; }
47
  if ($toc_id) {
48
+ $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
49
  $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
50
  $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
51
  $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
73
  $this->m_TOC[$toc_id]['TOCsheetsize'] = $toc_sheetsize;
74
  }
75
  else {
76
+ $this->TOCmark = $this->mpdf->page;
77
  $this->TOCoutdent = $tocoutdent;
78
  $this->TOCorientation = $toc_orientation;
79
  $this->TOCuseLinking = $TOCuseLinking;
115
  }
116
  $this->mpdf->AddPage($this->mpdf->CurOrientation,'',$resetpagenum, $pagenumstyle, $suppress);
117
  }
118
+ else {
119
  $this->mpdf->PageNumSubstitutions[] = array('from'=>$this->mpdf->page, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=>$suppress);
120
  }
121
  if ($toc_id) {
122
+ $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
123
  $this->m_TOC[$toc_id]['TOCoutdent'] = $tocoutdent;
124
  $this->m_TOC[$toc_id]['TOCorientation'] = $toc_orientation;
125
  $this->m_TOC[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
126
  $this->m_TOC[$toc_id]['TOCusePaging'] = $TOCusePaging;
127
  }
128
  else {
129
+ $this->TOCmark = $this->mpdf->page;
130
  $this->TOCoutdent = $tocoutdent;
131
  $this->TOCorientation = $toc_orientation;
132
  $this->TOCuseLinking = $TOCuseLinking;
155
  for ($toci = 0; $toci<$notocs; $toci++) {
156
  if ($toci==0 && $this->TOCmark) {
157
  $toc_id = 0;
158
+ $toc_page = $this->TOCmark;
159
  $tocoutdent = $this->TOCoutdent;
160
  $toc_orientation = $this->TOCorientation;
161
  $TOCuseLinking = $this->TOCuseLinking;
240
  if ($TOCuseLinking) { $html .= '</a>'; }
241
  }
242
  $html .= '</div>';
243
+ }
244
  }
245
  $html .= '</div>';
246
  $this->mpdf->WriteHTML($html);
283
  for ($toci = 0; $toci<$notocs; $toci++) {
284
  if ($toci==0 && $this->TOCmark) {
285
  $toc_id = 0;
286
+ $toc_page = $this->TOCmark + $added_toc_pages;
287
  $toc_orientation = $this->TOCorientation;
288
  $TOCuseLinking = $this->TOCuseLinking;
289
  $TOCusePaging = $this->TOCusePaging;
438
 
439
  if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
440
  if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
441
+ if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); }
442
  }
443
 
444
+ if ($this->mpdf->y == $this->mpdf->tMargin && (!$this->mpdf->mirrorMargins ||($this->mpdf->mirrorMargins && $this->mpdf->page % 2==1))) {
445
  if ($toc_id) { $this->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; }
446
  else { $this->TOCmark = $this->mpdf->page; }
447
  // Don't add a page
448
+ if ($this->mpdf->page==1 && count($this->mpdf->PageNumSubstitutions)==0) {
449
  $resetpagenum = '';
450
  $pagenumstyle = '';
451
  $suppress = '';
464
 
465
 
466
  }
 
 
mPDF/classes/ttfontsuni.php CHANGED
@@ -10,7 +10,7 @@
10
  * Copyright (c) Ian Back, 2010 *
11
  * This class is based on The ReportLab Open Source PDF library *
12
  * written in Python - http://www.reportlab.com/software/opensource/ *
13
- * together with ideas from the OpenOffice source code and others. *
14
  * This header must be retained in any redistribution or *
15
  * modification of the file. *
16
  * *
@@ -79,7 +79,7 @@ var $TTCFonts;
79
  var $maxUniChar;
80
  var $kerninfo;
81
 
82
- function TTFontFile() {
83
  $this->maxStrLenRead = 200000; // Maximum size of glyf table to read in as string (otherwise reads each glyph from file)
84
  }
85
 
@@ -101,9 +101,9 @@ var $kerninfo;
101
  $this->TTCFonts = array();
102
  $this->version = $version = $this->read_ulong();
103
  $this->panose = array();
104
- if ($version==0x4F54544F)
105
  die("Postscript outlines are not supported");
106
- if ($version==0x74746366 && !$TTCfontID)
107
  die("ERROR - You must define the TTCfontID for a TrueType Collection in config_fonts.php (". $file.")");
108
  if (!in_array($version, array(0x00010000,0x74727565)) && !$TTCfontID)
109
  die("Not a TrueType font: version=".$version);
@@ -119,17 +119,17 @@ var $kerninfo;
119
  $this->version = $version = $this->read_ulong(); // TTFont version again now
120
  }
121
  $this->readTableDirectory($debug);
122
- $this->extractInfo($debug, $BMPonly, $kerninfo);
123
  fclose($this->fh);
124
  }
125
 
126
 
127
- function readTableDirectory($debug=false) {
128
  $this->numTables = $this->read_ushort();
129
  $this->searchRange = $this->read_ushort();
130
  $this->entrySelector = $this->read_ushort();
131
  $this->rangeShift = $this->read_ushort();
132
- $this->tables = array();
133
  for ($i=0;$i<$this->numTables;$i++) {
134
  $record = array();
135
  $record['tag'] = $this->read_tag();
@@ -155,7 +155,7 @@ var $kerninfo;
155
  }
156
  $xchecksum = $t['checksum'];
157
 
158
- if ($xchecksum != $checksum)
159
  die(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename,dechex($checksum[0]).dechex($checksum[1]),$t['tag'],dechex($xchecksum[0]).dechex($xchecksum[1])));
160
  }
161
  }
@@ -220,16 +220,16 @@ var $kerninfo;
220
  $this->_pos += 2;
221
  $s = fread($this->fh,2);
222
  $a = (ord($s[0])<<8) + ord($s[1]);
223
- if ($a & (1 << 15) ) {
224
- $a = ($a - (1 << 16));
225
  }
226
  return $a;
227
  }
228
 
229
  function unpack_short($s) {
230
  $a = (ord($s[0])<<8) + ord($s[1]);
231
- if ($a & (1 << 15) ) {
232
- $a = ($a - (1 << 16));
233
  }
234
  return $a;
235
  }
@@ -261,12 +261,12 @@ var $kerninfo;
261
  }
262
 
263
  function pack_short($val) {
264
- if ($val<0) {
265
  $val = abs($val);
266
  $val = ~$val;
267
  $val += 1;
268
  }
269
- return pack("n",$val);
270
  }
271
 
272
  function splice($stream, $offset, $value) {
@@ -279,12 +279,12 @@ var $kerninfo;
279
  }
280
 
281
  function _set_short($stream, $offset, $val) {
282
- if ($val<0) {
283
  $val = abs($val);
284
  $val = ~$val;
285
  $val += 1;
286
  }
287
- $up = pack("n",$val);
288
  return $this->splice($stream, $offset, $up);
289
  }
290
 
@@ -482,7 +482,7 @@ var $kerninfo;
482
  // head - Font header table
483
  ///////////////////////////////////
484
  $this->seek_table("head");
485
- if ($debug) {
486
  $ver_maj = $this->read_ushort();
487
  $ver_min = $this->read_ushort();
488
  if ($ver_maj != 1)
@@ -491,12 +491,12 @@ var $kerninfo;
491
 
492
  $this->skip(4);
493
  $magic = $this->read_ulong();
494
- if ($magic != 0x5F0F3CF5)
495
  die('Invalid head table magic ' .$magic);
496
  $this->skip(2);
497
  }
498
  else {
499
- $this->skip(18);
500
  }
501
  $this->unitsPerEm = $unitsPerEm = $this->read_ushort();
502
  $scale = 1000 / $unitsPerEm;
@@ -574,14 +574,14 @@ var $kerninfo;
574
  // post - PostScript table
575
  ///////////////////////////////////
576
  $this->seek_table("post");
577
- if ($debug) {
578
  $ver_maj = $this->read_ushort();
579
  $ver_min = $this->read_ushort();
580
- if ($ver_maj <1 || $ver_maj >4)
581
  die('Unknown post table version '.$ver_maj);
582
  }
583
  else {
584
- $this->skip(4);
585
  }
586
  $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;
587
  $this->underlinePosition = $this->read_short() * $scale;
@@ -590,7 +590,7 @@ var $kerninfo;
590
 
591
  $this->flags = 4;
592
 
593
- if ($this->italicAngle!= 0)
594
  $this->flags = $this->flags | 64;
595
  if ($usWeightClass >= 600)
596
  $this->flags = $this->flags | 262144;
@@ -601,7 +601,7 @@ var $kerninfo;
601
  // hhea - Horizontal header table
602
  ///////////////////////////////////
603
  $this->seek_table("hhea");
604
- if ($debug) {
605
  $ver_maj = $this->read_ushort();
606
  $ver_min = $this->read_ushort();
607
  if ($ver_maj != 1)
@@ -609,27 +609,27 @@ var $kerninfo;
609
  $this->skip(28);
610
  }
611
  else {
612
- $this->skip(32);
613
  }
614
  $metricDataFormat = $this->read_ushort();
615
  if ($metricDataFormat != 0)
616
  die('Unknown horizontal metric data format '.$metricDataFormat);
617
  $numberOfHMetrics = $this->read_ushort();
618
- if ($numberOfHMetrics == 0)
619
  die('Number of horizontal metrics is 0');
620
 
621
  ///////////////////////////////////
622
  // maxp - Maximum profile table
623
  ///////////////////////////////////
624
  $this->seek_table("maxp");
625
- if ($debug) {
626
  $ver_maj = $this->read_ushort();
627
  $ver_min = $this->read_ushort();
628
  if ($ver_maj != 1)
629
  die('Unknown maxp table version '.$ver_maj);
630
  }
631
  else {
632
- $this->skip(4);
633
  }
634
  $numGlyphs = $this->read_ushort();
635
 
@@ -681,15 +681,15 @@ var $kerninfo;
681
 
682
  $glyphToChar = array();
683
  $charToGlyph = array();
684
- for($i=0; $i<$nGroups ; $i++) {
685
- $startCharCode = $this->read_ulong();
686
- $endCharCode = $this->read_ulong();
687
- $startGlyphCode = $this->read_ulong();
688
  if (($endCharCode > 0x20000 && $endCharCode < 0x2A6DF) || ($endCharCode > 0x2F800 && $endCharCode < 0x2FA1F)) {
689
- $sipset = true;
690
  }
691
  else if ($endCharCode > 0x10000 && $endCharCode < 0x1FFFF) {
692
- $smpset = true;
693
  }
694
  $offset = 0;
695
  for ($unichar=$startCharCode;$unichar<=$endCharCode;$unichar++) {
@@ -784,7 +784,7 @@ var $kerninfo;
784
  // head - Font header table
785
  ///////////////////////////////////
786
  $this->seek_table("head");
787
- $this->skip(50);
788
  $indexToLocFormat = $this->read_ushort();
789
  $glyphDataFormat = $this->read_ushort();
790
 
@@ -792,7 +792,7 @@ var $kerninfo;
792
  // hhea - Horizontal header table
793
  ///////////////////////////////////
794
  $this->seek_table("hhea");
795
- $this->skip(32);
796
  $metricDataFormat = $this->read_ushort();
797
  $orignHmetrics = $numberOfHMetrics = $this->read_ushort();
798
 
@@ -866,7 +866,7 @@ var $kerninfo;
866
  $n = 0;
867
  $fsLastCharIndex = 0; // maximum Unicode index (character code) in this font, according to the cmap subtable for platform ID 3 and platform- specific encoding ID 0 or 1.
868
  foreach($subsetglyphs AS $originalGlyphIdx => $uni) {
869
- $fsLastCharIndex = max($fsLastCharIndex , $uni);
870
  $glyphSet[$originalGlyphIdx] = $n; // old glyphID to new glyphID
871
  $n++;
872
  }
@@ -935,7 +935,7 @@ var $kerninfo;
935
  ///////////////////////////////////
936
  // CMap table
937
  ///////////////////////////////////
938
- // cmap - Character to glyph mapping
939
  $segCount = count($range) + 1; // + 1 Last segment has missing character 0xFFFF
940
  $searchRange = 1;
941
  $entrySelector = 0;
@@ -972,14 +972,14 @@ var $kerninfo;
972
  $cmap[] = $start; // startCode(s)
973
  }
974
  $cmap[] = 0xFFFF; // startCode of last Segment
975
- // idDelta(s)
976
  foreach($range AS $start=>$subrange) {
977
  $idDelta = -($start-$subrange[0]);
978
  $n += count($subrange);
979
  $cmap[] = $idDelta; // idDelta(s)
980
  }
981
  $cmap[] = 1; // idDelta of last Segment
982
- // idRangeOffset(s)
983
  foreach($range AS $subrange) {
984
  $cmap[] = 0; // idRangeOffset[segCount] Offset in bytes to glyph indexArray, or 0
985
 
@@ -1050,7 +1050,7 @@ var $kerninfo;
1050
  $yMinT = min($yMinT,$yMin);
1051
  $xMaxT = max($xMaxT,$xMax);
1052
  $yMaxT = max($yMaxT,$yMax);
1053
- $aw = $this->unpack_short(substr($hm,0,2));
1054
  $lsb = $this->unpack_short(substr($hm,2,2));
1055
  $advanceWidthMax = max($advanceWidthMax,$aw);
1056
  $minLeftSideBearing = min($minLeftSideBearing,$lsb);
@@ -1160,10 +1160,10 @@ var $kerninfo;
1160
  $hhea = $this->get_table('hhea');
1161
  $hhea = $this->_set_ushort($hhea, 34, $numberOfHMetrics);
1162
  if (_RECALC_PROFILE) {
1163
- $hhea = $this->_set_ushort($hhea, 10, $advanceWidthMax);
1164
- $hhea = $this->_set_short($hhea, 12, $minLeftSideBearing);
1165
- $hhea = $this->_set_short($hhea, 14, $minRightSideBearing);
1166
- $hhea = $this->_set_short($hhea, 16, $xMaxExtent);
1167
  }
1168
  $this->add('hhea', $hhea);
1169
 
@@ -1186,7 +1186,7 @@ var $kerninfo;
1186
  ///////////////////////////////////
1187
  // OS/2 - OS/2
1188
  ///////////////////////////////////
1189
- if (isset($this->tables['OS/2'])) {
1190
  $os2_offset = $this->seek_table("OS/2");
1191
  if (_RECALC_PROFILE) {
1192
  $fsSelection = $this->get_ushort($os2_offset+62);
@@ -1197,13 +1197,13 @@ var $kerninfo;
1197
  }
1198
 
1199
  // NB Currently this method never subsets characters above BMP
1200
- // Could set nonBMP bit according to $this->maxUni
1201
  $nonBMP = $this->get_ushort($os2_offset+46);
1202
  $nonBMP = ($nonBMP & ~(1 << 9)); // Unset Bit 57 (indicates non-BMP) - for interactive forms
1203
 
1204
  $os2 = $this->get_table('OS/2');
1205
  if (_RECALC_PROFILE) {
1206
- $os2 = $this->_set_ushort($os2, 62, $fsSelection);
1207
  $os2 = $this->_set_ushort($os2, 66, $fsLastCharIndex);
1208
  $os2 = $this->_set_ushort($os2, 42, 0x0000); // ulCharRange (ulUnicodeRange) bits 24-31 | 16-23
1209
  $os2 = $this->_set_ushort($os2, 44, 0x0000); // ulCharRange (Unicode ranges) bits 8-15 | 0-7
@@ -1264,7 +1264,7 @@ var $kerninfo;
1264
  // head - Font header table
1265
  ///////////////////////////////////
1266
  $this->seek_table("head");
1267
- $this->skip(50);
1268
  $indexToLocFormat = $this->read_ushort();
1269
  $glyphDataFormat = $this->read_ushort();
1270
 
@@ -1272,7 +1272,7 @@ var $kerninfo;
1272
  // hhea - Horizontal header table
1273
  ///////////////////////////////////
1274
  $this->seek_table("hhea");
1275
- $this->skip(32);
1276
  $metricDataFormat = $this->read_ushort();
1277
  $orignHmetrics = $numberOfHMetrics = $this->read_ushort();
1278
 
@@ -1321,10 +1321,10 @@ var $kerninfo;
1321
 
1322
  $glyphToChar = array();
1323
  $charToGlyph = array();
1324
- for($i=0; $i<$nGroups ; $i++) {
1325
- $startCharCode = $this->read_ulong();
1326
- $endCharCode = $this->read_ulong();
1327
- $startGlyphCode = $this->read_ulong();
1328
  $offset = 0;
1329
  for ($unichar=$startCharCode;$unichar<=$endCharCode;$unichar++) {
1330
  $glyph = $startGlyphCode + $offset ;
@@ -1335,7 +1335,7 @@ var $kerninfo;
1335
  }
1336
  }
1337
  }
1338
- else
1339
  die('Font does not have cmap for Unicode (format 12)');
1340
 
1341
 
@@ -1352,7 +1352,7 @@ var $kerninfo;
1352
 
1353
  ///////////////////////////////////////////////////////////////////
1354
 
1355
- $glyphMap = array(0=>0);
1356
  $glyphSet = array(0=>0);
1357
  $codeToGlyph = array();
1358
  // Set a substitute if ASCII characters do not have glyphs
@@ -1414,7 +1414,7 @@ var $kerninfo;
1414
  // name
1415
  ///////////////////////////////////
1416
  // Needs to have a name entry in 3,0 (e.g. symbol) - original font will be 3,1 (i.e. Unicode)
1417
- $name = $this->get_table('name');
1418
  $name_offset = $this->seek_table("name");
1419
  $format = $this->read_ushort();
1420
  $numRecords = $this->read_ushort();
@@ -1433,7 +1433,7 @@ var $kerninfo;
1433
  ///////////////////////////////////
1434
  // OS/2
1435
  ///////////////////////////////////
1436
- if (isset($this->tables['OS/2'])) {
1437
  $os2 = $this->get_table('OS/2');
1438
  $os2 = $this->_set_ushort($os2, 42, 0x00); // ulCharRange (Unicode ranges)
1439
  $os2 = $this->_set_ushort($os2, 44, 0x00); // ulCharRange (Unicode ranges)
@@ -1461,15 +1461,15 @@ var $kerninfo;
1461
  ///////////////////////////////////
1462
  //tables copied from the original
1463
  ///////////////////////////////////
1464
- $tags = array ('cvt ', 'fpgm', 'prep', 'gasp');
1465
  foreach($tags AS $tag) { // 1.02
1466
- if (isset($this->tables[$tag])) { $this->add($tag, $this->get_table($tag)); }
1467
  }
1468
 
1469
  ///////////////////////////////////
1470
  // post - PostScript
1471
  ///////////////////////////////////
1472
- if (isset($this->tables['post'])) {
1473
  $opost = $this->get_table('post');
1474
  $post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
1475
  }
@@ -1502,7 +1502,7 @@ var $kerninfo;
1502
  $prevglidx = -1;
1503
  // for each character
1504
  foreach ($subset as $cid => $code) {
1505
- $glidx = $codeToGlyph[$code];
1506
  if ($cid == ($prevcid + 1) && $glidx == ($prevglidx + 1)) {
1507
  $range[$rangeid][] = $glidx;
1508
  } else {
@@ -1514,7 +1514,7 @@ var $kerninfo;
1514
  $prevcid = $cid;
1515
  $prevglidx = $glidx;
1516
  }
1517
- // cmap - Character to glyph mapping
1518
  $segCount = count($range) + 1; // + 1 Last segment has missing character 0xFFFF
1519
  $searchRange = 1;
1520
  $entrySelector = 0;
@@ -1545,14 +1545,14 @@ var $kerninfo;
1545
  $cmap[] = $start; // startCode(s)
1546
  }
1547
  $cmap[] = 0xFFFF; // startCode of last Segment
1548
- // idDelta(s)
1549
  foreach($range AS $start=>$subrange) {
1550
  $idDelta = -($start-$subrange[0]);
1551
  $n += count($subrange);
1552
  $cmap[] = $idDelta; // idDelta(s)
1553
  }
1554
  $cmap[] = 1; // idDelta of last Segment
1555
- // idRangeOffset(s)
1556
  foreach($range AS $subrange) {
1557
  $cmap[] = 0; // idRangeOffset[segCount] Offset in bytes to glyph indexArray, or 0
1558
 
@@ -1708,7 +1708,7 @@ var $kerninfo;
1708
  function getGlyphs($originalGlyphIdx, &$start, &$glyphSet, &$subsetglyphs) {
1709
  $glyphPos = $this->glyphPos[$originalGlyphIdx];
1710
  $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
1711
- if (!$glyphLen) {
1712
  return;
1713
  }
1714
  $this->seek($start + $glyphPos);
@@ -1794,7 +1794,7 @@ var $kerninfo;
1794
  if (isset($glyphToChar[$glyph])) {
1795
  foreach($glyphToChar[$glyph] AS $char) {
1796
  if ($char != 0 && $char != 65535) {
1797
- if ($char < 196608) {
1798
  $this->charWidths[$char*2] = chr($w >> 8);
1799
  $this->charWidths[$char*2 + 1] = chr($w & 0xFF);
1800
  $nCharWidths++;
@@ -1841,14 +1841,14 @@ var $kerninfo;
1841
  $this->glyphPos[] = ($arr[$n+1]);
1842
  }
1843
  }
1844
- else
1845
  die('Unknown location table format '.$indexToLocFormat);
1846
  }
1847
 
1848
 
1849
  // CMAP Format 4
1850
  function getCMAP4($unicode_cmap_offset, &$glyphToChar, &$charToGlyph ) {
1851
- $this->maxUniChar = 0;
1852
  $this->seek($unicode_cmap_offset + 2);
1853
  $length = $this->read_ushort();
1854
  $limit = $unicode_cmap_offset + $length;
@@ -1929,16 +1929,16 @@ var $kerninfo;
1929
  // LAM with ALEF ligatures (Mandatory ligatures)
1930
  else if (preg_match('/^uni064406(22|23|25|27)(\.fina|\.fin){0,1}$/i',$name,$m)) {
1931
  if ($m[1]=='22') {
1932
- if ($m[2]) { $uni = hexdec('FEF6'); } else { $uni = hexdec('FEF5'); }
1933
  }
1934
  else if ($m[1]=='23') {
1935
- if ($m[2]) { $uni = hexdec('FEF8'); } else { $uni = hexdec('FEF7'); }
1936
  }
1937
  else if ($m[1]=='25') {
1938
- if ($m[2]) { $uni = hexdec('FEFA'); } else { $uni = hexdec('FEF9'); }
1939
  }
1940
  else if ($m[1]=='27') {
1941
- if ($m[2]) { $uni = hexdec('FEFC'); } else { $uni = hexdec('FEFB'); }
1942
  }
1943
  if (!isset($glyphToChar[$gid]) || (isset($glyphToChar[$gid]) && is_array($glyphToChar[$gid]) && count($glyphToChar[$gid])==1 && $glyphToChar[$gid][0]>57343 && $glyphToChar[$gid][0]<63489)) { // if set in PUA private use area E000-F8FF, or NOT Unicode mapped
1944
  // ADD TO CMAP
@@ -1977,7 +1977,7 @@ var $kerninfo;
1977
 
1978
  // Table directory
1979
  $tables = $this->otables;
1980
- ksort ($tables);
1981
  $offset = 12 + $numTables * 16;
1982
  foreach ($tables AS $tag=>$data) {
1983
  if ($tag == 'head') { $head_start = $offset; }
@@ -2061,6 +2061,3 @@ PCLT - not recommended
2061
 
2062
 
2063
  }
2064
-
2065
-
2066
- ?>
10
  * Copyright (c) Ian Back, 2010 *
11
  * This class is based on The ReportLab Open Source PDF library *
12
  * written in Python - http://www.reportlab.com/software/opensource/ *
13
+ * together with ideas from the OpenOffice source code and others. *
14
  * This header must be retained in any redistribution or *
15
  * modification of the file. *
16
  * *
79
  var $maxUniChar;
80
  var $kerninfo;
81
 
82
+ function __construct() {
83
  $this->maxStrLenRead = 200000; // Maximum size of glyf table to read in as string (otherwise reads each glyph from file)
84
  }
85
 
101
  $this->TTCFonts = array();
102
  $this->version = $version = $this->read_ulong();
103
  $this->panose = array();
104
+ if ($version==0x4F54544F)
105
  die("Postscript outlines are not supported");
106
+ if ($version==0x74746366 && !$TTCfontID)
107
  die("ERROR - You must define the TTCfontID for a TrueType Collection in config_fonts.php (". $file.")");
108
  if (!in_array($version, array(0x00010000,0x74727565)) && !$TTCfontID)
109
  die("Not a TrueType font: version=".$version);
119
  $this->version = $version = $this->read_ulong(); // TTFont version again now
120
  }
121
  $this->readTableDirectory($debug);
122
+ $this->extractInfo($debug, $BMPonly, $kerninfo);
123
  fclose($this->fh);
124
  }
125
 
126
 
127
+ function readTableDirectory($debug=false) {
128
  $this->numTables = $this->read_ushort();
129
  $this->searchRange = $this->read_ushort();
130
  $this->entrySelector = $this->read_ushort();
131
  $this->rangeShift = $this->read_ushort();
132
+ $this->tables = array();
133
  for ($i=0;$i<$this->numTables;$i++) {
134
  $record = array();
135
  $record['tag'] = $this->read_tag();
155
  }
156
  $xchecksum = $t['checksum'];
157
 
158
+ if ($xchecksum != $checksum)
159
  die(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename,dechex($checksum[0]).dechex($checksum[1]),$t['tag'],dechex($xchecksum[0]).dechex($xchecksum[1])));
160
  }
161
  }
220
  $this->_pos += 2;
221
  $s = fread($this->fh,2);
222
  $a = (ord($s[0])<<8) + ord($s[1]);
223
+ if ($a & (1 << 15) ) {
224
+ $a = ($a - (1 << 16));
225
  }
226
  return $a;
227
  }
228
 
229
  function unpack_short($s) {
230
  $a = (ord($s[0])<<8) + ord($s[1]);
231
+ if ($a & (1 << 15) ) {
232
+ $a = ($a - (1 << 16));
233
  }
234
  return $a;
235
  }
261
  }
262
 
263
  function pack_short($val) {
264
+ if ($val<0) {
265
  $val = abs($val);
266
  $val = ~$val;
267
  $val += 1;
268
  }
269
+ return pack("n",$val);
270
  }
271
 
272
  function splice($stream, $offset, $value) {
279
  }
280
 
281
  function _set_short($stream, $offset, $val) {
282
+ if ($val<0) {
283
  $val = abs($val);
284
  $val = ~$val;
285
  $val += 1;
286
  }
287
+ $up = pack("n",$val);
288
  return $this->splice($stream, $offset, $up);
289
  }
290
 
482
  // head - Font header table
483
  ///////////////////////////////////
484
  $this->seek_table("head");
485
+ if ($debug) {
486
  $ver_maj = $this->read_ushort();
487
  $ver_min = $this->read_ushort();
488
  if ($ver_maj != 1)
491
 
492
  $this->skip(4);
493
  $magic = $this->read_ulong();
494
+ if ($magic != 0x5F0F3CF5)
495
  die('Invalid head table magic ' .$magic);
496
  $this->skip(2);
497
  }
498
  else {
499
+ $this->skip(18);
500
  }
501
  $this->unitsPerEm = $unitsPerEm = $this->read_ushort();
502
  $scale = 1000 / $unitsPerEm;
574
  // post - PostScript table
575
  ///////////////////////////////////
576
  $this->seek_table("post");
577
+ if ($debug) {
578
  $ver_maj = $this->read_ushort();
579
  $ver_min = $this->read_ushort();
580
+ if ($ver_maj <1 || $ver_maj >4)
581
  die('Unknown post table version '.$ver_maj);
582
  }
583
  else {
584
+ $this->skip(4);
585
  }
586
  $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;
587
  $this->underlinePosition = $this->read_short() * $scale;
590
 
591
  $this->flags = 4;
592
 
593
+ if ($this->italicAngle!= 0)
594
  $this->flags = $this->flags | 64;
595
  if ($usWeightClass >= 600)
596
  $this->flags = $this->flags | 262144;
601
  // hhea - Horizontal header table
602
  ///////////////////////////////////
603
  $this->seek_table("hhea");
604
+ if ($debug) {
605
  $ver_maj = $this->read_ushort();
606
  $ver_min = $this->read_ushort();
607
  if ($ver_maj != 1)
609
  $this->skip(28);
610
  }
611
  else {
612
+ $this->skip(32);
613
  }
614
  $metricDataFormat = $this->read_ushort();
615
  if ($metricDataFormat != 0)
616
  die('Unknown horizontal metric data format '.$metricDataFormat);
617
  $numberOfHMetrics = $this->read_ushort();
618
+ if ($numberOfHMetrics == 0)
619
  die('Number of horizontal metrics is 0');
620
 
621
  ///////////////////////////////////
622
  // maxp - Maximum profile table
623
  ///////////////////////////////////
624
  $this->seek_table("maxp");
625
+ if ($debug) {
626
  $ver_maj = $this->read_ushort();
627
  $ver_min = $this->read_ushort();
628
  if ($ver_maj != 1)
629
  die('Unknown maxp table version '.$ver_maj);
630
  }
631
  else {
632
+ $this->skip(4);
633
  }
634
  $numGlyphs = $this->read_ushort();
635
 
681
 
682
  $glyphToChar = array();
683
  $charToGlyph = array();
684
+ for($i=0; $i<$nGroups ; $i++) {
685
+ $startCharCode = $this->read_ulong();
686
+ $endCharCode = $this->read_ulong();
687
+ $startGlyphCode = $this->read_ulong();
688
  if (($endCharCode > 0x20000 && $endCharCode < 0x2A6DF) || ($endCharCode > 0x2F800 && $endCharCode < 0x2FA1F)) {
689
+ $sipset = true;
690
  }
691
  else if ($endCharCode > 0x10000 && $endCharCode < 0x1FFFF) {
692
+ $smpset = true;
693
  }
694
  $offset = 0;
695
  for ($unichar=$startCharCode;$unichar<=$endCharCode;$unichar++) {
784
  // head - Font header table
785
  ///////////////////////////////////
786
  $this->seek_table("head");
787
+ $this->skip(50);
788
  $indexToLocFormat = $this->read_ushort();
789
  $glyphDataFormat = $this->read_ushort();
790
 
792
  // hhea - Horizontal header table
793
  ///////////////////////////////////
794
  $this->seek_table("hhea");
795
+ $this->skip(32);
796
  $metricDataFormat = $this->read_ushort();
797
  $orignHmetrics = $numberOfHMetrics = $this->read_ushort();
798
 
866
  $n = 0;
867
  $fsLastCharIndex = 0; // maximum Unicode index (character code) in this font, according to the cmap subtable for platform ID 3 and platform- specific encoding ID 0 or 1.
868
  foreach($subsetglyphs AS $originalGlyphIdx => $uni) {
869
+ $fsLastCharIndex = max($fsLastCharIndex , $uni);
870
  $glyphSet[$originalGlyphIdx] = $n; // old glyphID to new glyphID
871
  $n++;
872
  }
935
  ///////////////////////////////////
936
  // CMap table
937
  ///////////////////////////////////
938
+ // cmap - Character to glyph mapping
939
  $segCount = count($range) + 1; // + 1 Last segment has missing character 0xFFFF
940
  $searchRange = 1;
941
  $entrySelector = 0;
972
  $cmap[] = $start; // startCode(s)
973
  }
974
  $cmap[] = 0xFFFF; // startCode of last Segment
975
+ // idDelta(s)
976
  foreach($range AS $start=>$subrange) {
977
  $idDelta = -($start-$subrange[0]);
978
  $n += count($subrange);
979
  $cmap[] = $idDelta; // idDelta(s)
980
  }
981
  $cmap[] = 1; // idDelta of last Segment
982
+ // idRangeOffset(s)
983
  foreach($range AS $subrange) {
984
  $cmap[] = 0; // idRangeOffset[segCount] Offset in bytes to glyph indexArray, or 0
985
 
1050
  $yMinT = min($yMinT,$yMin);
1051
  $xMaxT = max($xMaxT,$xMax);
1052
  $yMaxT = max($yMaxT,$yMax);
1053
+ $aw = $this->unpack_short(substr($hm,0,2));
1054
  $lsb = $this->unpack_short(substr($hm,2,2));
1055
  $advanceWidthMax = max($advanceWidthMax,$aw);
1056
  $minLeftSideBearing = min($minLeftSideBearing,$lsb);
1160
  $hhea = $this->get_table('hhea');
1161
  $hhea = $this->_set_ushort($hhea, 34, $numberOfHMetrics);
1162
  if (_RECALC_PROFILE) {
1163
+ $hhea = $this->_set_ushort($hhea, 10, $advanceWidthMax);
1164
+ $hhea = $this->_set_short($hhea, 12, $minLeftSideBearing);
1165
+ $hhea = $this->_set_short($hhea, 14, $minRightSideBearing);
1166
+ $hhea = $this->_set_short($hhea, 16, $xMaxExtent);
1167
  }
1168
  $this->add('hhea', $hhea);
1169
 
1186
  ///////////////////////////////////
1187
  // OS/2 - OS/2
1188
  ///////////////////////////////////
1189
+ if (isset($this->tables['OS/2'])) {
1190
  $os2_offset = $this->seek_table("OS/2");
1191
  if (_RECALC_PROFILE) {
1192
  $fsSelection = $this->get_ushort($os2_offset+62);
1197
  }
1198
 
1199
  // NB Currently this method never subsets characters above BMP
1200
+ // Could set nonBMP bit according to $this->maxUni
1201
  $nonBMP = $this->get_ushort($os2_offset+46);
1202
  $nonBMP = ($nonBMP & ~(1 << 9)); // Unset Bit 57 (indicates non-BMP) - for interactive forms
1203
 
1204
  $os2 = $this->get_table('OS/2');
1205
  if (_RECALC_PROFILE) {
1206
+ $os2 = $this->_set_ushort($os2, 62, $fsSelection);
1207
  $os2 = $this->_set_ushort($os2, 66, $fsLastCharIndex);
1208
  $os2 = $this->_set_ushort($os2, 42, 0x0000); // ulCharRange (ulUnicodeRange) bits 24-31 | 16-23
1209
  $os2 = $this->_set_ushort($os2, 44, 0x0000); // ulCharRange (Unicode ranges) bits 8-15 | 0-7
1264
  // head - Font header table
1265
  ///////////////////////////////////
1266
  $this->seek_table("head");
1267
+ $this->skip(50);
1268
  $indexToLocFormat = $this->read_ushort();
1269
  $glyphDataFormat = $this->read_ushort();
1270
 
1272
  // hhea - Horizontal header table
1273
  ///////////////////////////////////
1274
  $this->seek_table("hhea");
1275
+ $this->skip(32);
1276
  $metricDataFormat = $this->read_ushort();
1277
  $orignHmetrics = $numberOfHMetrics = $this->read_ushort();
1278
 
1321
 
1322
  $glyphToChar = array();
1323
  $charToGlyph = array();
1324
+ for($i=0; $i<$nGroups ; $i++) {
1325
+ $startCharCode = $this->read_ulong();
1326
+ $endCharCode = $this->read_ulong();
1327
+ $startGlyphCode = $this->read_ulong();
1328
  $offset = 0;
1329
  for ($unichar=$startCharCode;$unichar<=$endCharCode;$unichar++) {
1330
  $glyph = $startGlyphCode + $offset ;
1335
  }
1336
  }
1337
  }
1338
+ else
1339
  die('Font does not have cmap for Unicode (format 12)');
1340
 
1341
 
1352
 
1353
  ///////////////////////////////////////////////////////////////////
1354
 
1355
+ $glyphMap = array(0=>0);
1356
  $glyphSet = array(0=>0);
1357
  $codeToGlyph = array();
1358
  // Set a substitute if ASCII characters do not have glyphs
1414
  // name
1415
  ///////////////////////////////////
1416
  // Needs to have a name entry in 3,0 (e.g. symbol) - original font will be 3,1 (i.e. Unicode)
1417
+ $name = $this->get_table('name');
1418
  $name_offset = $this->seek_table("name");
1419
  $format = $this->read_ushort();
1420
  $numRecords = $this->read_ushort();
1433
  ///////////////////////////////////
1434
  // OS/2
1435
  ///////////////////////////////////
1436
+ if (isset($this->tables['OS/2'])) {
1437
  $os2 = $this->get_table('OS/2');
1438
  $os2 = $this->_set_ushort($os2, 42, 0x00); // ulCharRange (Unicode ranges)
1439
  $os2 = $this->_set_ushort($os2, 44, 0x00); // ulCharRange (Unicode ranges)
1461
  ///////////////////////////////////
1462
  //tables copied from the original
1463
  ///////////////////////////////////
1464
+ $tags = array ('cvt ', 'fpgm', 'prep', 'gasp');
1465
  foreach($tags AS $tag) { // 1.02
1466
+ if (isset($this->tables[$tag])) { $this->add($tag, $this->get_table($tag)); }
1467
  }
1468
 
1469
  ///////////////////////////////////
1470
  // post - PostScript
1471
  ///////////////////////////////////
1472
+ if (isset($this->tables['post'])) {
1473
  $opost = $this->get_table('post');
1474
  $post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
1475
  }
1502
  $prevglidx = -1;
1503
  // for each character
1504
  foreach ($subset as $cid => $code) {
1505
+ $glidx = $codeToGlyph[$code];
1506
  if ($cid == ($prevcid + 1) && $glidx == ($prevglidx + 1)) {
1507
  $range[$rangeid][] = $glidx;
1508
  } else {
1514
  $prevcid = $cid;
1515
  $prevglidx = $glidx;
1516
  }
1517
+ // cmap - Character to glyph mapping
1518
  $segCount = count($range) + 1; // + 1 Last segment has missing character 0xFFFF
1519
  $searchRange = 1;
1520
  $entrySelector = 0;
1545
  $cmap[] = $start; // startCode(s)
1546
  }
1547
  $cmap[] = 0xFFFF; // startCode of last Segment
1548
+ // idDelta(s)
1549
  foreach($range AS $start=>$subrange) {
1550
  $idDelta = -($start-$subrange[0]);
1551
  $n += count($subrange);
1552
  $cmap[] = $idDelta; // idDelta(s)
1553
  }
1554
  $cmap[] = 1; // idDelta of last Segment
1555
+ // idRangeOffset(s)
1556
  foreach($range AS $subrange) {
1557
  $cmap[] = 0; // idRangeOffset[segCount] Offset in bytes to glyph indexArray, or 0
1558
 
1708
  function getGlyphs($originalGlyphIdx, &$start, &$glyphSet, &$subsetglyphs) {
1709
  $glyphPos = $this->glyphPos[$originalGlyphIdx];
1710
  $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
1711
+ if (!$glyphLen) {
1712
  return;
1713
  }
1714
  $this->seek($start + $glyphPos);
1794
  if (isset($glyphToChar[$glyph])) {
1795
  foreach($glyphToChar[$glyph] AS $char) {
1796
  if ($char != 0 && $char != 65535) {
1797
+ if ($char < 196608) {
1798
  $this->charWidths[$char*2] = chr($w >> 8);
1799
  $this->charWidths[$char*2 + 1] = chr($w & 0xFF);
1800
  $nCharWidths++;
1841
  $this->glyphPos[] = ($arr[$n+1]);
1842
  }
1843
  }
1844
+ else
1845
  die('Unknown location table format '.$indexToLocFormat);
1846
  }
1847
 
1848
 
1849
  // CMAP Format 4
1850
  function getCMAP4($unicode_cmap_offset, &$glyphToChar, &$charToGlyph ) {
1851
+ $this->maxUniChar = 0;
1852
  $this->seek($unicode_cmap_offset + 2);
1853
  $length = $this->read_ushort();
1854
  $limit = $unicode_cmap_offset + $length;
1929
  // LAM with ALEF ligatures (Mandatory ligatures)
1930
  else if (preg_match('/^uni064406(22|23|25|27)(\.fina|\.fin){0,1}$/i',$name,$m)) {
1931
  if ($m[1]=='22') {
1932
+ if ($m[2]) { $uni = hexdec('FEF6'); } else { $uni = hexdec('FEF5'); }
1933
  }
1934
  else if ($m[1]=='23') {
1935
+ if ($m[2]) { $uni = hexdec('FEF8'); } else { $uni = hexdec('FEF7'); }
1936
  }
1937
  else if ($m[1]=='25') {
1938
+ if ($m[2]) { $uni = hexdec('FEFA'); } else { $uni = hexdec('FEF9'); }
1939
  }
1940
  else if ($m[1]=='27') {
1941
+ if ($m[2]) { $uni = hexdec('FEFC'); } else { $uni = hexdec('FEFB'); }
1942
  }
1943
  if (!isset($glyphToChar[$gid]) || (isset($glyphToChar[$gid]) && is_array($glyphToChar[$gid]) && count($glyphToChar[$gid])==1 && $glyphToChar[$gid][0]>57343 && $glyphToChar[$gid][0]<63489)) { // if set in PUA private use area E000-F8FF, or NOT Unicode mapped
1944
  // ADD TO CMAP
1977
 
1978
  // Table directory
1979
  $tables = $this->otables;
1980
+ ksort ($tables);
1981
  $offset = 12 + $numTables * 16;
1982
  foreach ($tables AS $tag=>$data) {
1983
  if ($tag == 'head') { $head_start = $offset; }
2061
 
2062
 
2063
  }
 
 
 
mPDF/classes/ttfontsuni_analysis.php CHANGED
@@ -21,7 +21,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
21
  $this->TTCFonts = array();
22
  $this->version = $version = $this->read_ulong();
23
  $this->panose = array(); // mPDF 5.0
24
- if ($version==0x4F54544F)
25
  return("ERROR - NOT ADDED as Postscript outlines are not supported - " . $file);
26
  if ($version==0x74746366) {
27
  if ($TTCfontID > 0) {
@@ -63,7 +63,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
63
  // name - Naming table
64
  ///////////////////////////////////
65
 
66
- /* Test purposes - displays table of names
67
  $name_offset = $this->seek_table("name");
68
  $format = $this->read_ushort();
69
  if ($format != 0 && $format != 1) // mPDF 5.3.73
@@ -177,7 +177,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
177
  $this->fontRevision = $this->read_ushort() . $this->read_ushort();
178
  $this->skip(4);
179
  $magic = $this->read_ulong();
180
- if ($magic != 0x5F0F3CF5)
181
  return('ERROR - NOT ADDED as Invalid head table magic ' .$magic." - " . $file);
182
  $this->skip(2);
183
  $this->unitsPerEm = $unitsPerEm = $this->read_ushort();
@@ -202,7 +202,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
202
  $panose = fread($this->fh,10);
203
  $this->panose = array();
204
  for ($p=0;$p<strlen($panose);$p++) { $this->panose[] = ord($panose[$p]); }
205
- $this->skip(20);
206
  $fsSelection = $this->read_short();
207
  }
208
 
@@ -210,7 +210,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
210
  // post - PostScript table
211
  ///////////////////////////////////
212
  $this->seek_table("post");
213
- $this->skip(4);
214
  $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;
215
  $this->skip(4);
216
  $isFixedPitch = $this->read_ulong();
@@ -264,30 +264,30 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
264
  $limit = $unicode_cmap_offset + $length;
265
  $this->skip(4);
266
  $nGroups = $this->read_ulong();
267
- for($i=0; $i<$nGroups ; $i++) {
268
- $startCharCode = $this->read_ulong();
269
- $endCharCode = $this->read_ulong();
270
- $startGlyphCode = $this->read_ulong();
271
  if (($endCharCode > 0x20000 && $endCharCode < 0x2A6DF) || ($endCharCode > 0x2F800 && $endCharCode < 0x2FA1F)) {
272
- $sip = true;
273
  }
274
  if ($endCharCode > 0x10000 && $endCharCode < 0x1FFFF) {
275
- $smp = true;
276
  }
277
  if (($endCharCode > 0x0590 && $endCharCode < 0x077F) || ($endCharCode > 0xFE70 && $endCharCode < 0xFEFF) || ($endCharCode > 0xFB50 && $endCharCode < 0xFDFF)) {
278
- $rtl = true;
279
  }
280
  if ($endCharCode > 0x0900 && $endCharCode < 0x0DFF) {
281
- $indic = true;
282
  }
283
  if ($endCharCode > 0xE000 && $endCharCode < 0xF8FF) {
284
- $pua = true;
285
  if ($endCharCode > 0xF500 && $endCharCode < 0xF7FF) {
286
- $puaag = true;
287
  }
288
  }
289
  if (($endCharCode > 0x2E80 && $endCharCode < 0x4DC0) || ($endCharCode > 0x4E00 && $endCharCode < 0xA4CF) || ($endCharCode > 0xAC00 && $endCharCode < 0xD7AF) || ($endCharCode > 0xF900 && $endCharCode < 0xFAFF) || ($endCharCode > 0xFE30 && $endCharCode < 0xFE4F)) {
290
- $cjk = true;
291
  }
292
 
293
  $offset = 0;
@@ -325,18 +325,18 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
325
 
326
  for ($n=0;$n<$segCount;$n++) {
327
  if (($endCount[$n] > 0x0590 && $endCount[$n] < 0x077F) || ($endCount[$n] > 0xFE70 && $endCount[$n] < 0xFEFF) || ($endCount[$n] > 0xFB50 && $endCount[$n] < 0xFDFF)) {
328
- $rtl = true;
329
  }
330
  if ($endCount[$n] > 0x0900 && $endCount[$n] < 0x0DFF) {
331
- $indic = true;
332
  }
333
  if (($endCount[$n] > 0x2E80 && $endCount[$n] < 0x4DC0) || ($endCount[$n] > 0x4E00 && $endCount[$n] < 0xA4CF) || ($endCount[$n] > 0xAC00 && $endCount[$n] < 0xD7AF) || ($endCount[$n] > 0xF900 && $endCount[$n] < 0xFAFF) || ($endCount[$n] > 0xFE30 && $endCount[$n] < 0xFE4F)) {
334
- $cjk = true;
335
  }
336
  if ($endCount[$n] > 0xE000 && $endCount[$n] < 0xF8FF) {
337
- $pua = true;
338
  if ($endCount[$n] > 0xF500 && $endCount[$n] < 0xF7FF) {
339
- $puaag = true;
340
  }
341
  }
342
  // Get each glyphToChar - only point if going to analyse un-mapped Arabic Glyphs
@@ -411,16 +411,16 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
411
  }
412
  $ptr += $len;
413
  }
414
- if ($unAGlyphs) {
415
- $unAGlyphs = 'GID:Name:Unicode base Hex:Dec:Form:PUA Unicode<br />'.$unAGlyphs ;
416
  }
417
  }
418
  }
419
 
420
 
421
 
422
- $bold = false;
423
- $italic = false;
424
  $ftype = '';
425
  if ($macStyle & (1 << 0)) { $bold = true; } // bit 0 bold
426
  else if ($fsSelection & (1 << 5)) { $bold = true; } // 5 BOLD Characters are emboldened
@@ -434,11 +434,11 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
434
  else if ($sFamily ==8) { $ftype = 'sans'; }
435
  else if ($sFamily ==10) { $ftype = 'cursive'; }
436
  // Use PANOSE
437
- if ($panose) {
438
- $bFamilyType=ord($panose[0]);
439
  if ($bFamilyType==2) {
440
- $bSerifStyle=ord($panose[1]);
441
- if (!$ftype) {
442
  if ($bSerifStyle>1 && $bSerifStyle<11) { $ftype = 'serif'; }
443
  else if ($bSerifStyle>10) { $ftype = 'sans'; }
444
  }
@@ -446,7 +446,7 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
446
  if ($bProportion==9 || $bProportion==1) { $ftype = 'mono'; } // ==1 i.e. No Fit needed for OCR-a and -b
447
  }
448
  else if ($bFamilyType==3) {
449
- $ftype = 'cursive';
450
  }
451
  }
452
 
@@ -458,6 +458,3 @@ class TTFontFile_Analysis EXTENDS TTFontFile {
458
 
459
 
460
  }
461
-
462
-
463
- ?>
21
  $this->TTCFonts = array();
22
  $this->version = $version = $this->read_ulong();
23
  $this->panose = array(); // mPDF 5.0
24
+ if ($version==0x4F54544F)
25
  return("ERROR - NOT ADDED as Postscript outlines are not supported - " . $file);
26
  if ($version==0x74746366) {
27
  if ($TTCfontID > 0) {
63
  // name - Naming table
64
  ///////////////////////////////////
65
 
66
+ /* Test purposes - displays table of names
67
  $name_offset = $this->seek_table("name");
68
  $format = $this->read_ushort();
69
  if ($format != 0 && $format != 1) // mPDF 5.3.73
177
  $this->fontRevision = $this->read_ushort() . $this->read_ushort();
178
  $this->skip(4);
179
  $magic = $this->read_ulong();
180
+ if ($magic != 0x5F0F3CF5)
181
  return('ERROR - NOT ADDED as Invalid head table magic ' .$magic." - " . $file);
182
  $this->skip(2);
183
  $this->unitsPerEm = $unitsPerEm = $this->read_ushort();
202
  $panose = fread($this->fh,10);
203
  $this->panose = array();
204
  for ($p=0;$p<strlen($panose);$p++) { $this->panose[] = ord($panose[$p]); }
205
+ $this->skip(20);
206
  $fsSelection = $this->read_short();
207
  }
208
 
210
  // post - PostScript table
211
  ///////////////////////////////////
212
  $this->seek_table("post");
213
+ $this->skip(4);
214
  $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;
215
  $this->skip(4);
216
  $isFixedPitch = $this->read_ulong();
264
  $limit = $unicode_cmap_offset + $length;
265
  $this->skip(4);
266
  $nGroups = $this->read_ulong();
267
+ for($i=0; $i<$nGroups ; $i++) {
268
+ $startCharCode = $this->read_ulong();
269
+ $endCharCode = $this->read_ulong();
270
+ $startGlyphCode = $this->read_ulong();
271
  if (($endCharCode > 0x20000 && $endCharCode < 0x2A6DF) || ($endCharCode > 0x2F800 && $endCharCode < 0x2FA1F)) {
272
+ $sip = true;
273
  }
274
  if ($endCharCode > 0x10000 && $endCharCode < 0x1FFFF) {
275
+ $smp = true;
276
  }
277
  if (($endCharCode > 0x0590 && $endCharCode < 0x077F) || ($endCharCode > 0xFE70 && $endCharCode < 0xFEFF) || ($endCharCode > 0xFB50 && $endCharCode < 0xFDFF)) {
278
+ $rtl = true;
279
  }
280
  if ($endCharCode > 0x0900 && $endCharCode < 0x0DFF) {
281
+ $indic = true;
282
  }
283
  if ($endCharCode > 0xE000 && $endCharCode < 0xF8FF) {
284
+ $pua = true;
285
  if ($endCharCode > 0xF500 && $endCharCode < 0xF7FF) {
286
+ $puaag = true;
287
  }
288
  }
289
  if (($endCharCode > 0x2E80 && $endCharCode < 0x4DC0) || ($endCharCode > 0x4E00 && $endCharCode < 0xA4CF) || ($endCharCode > 0xAC00 && $endCharCode < 0xD7AF) || ($endCharCode > 0xF900 && $endCharCode < 0xFAFF) || ($endCharCode > 0xFE30 && $endCharCode < 0xFE4F)) {
290
+ $cjk = true;
291
  }
292
 
293
  $offset = 0;
325
 
326
  for ($n=0;$n<$segCount;$n++) {
327
  if (($endCount[$n] > 0x0590 && $endCount[$n] < 0x077F) || ($endCount[$n] > 0xFE70 && $endCount[$n] < 0xFEFF) || ($endCount[$n] > 0xFB50 && $endCount[$n] < 0xFDFF)) {
328
+ $rtl = true;
329
  }
330
  if ($endCount[$n] > 0x0900 && $endCount[$n] < 0x0DFF) {
331
+ $indic = true;
332
  }
333
  if (($endCount[$n] > 0x2E80 && $endCount[$n] < 0x4DC0) || ($endCount[$n] > 0x4E00 && $endCount[$n] < 0xA4CF) || ($endCount[$n] > 0xAC00 && $endCount[$n] < 0xD7AF) || ($endCount[$n] > 0xF900 && $endCount[$n] < 0xFAFF) || ($endCount[$n] > 0xFE30 && $endCount[$n] < 0xFE4F)) {
334
+ $cjk = true;
335
  }
336
  if ($endCount[$n] > 0xE000 && $endCount[$n] < 0xF8FF) {
337
+ $pua = true;
338
  if ($endCount[$n] > 0xF500 && $endCount[$n] < 0xF7FF) {
339
+ $puaag = true;
340
  }
341
  }
342
  // Get each glyphToChar - only point if going to analyse un-mapped Arabic Glyphs
411
  }
412
  $ptr += $len;
413
  }
414
+ if ($unAGlyphs) {
415
+ $unAGlyphs = 'GID:Name:Unicode base Hex:Dec:Form:PUA Unicode<br />'.$unAGlyphs ;
416
  }
417
  }
418
  }
419
 
420
 
421
 
422
+ $bold = false;
423
+ $italic = false;
424
  $ftype = '';
425
  if ($macStyle & (1 << 0)) { $bold = true; } // bit 0 bold
426
  else if ($fsSelection & (1 << 5)) { $bold = true; } // 5 BOLD Characters are emboldened
434
  else if ($sFamily ==8) { $ftype = 'sans'; }
435
  else if ($sFamily ==10) { $ftype = 'cursive'; }
436
  // Use PANOSE
437
+ if ($panose) {
438
+ $bFamilyType=ord($panose[0]);
439
  if ($bFamilyType==2) {
440
+ $bSerifStyle=ord($panose[1]);
441
+ if (!$ftype) {
442
  if ($bSerifStyle>1 && $bSerifStyle<11) { $ftype = 'serif'; }
443
  else if ($bSerifStyle>10) { $ftype = 'sans'; }
444
  }
446
  if ($bProportion==9 || $bProportion==1) { $ftype = 'mono'; } // ==1 i.e. No Fit needed for OCR-a and -b
447
  }
448
  else if ($bFamilyType==3) {
449
+ $ftype = 'cursive';
450
  }
451
  }
452
 
458
 
459
 
460
  }
 
 
 
mPDF/classes/wmf.php CHANGED
@@ -16,10 +16,10 @@ function _getWMFimage($data) {
16
  $this->gdiObjectArray = array();
17
  $a=unpack('stest',"\1\0");
18
  if ($a['test']!=1)
19
- return array(0, 'Error parsing WMF image - Big-endian architecture not supported');
20
  // check for Aldus placeable metafile header
21
  $key = unpack('Lmagic', substr($data, 0, 4));
22
- $p = 18; // WMF header
23
  if ($key['magic'] == (int)0x9AC6CDD7) { $p +=22; } // Aldus header
24
  // define some state variables
25
  $wo=null; // window origin
@@ -94,12 +94,12 @@ function _getWMFimage($data) {
94
  $nullBrush = false;
95
  if ($obj['style'] == 1) { $nullBrush = true; }
96
  else {
97
- $wmfdata .= $this->mpdf->SetFColor($this->mpdf->ConvertColor('rgb('.$obj['r'].','.$obj['g'].','.$obj['b'].')'), true)."\n";
98
  }
99
  break;
100
  case 'P':
101
  $nullPen = false;
102
- $dashArray = array();
103
  // dash parameters are custom
104
  switch ($obj['style']) {
105
  case 0: // PS_SOLID
@@ -232,5 +232,3 @@ function _DeleteGDIObject($idx) {
232
 
233
 
234
  }
235
-
236
- ?>
16
  $this->gdiObjectArray = array();
17
  $a=unpack('stest',"\1\0");
18
  if ($a['test']!=1)
19
+ return array(0, 'Error parsing WMF image - Big-endian architecture not supported');
20
  // check for Aldus placeable metafile header
21
  $key = unpack('Lmagic', substr($data, 0, 4));
22
+ $p = 18; // WMF header
23
  if ($key['magic'] == (int)0x9AC6CDD7) { $p +=22; } // Aldus header
24
  // define some state variables
25
  $wo=null; // window origin
94
  $nullBrush = false;
95
  if ($obj['style'] == 1) { $nullBrush = true; }
96
  else {
97
+ $wmfdata .= $this->mpdf->SetFColor($this->mpdf->ConvertColor('rgb('.$obj['r'].','.$obj['g'].','.$obj['b'].')'), true)."\n";
98
  }
99
  break;
100
  case 'P':
101
  $nullPen = false;
102
+ $dashArray = array();
103
  // dash parameters are custom
104
  switch ($obj['style']) {
105
  case 0: // PS_SOLID
232
 
233
 
234
  }
 
 
mPDF/mpdf-extra-lite.php CHANGED
@@ -36,7 +36,7 @@ if (!defined('_MPDF_URI')) define('_MPDF_URI',_MPDF_PATH);
36
  require_once(_MPDF_PATH.'includes/functions.php');
37
  require_once(_MPDF_PATH.'config_cp.php');
38
 
39
- if (!defined('_JPGRAPH_PATH')) define("_JPGRAPH_PATH", _MPDF_PATH.'jpgraph/');
40
 
41
  if (!defined('_MPDF_TEMP_PATH')) define("_MPDF_TEMP_PATH", _MPDF_PATH.'tmp/');
42
 
@@ -195,7 +195,7 @@ var $max_colH_correction;
195
  var $table_error_report;
196
  var $table_error_report_param;
197
  var $biDirectional;
198
- var $text_input_as_HTML;
199
  var $anchor2Bookmark;
200
  var $list_indent_first_level;
201
  var $shrink_tables_to_fit;
@@ -312,9 +312,9 @@ var $tableCJK;
312
 
313
  var $watermarkImgAlpha;
314
  var $PDFAXwarnings;
315
- var $MetadataRoot;
316
  var $OutputIntentRoot;
317
- var $InfoRoot;
318
  var $current_filename;
319
  var $parsers;
320
  var $current_parser;
@@ -335,7 +335,7 @@ var $subArrMB;
335
  var $ReqFontStyle;
336
  var $tableClipPath ;
337
  var $forceExactLineheight;
338
- var $listOcc;
339
 
340
  var $fullImageHeight;
341
  var $inFixedPosBlock; // Internal flag for position:fixed block
@@ -530,7 +530,7 @@ var $HTMLHeader;
530
  var $HTMLFooter;
531
  var $HTMLHeaderE;
532
  var $HTMLFooterE;
533
- var $bufferoutput;
534
 
535
  var $showdefaultpagenos; // DEPRACATED -left for backward compatability
536
 
@@ -565,7 +565,7 @@ var $y0; //Top ordinate of columns
565
  var $ColL;
566
  var $ColWidth;
567
  var $ColGap;
568
- // COLUMNS
569
  var $ColR;
570
  var $ChangeColumn;
571
  var $columnbuffer;
@@ -592,7 +592,7 @@ var $ColumnAdjust;
592
  var $ws; // Word spacing
593
  var $HREF;
594
  var $pgwidth;
595
- var $fontlist;
596
  var $oldx;
597
  var $oldy;
598
  var $B;
@@ -696,7 +696,7 @@ var $page_break_after_avoid;
696
  var $margin_bottom_collapse;
697
  var $list_indent;
698
  var $list_align;
699
- var $list_margin_bottom;
700
  var $default_font_size; // in pts
701
  var $original_default_font_size; // used to save default sizes when using table default
702
  var $original_default_font;
@@ -739,7 +739,7 @@ var $usingCoreFont;
739
  var $charspacing;
740
 
741
  //Private properties FROM FPDF
742
- var $DisplayPreferences;
743
  var $outlines;
744
  var $flowingBlockAttr;
745
  var $page; //current page number
@@ -826,7 +826,7 @@ var $innerblocktags;
826
  // **********************************
827
  // **********************************
828
 
829
- function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
830
 
831
 
832
  $this->time0 = microtime(true);
@@ -907,18 +907,18 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
907
  'palevioletred'=>'#D87093','peachpuff'=>'#FFDAB9','pink'=>'#FFC0CB','powderblue'=>'#B0E0E6','purple'=>'#800080',
908
  'red'=>'#FF0000','royalblue'=>'#4169E1','salmon'=>'#FA8072','seagreen'=>'#2E8B57','sienna'=>'#A0522D','silver'=>'#C0C0C0','skyblue'=>'#87CEEB',
909
  'slategray'=>'#708090','springgreen'=>'#00FF7F','steelblue'=>'#4682B4','tan'=>'#D2B48C','teal'=>'#008080','thistle'=>'#D8BFD8','turquoise'=>'#40E0D0',
910
- 'violetred'=>'#D02090','white'=>'#FFFFFF','yellow'=>'#FFFF00',
911
- 'aliceblue'=>'#f0f8ff', 'azure'=>'#f0ffff', 'bisque'=>'#ffe4c4', 'blanchedalmond'=>'#ffebcd', 'blueviolet'=>'#8a2be2', 'burlywood'=>'#deb887',
912
- 'chartreuse'=>'#7fff00', 'coral'=>'#ff7f50', 'cornsilk'=>'#fff8dc', 'cyan'=>'#00ffff', 'darkcyan'=>'#008b8b', 'darkgray'=>'#a9a9a9',
913
- 'darkgrey'=>'#a9a9a9', 'darkkhaki'=>'#bdb76b', 'darkolivegreen'=>'#556b2f', 'darkorchid'=>'#9932cc', 'darksalmon'=>'#e9967a',
914
- 'darkslateblue'=>'#483d8b', 'darkslategrey'=>'#2f4f4f', 'darkturquoise'=>'#00ced1', 'deeppink'=>'#ff1493', 'dimgray'=>'#696969',
915
- 'dimgrey'=>'#696969', 'floralwhite'=>'#fffaf0', 'ghostwhite'=>'#f8f8ff', 'goldenrod'=>'#daa520', 'grey'=>'#808080', 'honeydew'=>'#f0fff0',
916
- 'indianred'=>'#cd5c5c', 'ivory'=>'#fffff0', 'lavender'=>'#e6e6fa', 'lawngreen'=>'#7cfc00', 'lightblue'=>'#add8e6', 'lightcyan'=>'#e0ffff',
917
- 'lightgray'=>'#d3d3d3', 'lightgrey'=>'#d3d3d3', 'lightpink'=>'#ffb6c1', 'lightseagreen'=>'#20b2aa', 'lightslategrey'=>'#778899',
918
- 'lightsteelblue'=>'#b0c4de', 'linen'=>'#faf0e6', 'mediumblue'=>'#0000cd', 'mediumpurple'=>'#9370db', 'mediumslateblue'=>'#7b68ee',
919
- 'mediumturquoise'=>'#48d1cc', 'mistyrose'=>'#ffe4e1', 'navajowhite'=>'#ffdead', 'oldlace'=>'#fdf5e6', 'olivedrab'=>'#6b8e23', 'orangered'=>'#ff4500',
920
- 'palegoldenrod'=>'#eee8aa', 'paleturquoise'=>'#afeeee', 'papayawhip'=>'#ffefd5', 'peru'=>'#cd853f', 'plum'=>'#dda0dd', 'rosybrown'=>'#bc8f8f',
921
- 'saddlebrown'=>'#8b4513', 'sandybrown'=>'#f4a460', 'seashell'=>'#fff5ee', 'slateblue'=>'#6a5acd', 'slategrey'=>'#708090', 'snow'=>'#fffafa',
922
  'tomato'=>'#ff6347', 'violet'=>'#ee82ee', 'wheat'=>'#f5deb3', 'whitesmoke'=>'#f5f5f5', 'yellowgreen'=>'#9acd32');
923
 
924
  $this->ColorFlag=false;
@@ -938,7 +938,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
938
  $this->SHYdictionaryWords = array();
939
  $this->blockContext = 1;
940
  $this->floatDivs = array();
941
- $this->DisplayPreferences='';
942
 
943
  $this->tablecascadeCSS = array();
944
  $this->listcascadeCSS = array();
@@ -978,7 +978,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
978
  $this->forceExactLineheight = false;
979
  $this->listOcc = 0;
980
  $this->normalLineheight = 1.3;
981
- // These are intended as configuration variables, and should be set in config.php - which will override these values;
982
  // set here as failsafe as will cause an error if not defined
983
  $this->incrementFPR1 = 10;
984
  $this->incrementFPR2 = 10;
@@ -1030,7 +1030,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1030
  $this->uniqid = '';
1031
 
1032
  $this->cascadeCSS = array();
1033
- $this->bufferoutput = false;
1034
  $this->encrypted=false; //whether document is protected
1035
  $this->BMoutlines=array();
1036
  $this->ColActive=0; //Flag indicating that columns are on (the index is being processed)
@@ -1126,7 +1126,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1126
  //Compression
1127
  $this->SetCompression(true);
1128
  //Set default display preferences
1129
- $this->SetDisplayPreferences('');
1130
 
1131
  // Font data
1132
  require(_MPDF_PATH.'config_fonts.php');
@@ -1154,7 +1154,7 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1154
  else if ($mode=='c') { $onlyCoreFonts = true; $mode = ''; }
1155
  }
1156
  else if (substr($mode,-2)=='-s') {
1157
- $this->percentSubset = 100;
1158
  $mode = substr($mode,0,strlen($mode)-2);
1159
  }
1160
  else if (substr($mode,-2)=='-c') {
@@ -1170,8 +1170,8 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1170
  if ((strlen($mode) == 5 && $mode != 'UTF-8') || strlen($mode) == 2) {
1171
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($mode, $this->useAdobeCJK);
1172
  if ($coreSuitable && $optcore) { $onlyCoreFonts = true; }
1173
- if ($mpdf_pdf_unifonts) {
1174
- $this->RestrictUnicodeFonts($mpdf_pdf_unifonts);
1175
  $this->default_available_fonts = $mpdf_pdf_unifonts;
1176
  }
1177
  $this->currentLang = $mode;
@@ -1213,18 +1213,18 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1213
  if (file_exists(_MPDF_PATH.'mpdf.css')) {
1214
  $css = file_get_contents(_MPDF_PATH.'mpdf.css');
1215
  $css2 = $this->ReadDefaultCSS($css);
1216
- $this->defaultCSS = $this->array_merge_recursive_unique($this->defaultCSS,$css2);
1217
  }
1218
 
1219
- if ($default_font=='') {
1220
- if ($this->onlyCoreFonts) {
1221
  if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->mono_fonts)) { $default_font = 'ccourier'; }
1222
  else if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->sans_fonts)) { $default_font = 'chelvetica'; }
1223
  else { $default_font = 'ctimes'; }
1224
  }
1225
  else { $default_font = $this->defaultCSS['BODY']['FONT-FAMILY']; }
1226
  }
1227
- if (!$default_font_size) {
1228
  $mmsize = $this->ConvertSize($this->defaultCSS['BODY']['FONT-SIZE']);
1229
  $default_font_size = $mmsize*(_MPDFK);
1230
  }
@@ -1243,23 +1243,23 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
1243
  $this->I=0;
1244
 
1245
  $this->listlvl=0;
1246
- $this->listnum=0;
1247
  $this->listtype='';
1248
  $this->listoccur=array();
1249
  $this->listlist=array();
1250
  $this->listitem=array();
1251
 
1252
- $this->tdbegin=false;
1253
- $this->table=array();
1254
- $this->cell=array();
1255
- $this->col=-1;
1256
- $this->row=-1;
1257
  $this->cellBorderBuffer = array();
1258
 
1259
  $this->divbegin=false;
1260
  $this->divalign='';
1261
- $this->divwidth=0;
1262
- $this->divheight=0;
1263
  $this->spanbgcolor=false;
1264
  $this->divrevert=false;
1265
  $this->spanborder=false;
@@ -1307,8 +1307,8 @@ function _setPageSize($format, &$orientation) {
1307
  if ($format=='') { $format = 'A4'; }
1308
  $pfo = 'P';
1309
  if(preg_match('/([0-9a-zA-Z]*)-L/i',$format,$m)) { // e.g. A4-L = A4 landscape
1310
- $format=$m[1];
1311
- $pfo='L';
1312
  }
1313
  $format = $this->_getPageFormat($format);
1314
  if (!$format) { $this->Error('Unknown page format: '.$format); }
@@ -1403,7 +1403,6 @@ function _getPageFormat($format) {
1403
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1404
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1405
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
1406
- default: $format = false;
1407
  }
1408
  return $format;
1409
  }
@@ -1424,9 +1423,9 @@ function RestrictUnicodeFonts($res) {
1424
 
1425
 
1426
  function setMBencoding($enc) {
1427
- if ($this->mb_enc != $enc) {
1428
- $this->mb_enc = $enc;
1429
- mb_internal_encoding($this->mb_enc);
1430
  }
1431
  }
1432
 
@@ -1557,9 +1556,9 @@ function SetAlpha($alpha, $bm='Normal', $return=false, $mode='B') {
1557
  // HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity
1558
  // set alpha for stroking (CA) and non-stroking (ca) operations
1559
  // mode determines F (fill) S (stroke) B (both)
1560
- if (($this->PDFA || $this->PDFX) && $alpha!=1) {
1561
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Image opacity must be 100% (Opacity changed to 100%)"; }
1562
- $alpha = 1;
1563
  }
1564
  $a = array('BM'=>'/'.$bm);
1565
  if ($mode=='F' || $mode='B') $a['ca'] = $alpha;
@@ -1701,7 +1700,7 @@ function PrintPageBackgrounds($adjustmenty=0) {
1701
  }
1702
 
1703
  if($pb['visibility']!='visible') {
1704
- if($pb['visibility']=='printonly')
1705
  $s .= '/OC /OC1 BDC'."\n";
1706
  else if($pb['visibility']=='screenonly')
1707
  $s .= '/OC /OC2 BDC'."\n";
@@ -1713,7 +1712,7 @@ function PrintPageBackgrounds($adjustmenty=0) {
1713
  if (isset($pb['clippath']) && $pb['clippath']) { $s .= $pb['clippath']."\n"; }
1714
  $s .= 'q '.$this->SetFColor($pb['col'], true)."\n";
1715
  if ($pb['col']{0}==5) { // RGBa
1716
- $s .= $this->SetAlpha(ord($pb['col']{4})/100, 'Normal', true, 'F')."\n";
1717
  }
1718
  else if ($pb['col']{0}==6) { // CMYKa
1719
  $s .= $this->SetAlpha(ord($pb['col']{5})/100, 'Normal', true, 'F')."\n";
@@ -1743,7 +1742,7 @@ function PrintTableBackgrounds($adjustmenty=0) {
1743
  function BeginLayer($id) {
1744
  if($this->current_layer>0) $this->EndLayer();
1745
  if ($id < 1) { return false; }
1746
- if (!isset($this->layers[$id])) {
1747
  $this->layers[$id] = array('name'=>'Layer '.($id) );
1748
  if (($this->PDFA || $this->PDFX)) { $this->PDFAXwarnings[] = "Cannot use layers when using PDFA or PDFX"; return ''; }
1749
  else if (!$this->PDFA && !$this->PDFX) { $this->pdf_version='1.5'; }
@@ -1766,7 +1765,7 @@ function EndLayer() {
1766
  // Depracated - can use AddPage for all
1767
  function AddPages($orientation='',$condition='', $resetpagenum='', $pagenumstyle='', $suppress='',$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='',$ohname='',$ehname='',$ofname='',$efname='',$ohvalue=0,$ehvalue=0,$ofvalue=0,$efvalue=0,$pagesel='',$newformat='')
1768
  {
1769
- $this->AddPage($orientation,$condition,$resetpagenum, $pagenumstyle, $suppress,$mgl,$mgr,$mgt,$mgb,$mgh,$mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue,$pagesel,$newformat);
1770
  }
1771
 
1772
 
@@ -1808,7 +1807,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
1808
  if($this->state==0) $this->Open();
1809
 
1810
  $bak_cml = $this->cMarginL;
1811
- $bak_cmr = $this->cMarginR;
1812
  $bak_dw = $this->divwidth;
1813
 
1814
 
@@ -1820,16 +1819,16 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
1820
 
1821
  if ($condition == 'NEXT-EVEN') { // always adds at least one new page to create an Even page
1822
  if (!$this->mirrorMargins) { $condition = ''; }
1823
- else {
1824
- $this->AddPage($this->CurOrientation,'O');
1825
- $condition = '';
1826
  }
1827
  }
1828
  if ($condition == 'NEXT-ODD') { // always adds at least one new page to create an Odd page
1829
  if (!$this->mirrorMargins) { $condition = ''; }
1830
- else {
1831
- $this->AddPage($this->CurOrientation,'E');
1832
- $condition = '';
1833
  }
1834
  }
1835
 
@@ -1862,7 +1861,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
1862
  // Paint Div Border if necessary
1863
  //PAINTS BACKGROUND COLOUR OR BORDERS for DIV - DISABLED FOR COLUMNS (cf. AcceptPageBreak) AT PRESENT in ->PaintDivBB
1864
  if (!$this->ColActive && $this->blklvl > 0) {
1865
- if (isset($this->blk[$this->blklvl]['y0']) && $this->y == $this->blk[$this->blklvl]['y0']) {
1866
  if (isset($this->blk[$this->blklvl]['startpage'])) { $this->blk[$this->blklvl]['startpage']++; }
1867
  else { $this->blk[$this->blklvl]['startpage'] = 1; }
1868
  }
@@ -1934,7 +1933,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
1934
  if ($this->docTemplate) {
1935
  $pagecount = $this->SetSourceFile($this->docTemplate);
1936
  if (($this->page - $this->docTemplateStart) > $pagecount) {
1937
- if ($this->docTemplateContinue) {
1938
  $tplIdx = $this->ImportPage($pagecount);
1939
  $this->UseTemplate($tplIdx);
1940
  }
@@ -2011,7 +2010,7 @@ function AddPage($orientation='',$condition='', $resetpagenum='', $pagenumstyle=
2011
  if (isset($this->blk[$bl]['x0'])) { $this->blk[$bl]['x0'] += $this->MarginCorrection; }
2012
  else { $this->blk[$bl]['x0'] = $this->MarginCorrection; }
2013
  // Added mPDF 3.0 Float DIV
2014
- $this->blk[$bl]['marginCorrected'][$this->page] = true;
2015
  }
2016
  }
2017
 
@@ -2071,7 +2070,7 @@ function SetColor($col, $type='') {
2071
  }
2072
  if ($type=='Draw') { $out = strtoupper($out); } // e.g. rg => RG
2073
  else if ($type=='CodeOnly') { $out = preg_replace('/\s(rg|g|k)/','',$out); }
2074
- return $out;
2075
  }
2076
 
2077
 
@@ -2100,7 +2099,7 @@ function SetTColor($col, $return=false) {
2100
  if ($out=='') { return ''; }
2101
  $this->TextColor = $out;
2102
  $this->ColorFlag = ($this->FillColor != $out);
2103
- }
2104
 
2105
 
2106
  function SetDrawColor($r,$g=-1,$b=-1,$col4=-1, $return=false) {
@@ -2154,21 +2153,21 @@ function GetCharWidthCore($c) {
2154
  $c = (string)$c;
2155
  $w = 0;
2156
  // Soft Hyphens chr(173)
2157
- if ($c == chr(173) && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
2158
  return 0;
2159
  }
2160
- else if ($this->S && isset($this->upperCase[ord($c)])) {
2161
  $charw = $this->CurrentFont['cw'][chr($this->upperCase[ord($c)])];
2162
- if ($charw!==false) {
2163
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2164
- $w+=$charw;
2165
  }
2166
  }
2167
- else if (isset($this->CurrentFont['cw'][$c])) {
2168
- $w += $this->CurrentFont['cw'][$c];
2169
- }
2170
- else if (isset($this->CurrentFont['cw'][ord($c)])) {
2171
- $w += $this->CurrentFont['cw'][ord($c)];
2172
  }
2173
  $w *= ($this->FontSize/ 1000);
2174
  if ($this->minwSpacing || $this->fixedlSpacing) {
@@ -2188,9 +2187,9 @@ function GetCharWidthNonCore($c, $addSubset=true) {
2188
  if ($char == 173) { return 0; } // Soft Hyphens
2189
  else if ($this->S && isset($this->upperCase[$char])) {
2190
  $charw = $this->_getCharWidth($this->CurrentFont['cw'],$this->upperCase[$char]);
2191
- if ($charw!==false) {
2192
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2193
- $w+=$charw;
2194
  }
2195
  elseif(isset($this->CurrentFont['desc']['MissingWidth'])) { $w += $this->CurrentFont['desc']['MissingWidth']; }
2196
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
@@ -2216,7 +2215,7 @@ function GetCharWidthNonCore($c, $addSubset=true) {
2216
  function GetCharWidth($c, $addSubset=true) {
2217
  if (!$this->usingCoreFont) {
2218
  return $this->GetCharWidthNonCore($c, $addSubset);
2219
- }
2220
  else {
2221
  return $this->GetCharWidthCore($c);
2222
  }
@@ -2235,18 +2234,18 @@ function GetStringWidth($s, $addSubset=true) {
2235
  if ($this->iterationCounter) $s = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/', '\\1', $s);
2236
 
2237
  if (!$this->usingCoreFont) {
2238
- $s = str_replace("\xc2\xad",'',$s );
2239
  $unicode = $this->UTF8StringToArray($s, $addSubset);
2240
  if ($this->minwSpacing || $this->fixedlSpacing) {
2241
- $nb_carac = count($unicode);
2242
- $nb_spaces = mb_substr_count($s,' ', $this->mb_enc);
2243
  }
2244
  foreach($unicode as $char) {
2245
  if ($this->S && isset($this->upperCase[$char])) {
2246
  $charw = $this->_getCharWidth($cw,$this->upperCase[$char]);
2247
- if ($charw!==false) {
2248
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2249
- $w+=$charw;
2250
  }
2251
  elseif(isset($this->CurrentFont['desc']['MissingWidth'])) { $w += $this->CurrentFont['desc']['MissingWidth']; }
2252
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
@@ -2259,40 +2258,40 @@ function GetStringWidth($s, $addSubset=true) {
2259
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
2260
  else { $w += 500; }
2261
  if ($this->kerning && $this->useKerning && $lastchar) {
2262
- if (isset($this->CurrentFont['kerninfo'][$lastchar][$char])) {
2263
- $kerning += $this->CurrentFont['kerninfo'][$lastchar][$char];
2264
  }
2265
  }
2266
  $lastchar = $char;
2267
  }
2268
  }
2269
 
2270
- }
2271
  else {
2272
- if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
2273
- $s = str_replace(chr(173),'',$s );
2274
  }
2275
  $nb_carac = $l = strlen($s);
2276
  if ($this->minwSpacing || $this->fixedlSpacing) {
2277
- $nb_spaces = substr_count($s,' ');
2278
  }
2279
  for($i=0; $i<$l; $i++) {
2280
- if ($this->S && isset($this->upperCase[ord($s[$i])])) {
2281
  $charw = $cw[chr($this->upperCase[ord($s[$i])])];
2282
- if ($charw!==false) {
2283
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2284
- $w+=$charw;
2285
  }
2286
  }
2287
- else if (isset($cw[$s[$i]])) {
2288
- $w += $cw[$s[$i]];
2289
- }
2290
- else if (isset($cw[ord($s[$i])])) {
2291
- $w += $cw[ord($s[$i])];
2292
  }
2293
  if ($this->kerning && $this->useKerning && $i>0) {
2294
- if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$s[$i]])) {
2295
- $kerning += $this->CurrentFont['kerninfo'][$s[($i-1)]][$s[$i]];
2296
  }
2297
  }
2298
  }
@@ -2309,7 +2308,7 @@ function SetLineWidth($width) {
2309
  $this->LineWidth=$width;
2310
  $lwout = (sprintf('%.3F w',$width*_MPDFK));
2311
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['LineWidth']) && $this->pageoutput[$this->page]['LineWidth'] != $lwout) || !isset($this->pageoutput[$this->page]['LineWidth']) || $this->keep_block_together)) {
2312
- $this->_out($lwout);
2313
  }
2314
  $this->pageoutput[$this->page]['LineWidth'] = $lwout;
2315
  }
@@ -2320,7 +2319,7 @@ function Line($x1,$y1,$x2,$y2) {
2320
  }
2321
 
2322
  function Arrow($x1,$y1,$x2,$y2,$headsize=3,$fill='B',$angle=25) {
2323
- //F == fill //S == stroke //B == stroke and fill
2324
  // angle = splay of arrowhead - 1 - 89 degrees
2325
  if($fill=='F') $fill='f';
2326
  elseif($fill=='FD' or $fill=='DF' or $fill=='B') $fill='B';
@@ -2393,15 +2392,15 @@ function AddFont($family,$style='') {
2393
  }
2394
  if (!$ttffile) {
2395
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2396
- if (!file_exists($ttffile)) {
2397
  /*
2398
  * Try load in the font file from the PDF_TEMPLATE
2399
  */
2400
  global $gfpdfe_data;
2401
- $ttffile = $gfpdfe_data->template_site_location . 'fonts/' . $this->fontdata[$family][$stylekey];
2402
  if(!file_exists($ttffile))
2403
  {
2404
- die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile);
2405
  }
2406
  }
2407
  }
@@ -2418,12 +2417,12 @@ function AddFont($family,$style='') {
2418
  else if (!$BMPonly && $BMPselected) { $regenerate = true; }
2419
  if ($this->useKerning && !$haskerninfo) { $regenerate = true; }
2420
  // mPDF 5.4.05
2421
- if (isset($this->fontdata[$family]['unAGlyphs']) && $this->fontdata[$family]['unAGlyphs'] && !$unAGlyphs) {
2422
- $regenerate = true;
2423
  $unAGlyphs = true;
2424
  }
2425
- else if ((!isset($this->fontdata[$family]['unAGlyphs']) || !$this->fontdata[$family]['unAGlyphs']) && $unAGlyphs) {
2426
- $regenerate = true;
2427
  $unAGlyphs = false;
2428
  }
2429
  if (!isset($name) || $originalsize != $ttfstat['size'] || $regenerate) {
@@ -2474,13 +2473,13 @@ function AddFont($family,$style='') {
2474
  else $s.='$BMPselected=false;'."\n";
2475
  $s.='$fontkey=\''.$fontkey."';\n";
2476
  $s.='$panose=\''.$panose."';\n";
2477
- if ($this->useKerning) {
2478
- $s.='$kerninfo='.var_export($kerninfo,true).";\n";
2479
  $s.='$haskerninfo=true;'."\n";
2480
  }
2481
  else $s.='$haskerninfo=false;'."\n";
2482
  // mPDF 5.4.05
2483
- if ($this->fontdata[$family]['unAGlyphs']) {
2484
  $s.='$unAGlyphs=true;'."\n";
2485
  }
2486
  else $s.='$unAGlyphs=false;'."\n";
@@ -2501,7 +2500,7 @@ function AddFont($family,$style='') {
2501
  unset($ttf);
2502
  }
2503
  else {
2504
- $cw = @file_get_contents(_MPDF_TTFONTDATAPATH.$fontkey.'.cw.dat');
2505
  }
2506
 
2507
  if (isset($this->fontdata[$family]['indic']) && $this->fontdata[$family]['indic']) { $indic = true; }
@@ -2534,19 +2533,19 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2534
  if ($family == 'mono' || $family == 'monospace') { $family = $this->mono_fonts[0]; }
2535
  }
2536
  if (isset($this->fonttrans[$family]) && $this->fonttrans[$family]) { $family = $this->fonttrans[$family]; }
2537
- if($family=='') {
2538
  if ($this->FontFamily) { $family=$this->FontFamily; }
2539
  else if ($this->default_font) { $family=$this->default_font; }
2540
  else { $this->Error("No font or default font set!"); }
2541
  }
2542
  $this->ReqFontStyle = $style; // required or requested style - used later for artificial bold/italic
2543
 
2544
- if (($family == 'csymbol') || ($family == 'czapfdingbats') || ($family == 'ctimes') || ($family == 'ccourier') || ($family == 'chelvetica')) {
2545
  if ($this->PDFA || $this->PDFX) {
2546
- if ($family == 'csymbol' || $family == 'czapfdingbats') {
2547
  $this->Error("Symbol and Zapfdingbats cannot be embedded in mPDF (required for PDFA1-b or PDFX/1-a).");
2548
  }
2549
- if ($family == 'ctimes' || $family == 'ccourier' || $family == 'chelvetica') {
2550
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Core Adobe font ".ucfirst($family)." cannot be embedded in mPDF, which is required for PDFA1-b or PDFX/1-a. (Embedded font will be substituted.)"; }
2551
  if ($family == 'chelvetica') { $family = 'sans'; }
2552
  if ($family == 'ctimes') { $family = 'serif'; }
@@ -2570,7 +2569,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2570
  if(strpos($style,'S')!==false) {
2571
  $this->S=true;
2572
  // Small Caps
2573
- if (empty($this->upperCase)) { @include(_MPDF_PATH.'includes/upperCase.php'); }
2574
  $style=str_replace('S','',$style);
2575
  }
2576
  if ($style=='IB') $style='BI';
@@ -2599,7 +2598,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2599
  else {
2600
  $found = 0;
2601
  // else substitute font of similar type
2602
- if (in_array($family,$this->sans_fonts)) {
2603
  $i = array_intersect($this->sans_fonts,$this->available_unifonts);
2604
  if (count($i)) {
2605
  $i = array_values($i);
@@ -2607,11 +2606,11 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2607
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2608
  $style = '';
2609
  }
2610
- $family = $i[0];
2611
  $found = 1;
2612
  }
2613
  }
2614
- else if (in_array($family,$this->serif_fonts)) {
2615
  $i = array_intersect($this->serif_fonts,$this->available_unifonts);
2616
  if (count($i)) {
2617
  $i = array_values($i);
@@ -2619,7 +2618,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2619
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2620
  $style = '';
2621
  }
2622
- $family = $i[0];
2623
  $found = 1;
2624
  }
2625
  }
@@ -2631,7 +2630,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2631
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2632
  $style = '';
2633
  }
2634
- $family = $i[0];
2635
  $found = 1;
2636
  }
2637
  }
@@ -2651,13 +2650,13 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2651
  $style = '';
2652
  }
2653
  else {
2654
- // or with the style specified
2655
  $family = $fas[1];
2656
  $style = $fas[2];
2657
  }
2658
  }
2659
  }
2660
- $fontkey = $family.$style;
2661
  }
2662
  }
2663
  // try to add font (if not already added)
@@ -2668,7 +2667,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2668
  return $family;
2669
  }
2670
 
2671
- $fontkey = $family.$style;
2672
 
2673
  //Select it
2674
  $this->FontFamily = $family;
@@ -2676,7 +2675,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2676
  $this->FontSizePt = $size;
2677
  $this->FontSize = $size / _MPDFK;
2678
  $this->CurrentFont = &$this->fonts[$fontkey];
2679
- if ($write) {
2680
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2681
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
2682
  $this->pageoutput[$this->page]['Font'] = $fontout;
@@ -2709,7 +2708,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2709
  else if (in_array($family,$this->mono_fonts)) { $family = 'ccourier'; }
2710
  else { $family = 'chelvetica'; }
2711
  $this->usingCoreFont = true;
2712
- $fontkey = $family.$style;
2713
  }
2714
 
2715
  if(!isset($this->fonts[$fontkey])) {
@@ -2739,7 +2738,7 @@ function SetFont($family,$style='',$size=0, $write=true, $forcewrite=false) {
2739
  $this->FontSizePt=$size;
2740
  $this->FontSize=$size/_MPDFK;
2741
  $this->CurrentFont=&$this->fonts[$fontkey];
2742
- if ($write) {
2743
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2744
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
2745
  $this->pageoutput[$this->page]['Font'] = $fontout;
@@ -2760,7 +2759,7 @@ function SetFontSize($size,$write=true) {
2760
  $this->FontSizePt=$size;
2761
  $this->FontSize=$size/_MPDFK;
2762
  $this->currentfontsize=$size;
2763
- if ($write) {
2764
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2765
  // Edited mPDF 3.0
2766
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
@@ -2821,7 +2820,7 @@ function Text($x,$y,$txt) {
2821
  if($this->FillColor!=$tc) { $s .= $tc.' '; } // stroke (outline) = same colour as text(fill)
2822
  }
2823
  if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) {
2824
- $aix = '1 0 0.261799 1 %.3F %.3F Tm';
2825
  }
2826
  else { $aix = '%.3F %.3F Td'; }
2827
 
@@ -2834,7 +2833,7 @@ function Text($x,$y,$txt) {
2834
  $s.=sprintf('BT '.$aix.' %s Tj ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$txt2);
2835
  }
2836
  else if (!$this->usingCoreFont) {
2837
- $txt2 = str_replace(chr(194).chr(160),chr(32),$txt);
2838
  $this->UTF8StringToArray($txt2); // this is just to add chars to subset list
2839
  if ($this->kerning && $this->useKerning) { $s .= $this->_kern($txt2, '', $aix, $x, $y); }
2840
  else {
@@ -2907,7 +2906,7 @@ function SetSpacing($cs,$ws) {
2907
 
2908
  // WORD SPACING
2909
  function GetJspacing($nc,$ns,$w,$inclCursive) {
2910
- $ws = 0;
2911
  $charspacing = 0;
2912
  $ww = $this->jSWord;
2913
  $ncx = $nc-1;
@@ -2915,11 +2914,11 @@ function GetJspacing($nc,$ns,$w,$inclCursive) {
2915
  else if ($nc==1) { $charspacing = $w; }
2916
  // Only word spacing allowed / possible
2917
  else if ($this->fixedlSpacing !== false || $inclCursive) {
2918
- if ($ns) { $ws = $w / $ns; }
2919
  }
2920
  else if (!$ns) {
2921
  $charspacing = $w / ($ncx );
2922
- if (($this->jSmaxChar > 0) && ($charspacing > $this->jSmaxChar)) {
2923
  $charspacing = $this->jSmaxChar;
2924
  }
2925
  }
@@ -2933,7 +2932,7 @@ function GetJspacing($nc,$ns,$w,$inclCursive) {
2933
  $cs = $this->jSmaxChar;
2934
  $ww = 1 - (($cs * ($ncx ))/$w);
2935
  }
2936
- $charspacing = $cs;
2937
  $ws = ($w * ($ww) ) / $ns;
2938
  }
2939
  else {
@@ -2942,11 +2941,11 @@ function GetJspacing($nc,$ns,$w,$inclCursive) {
2942
  $cs = $this->jSmaxChar;
2943
  $ww = 1 - (($cs * ($ncx -$ns))/$w);
2944
  }
2945
- $charspacing = $cs;
2946
  $ws = (($w * ($ww) ) / $ns) - $charspacing;
2947
  }
2948
  }
2949
- return array($charspacing,$ws);
2950
  }
2951
 
2952
  function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $currentx=0, $lcpaddingL=0, $lcpaddingR=0, $valign='M', $spanfill=0, $abovefont=0, $belowfont=0, $exactWidth=false) {
@@ -2964,7 +2963,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
2964
  // Automatic page break
2965
  // Allows PAGE-BREAK-AFTER = avoid to work
2966
 
2967
- if (!$this->tableLevel && (($this->y+$this->divheight>$this->PageBreakTrigger) || ($this->y+$h>$this->PageBreakTrigger) ||
2968
  ($this->y+($h*2)>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) {
2969
  $x=$this->x;//Current X position
2970
 
@@ -2977,9 +2976,9 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
2977
  $this->AddPage($this->CurOrientation);
2978
  // Added to correct for OddEven Margins
2979
  $x += $this->MarginCorrection;
2980
- if ($currentx) {
2981
  $currentx += $this->MarginCorrection;
2982
- }
2983
  $this->x=$x;
2984
  // WORD SPACING
2985
  $this->SetSpacing($charspacing,$ws);
@@ -2996,7 +2995,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
2996
 
2997
  if($w==0) $w = $this->w-$this->rMargin-$this->x;
2998
  $s='';
2999
- if($fill==1 && $this->FillColor) {
3000
  if((isset($this->pageoutput[$this->page]['FillColor']) && $this->pageoutput[$this->page]['FillColor'] != $this->FillColor) || !isset($this->pageoutput[$this->page]['FillColor']) || $this->keep_block_together) { $s .= $this->FillColor.' '; }
3001
  $this->pageoutput[$this->page]['FillColor'] = $this->FillColor;
3002
  }
@@ -3021,12 +3020,12 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3021
  if ($abovefont || $belowfont) { // from flowing block - valign always M
3022
  $va = $abovefont + (0.5*$bfs);
3023
  }
3024
- else if ($this->lineheight_correction) {
3025
  if ($valign == 'T') { $va = (0.5 * $bfs * $this->lineheight_correction); }
3026
  else if ($valign == 'B') { $va = $h-(0.5 * $bfs * $this->lineheight_correction); }
3027
  else { $va = 0.5*$h; } // Middle
3028
  }
3029
- else {
3030
  if ($valign == 'T') { $va = (0.5 * $bfs * $this->default_lineheight_correction); }
3031
  else if ($valign == 'B') { $va = $h-(0.5 * $bfs * $this->default_lineheight_correction); }
3032
  else { $va = 0.5*$h; } // Middle
@@ -3043,7 +3042,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3043
  }
3044
 
3045
  $bbw = $tbw = $lbw = $rbw = 0; // Border widths
3046
- if (!empty($this->spanborddet)) {
3047
  if (!isset($this->spanborddet['B'])) { $this->spanborddet['B'] = array('s' => 0, 'style' => '', 'w' => 0); }
3048
  if (!isset($this->spanborddet['T'])) { $this->spanborddet['T'] = array('s' => 0, 'style' => '', 'w' => 0); }
3049
  if (!isset($this->spanborddet['L'])) { $this->spanborddet['L'] = array('s' => 0, 'style' => '', 'w' => 0); }
@@ -3054,7 +3053,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3054
  $rbw = $this->spanborddet['R']['w'];
3055
  }
3056
  if($fill==1 || $border==1 || !empty($this->spanborddet)) {
3057
- if (!empty($this->spanborddet)) {
3058
  if ($fill==1) {
3059
  $s.=sprintf('%.3F %.3F %.3F %.3F re f ',($this->x-$lbw)*_MPDFK,($this->h-$boxtop+$tbw)*_MPDFK,($w+$lbw+$rbw)*_MPDFK,(-$boxheight-$tbw-$bbw)*_MPDFK);
3060
  }
@@ -3077,7 +3076,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3077
  $c = $this->SetDColor($this->spanborddet['T']['c'],true);
3078
  if ($this->spanborddet['T']['style'] == 'double') {
3079
  $s.=sprintf(' %s %.3F w ',$c,$tbw/3*_MPDFK);
3080
- $xadj = $xadj2 = 0;
3081
  if ($this->spanborddet['L']['style'] == 'double') { $xadj = $this->spanborddet['L']['w']*2/3; }
3082
  if ($this->spanborddet['R']['style'] == 'double') { $xadj2 = $this->spanborddet['R']['w']*2/3; }
3083
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw)*_MPDFK,($this->h-$boxtop+$tbw*5/6)*_MPDFK,($this->x+$w+$rbw-$short)*_MPDFK,($this->h-$boxtop+$tbw*5/6)*_MPDFK);
@@ -3103,7 +3102,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3103
  $c = $this->SetDColor($this->spanborddet['B']['c'],true);
3104
  if ($this->spanborddet['B']['style'] == 'double') {
3105
  $s.=sprintf(' %s %.3F w ',$c,$bbw/3*_MPDFK);
3106
- $xadj = $xadj2 = 0;
3107
  if ($this->spanborddet['L']['style'] == 'double') { $xadj = $this->spanborddet['L']['w']*2/3; }
3108
  if ($this->spanborddet['R']['style'] == 'double') { $xadj2 = $this->spanborddet['R']['w']*2/3; }
3109
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw+$xadj)*_MPDFK,($this->h-$boxbottom-$bbw/6)*_MPDFK,($this->x+$w+$rbw-$short-$xadj2)*_MPDFK,($this->h-$boxbottom-$bbw/6)*_MPDFK);
@@ -3129,7 +3128,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3129
  $c = $this->SetDColor($this->spanborddet['L']['c'],true);
3130
  if ($this->spanborddet['L']['style'] == 'double') {
3131
  $s.=sprintf(' %s %.3F w ',$c,$lbw/3*_MPDFK);
3132
- $yadj = $yadj2 = 0;
3133
  if ($this->spanborddet['T']['style'] == 'double') { $yadj = $this->spanborddet['T']['w']*2/3; }
3134
  if ($this->spanborddet['B']['style'] == 'double') { $yadj2 = $this->spanborddet['B']['w']*2/3; }
3135
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw/6)*_MPDFK,($this->h-$boxtop+$tbw-$yadj)*_MPDFK,($this->x-$lbw/6)*_MPDFK,($this->h-$boxbottom-$bbw+$short+$yadj2)*_MPDFK);
@@ -3155,7 +3154,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3155
  $c = $this->SetDColor($this->spanborddet['R']['c'],true);
3156
  if ($this->spanborddet['R']['style'] == 'double') {
3157
  $s.=sprintf(' %s %.3F w ',$c,$rbw/3*_MPDFK);
3158
- $yadj = $yadj2 = 0;
3159
  if ($this->spanborddet['T']['style'] == 'double') { $yadj = $this->spanborddet['T']['w']*2/3; }
3160
  if ($this->spanborddet['B']['style'] == 'double') { $yadj2 = $this->spanborddet['B']['w']*2/3; }
3161
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x+$w+$rbw/6)*_MPDFK,($this->h-$boxtop+$tbw-$yadj)*_MPDFK,($this->x+$w+$rbw/6)*_MPDFK,($this->h-$boxbottom-$bbw+$short+$yadj2)*_MPDFK);
@@ -3190,8 +3189,8 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3190
 
3191
  if($txt!='') {
3192
  if ($exactWidth)
3193
- $stringWidth = $w;
3194
- else
3195
  $stringWidth = $this->GetStringWidth($txt) + ( $this->charspacing * mb_strlen( $txt, $this->mb_enc ) / _MPDFK )
3196
  + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ) / _MPDFK );
3197
 
@@ -3221,7 +3220,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3221
  }
3222
 
3223
  if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) { // Artificial italic
3224
- $aix = '1 0 0.261799 1 %.3F %.3F Tm ';
3225
  }
3226
  else { $aix = '%.3F %.3F Td '; }
3227
 
@@ -3232,22 +3231,22 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3232
  // WORD SPACING
3233
  // IF multibyte - Tw has no effect - need to use alternative method - do word spacing using an adjustment before each space
3234
  if ($this->ws && !$this->usingCoreFont && !$this->CurrentFont['sip'] && !$this->CurrentFont['smp'] && !$this->S) {
3235
- $sub .= ' BT 0 Tw ET ';
3236
  if ($this->kerning && $this->useKerning) { $sub .= $this->_kern($txt, 'MBTw', $aix, ($this->x+$dx), ($this->y+$baseline+$va)); }
3237
  else {
3238
  $space = " ";
3239
  //Convert string to UTF-16BE without BOM
3240
  $space= $this->UTF8ToUTF16BE($space , false);
3241
- $space=$this->_escape($space );
3242
  $sub .=sprintf('BT '.$aix,($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK);
3243
  $t = explode(' ',$txt);
3244
  $sub .=sprintf(' %.3F Tc [',$this->charspacing);
3245
  $numt = count($t);
3246
  for($i=0;$i<$numt;$i++) {
3247
- $tx = $t[$i];
3248
  //Convert string to UTF-16BE without BOM
3249
  $tx = $this->UTF8ToUTF16BE($tx , false);
3250
- $tx = $this->_escape($tx);
3251
  $sub .=sprintf('(%s) ',$tx);
3252
  if (($i+1)<$numt) {
3253
  $adj = -($this->ws)*1000/$this->FontSizePt;
@@ -3261,20 +3260,20 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3261
  else {
3262
  $txt2= $txt;
3263
  if ($this->CurrentFont['type']=='TTF' && ($this->CurrentFont['sip'] || $this->CurrentFont['smp'])) {
3264
- if ($this->S) { $sub .= $this->_smallCaps($txt2, 'SIPSMP', $aix, $dx, _MPDFK, $baseline, $va); }
3265
  else {
3266
  $txt2 = $this->UTF8toSubset($txt2);
3267
  $sub .=sprintf('BT '.$aix.' %s Tj ET',($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK,$txt2);
3268
  }
3269
  }
3270
  else {
3271
- if ($this->S) { $sub .= $this->_smallCaps($txt2, '', $aix, $dx, _MPDFK, $baseline, $va); }
3272
- else if ($this->kerning && $this->useKerning) { $sub .= $this->_kern($txt2, '', $aix, ($this->x+$dx), ($this->y+$baseline+$va)); }
3273
  else {
3274
  if (!$this->usingCoreFont) {
3275
  $txt2 = $this->UTF8ToUTF16BE($txt2, false);
3276
  }
3277
- $txt2=$this->_escape($txt2);
3278
  $sub .=sprintf('BT '.$aix.' (%s) Tj ET',($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK,$txt2);
3279
  }
3280
  }
@@ -3318,13 +3317,13 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3318
  $s .= ' q ';
3319
  $s .= $this->SetTColor($ts['col'], true)."\n";
3320
  if ($ts['col']{0}==5 && ord($ts['col']{4})<100) { // RGBa
3321
- $s .= $this->SetAlpha(ord($ts['col']{4})/100, 'Normal', true, 'F')."\n";
3322
  }
3323
  else if ($ts['col']{0}==6 && ord($ts['col']{5})<100) { // CMYKa
3324
- $s .= $this->SetAlpha(ord($ts['col']{5})/100, 'Normal', true, 'F')."\n";
3325
  }
3326
  else if ($ts['col']{0}==1 && $ts['col']{2}==1 && ord($ts['col']{3})<100) { // Gray
3327
- $s .= $this->SetAlpha(ord($ts['col']{3})/100, 'Normal', true, 'F')."\n";
3328
  }
3329
  $s .= sprintf(' 1 0 0 1 %.4F %.4F cm', $ts['x']*_MPDFK, -$ts['y']*_MPDFK)."\n";
3330
  $s .= $sub;
@@ -3346,7 +3345,7 @@ function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $curre
3346
 
3347
  // WORD SPACING
3348
  if ($this->ws && !$this->usingCoreFont) {
3349
- $this->_out(sprintf('BT %.3F Tc ET',$this->charspacing));
3350
  }
3351
  $this->lasth=$h;
3352
  if( strpos($txt,"\n") !== false) $ln=1; // cell recognizes \n from <BR> tag
@@ -3371,11 +3370,11 @@ function _kern($txt, $mode, $aix, $x, $y) {
3371
  $space = ' ';
3372
  //Convert string to UTF-16BE without BOM
3373
  $space= $this->UTF8ToUTF16BE($space , false);
3374
- $space=$this->_escape($space );
3375
  $s = sprintf(' BT '.$aix,$x*_MPDFK,($this->h-$y)*_MPDFK);
3376
  $t = explode(' ',$txt);
3377
  for($i=0;$i<count($t);$i++) {
3378
- $tx = $t[$i];
3379
 
3380
  $tj = '(';
3381
  $unicode = $this->UTF8StringToArray($tx);
@@ -3386,7 +3385,7 @@ function _kern($txt, $mode, $aix, $x, $y) {
3386
  }
3387
  $tc = code2utf($unicode[$ti]);
3388
  $tc = $this->UTF8ToUTF16BE($tc, false);
3389
- $tj .= $this->_escape($tc);
3390
  }
3391
  $tj .= ')';
3392
  $s.=sprintf(' %.3F Tc [%s] TJ',$this->charspacing,$tj);
@@ -3409,7 +3408,7 @@ function _kern($txt, $mode, $aix, $x, $y) {
3409
  }
3410
  $tx = code2utf($unicode[$i]);
3411
  $tx = $this->UTF8ToUTF16BE($tx, false);
3412
- $tj .= $this->_escape($tx);
3413
  }
3414
  $tj .= ')';
3415
  $s.=sprintf(' BT '.$aix.' [%s] TJ ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$tj);
@@ -3423,7 +3422,7 @@ function _kern($txt, $mode, $aix, $x, $y) {
3423
  $kern = -$this->CurrentFont['kerninfo'][$txt[($i-1)]][$txt[$i]];
3424
  $tj .= sprintf(')%d(',$kern);
3425
  }
3426
- $tj .= $this->_escape($txt[$i]);
3427
  }
3428
  $tj .= ')';
3429
  $s.=sprintf(' BT '.$aix.' [%s] TJ ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$tj);
@@ -3437,30 +3436,30 @@ function _smallCaps($txt, $mode, $aix, $dx, $k, $baseline, $va) {
3437
  $upp = false;
3438
  $str = array();
3439
  $bits = array();
3440
- if (!$this->usingCoreFont) {
3441
  $unicode = $this->UTF8StringToArray($txt);
3442
  foreach($unicode as $char) {
3443
  if ($this->ws && $char == 32) { // space
3444
  if (count($str)) { $bits[] = array($upp, $str, false); }
3445
- $bits[] = array(false, array(32), true);
3446
- $str = array();
3447
  $upp = false;
3448
  }
3449
- else if (isset($this->upperCase[$char])) {
3450
- if (!$upp) {
3451
  if (count($str)) { $bits[] = array($upp, $str, false); }
3452
- $str = array();
3453
  }
3454
- $str[] = $this->upperCase[$char];
3455
- if ((!isset($this->CurrentFont['sip']) || !$this->CurrentFont['sip']) && (!isset($this->CurrentFont['smp']) || !$this->CurrentFont['smp'])) {
3456
  $this->CurrentFont['subset'][$this->upperCase[$char]] = $this->upperCase[$char];
3457
  }
3458
  $upp = true;
3459
  }
3460
- else {
3461
- if ($upp) {
3462
  if (count($str)) { $bits[] = array($upp, $str, false); }
3463
- $str = array();
3464
  }
3465
  $str[] = $char;
3466
  $upp = false;
@@ -3469,18 +3468,18 @@ function _smallCaps($txt, $mode, $aix, $dx, $k, $baseline, $va) {
3469
  }
3470
  else {
3471
  for($i=0;$i<strlen($txt);$i++) {
3472
- if (isset($this->upperCase[ord($txt[$i])]) && $this->upperCase[ord($txt[$i])] < 256) {
3473
- if (!$upp) {
3474
  if (count($str)) { $bits[] = array($upp, $str, false); }
3475
- $str = array();
3476
  }
3477
- $str[] = $this->upperCase[ord($txt[$i])];
3478
  $upp = true;
3479
  }
3480
- else {
3481
- if ($upp) {
3482
  if (count($str)) { $bits[] = array($upp, $str, false); }
3483
- $str = array();
3484
  }
3485
  $str[] = ord($txt[$i]);
3486
  $upp = false;
@@ -3499,35 +3498,35 @@ function _smallCaps($txt, $mode, $aix, $dx, $k, $baseline, $va) {
3499
  $size = count ($b[1]);
3500
  $txt = '';
3501
  for ($i = 0; $i < $size; $i++) {
3502
- $txt .= code2utf($b[1][$i]);
3503
  }
3504
- if ($this->usingCoreFont) {
3505
  $txt = utf8_decode($txt);
3506
  }
3507
  if ($mode == 'SIPSMP') {
3508
  $txt = $this->UTF8toSubset($txt);
3509
  }
3510
- else {
3511
  if (!$this->usingCoreFont) {
3512
  $txt = $this->UTF8ToUTF16BE($txt, false);
3513
  }
3514
- $txt=$this->_escape($txt);
3515
  $txt = '('.$txt.')';
3516
  }
3517
  if ($b[2]) { // space
3518
- $s.=sprintf(' /F%d %.3F Tf %d Tz', $fid, $this->FontSizePt, 100);
3519
  $s.=sprintf(' %.3F Tc', ($this->charspacing+$this->ws));
3520
  $s.=sprintf(' %s Tj', $txt);
3521
  }
3522
- else if ($upp) {
3523
- $s.=sprintf(' /F%d %.3F Tf', $fid, $this->FontSizePt*$this->smCapsScale);
3524
- $s.=sprintf(' %d Tz', $this->smCapsStretch);
3525
  $s.=sprintf(' %.3F Tc', ($this->charspacing*100/$this->smCapsStretch));
3526
  $s.=sprintf(' %s Tj', $txt);
3527
  }
3528
- else {
3529
- $s.=sprintf(' /F%d %.3F Tf %d Tz', $fid, $this->FontSizePt, 100);
3530
- $s.=sprintf(' %.3F Tc', ($this->charspacing));
3531
  $s.=sprintf(' %s Tj', $txt);
3532
  }
3533
  }
@@ -3635,10 +3634,10 @@ function MultiCell($w,$h,$txt,$border=0,$align='',$fill=0,$link='',$directionali
3635
  // JUSTIFY J using Unicode fonts (Word spacing doesn't work)
3636
  // WORD SPACING UNICODE
3637
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
3638
- $tmp = str_replace(chr(194).chr(160),chr(32),$tmp );
3639
  $len_ligne = $this->GetStringWidth($tmp );
3640
- $nb_carac = mb_strlen( $tmp , $this->mb_enc ) ;
3641
- $nb_spaces = mb_substr_count( $tmp ,' ', $this->mb_enc ) ;
3642
 
3643
  $inclCursive=false;
3644
  if ($checkCursive) {
@@ -3713,8 +3712,8 @@ function MultiCell($w,$h,$txt,$border=0,$align='',$fill=0,$link='',$directionali
3713
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
3714
  $tmp = str_replace(chr(160),chr(32),$tmp);
3715
  $len_ligne = $this->GetStringWidth($tmp );
3716
- $nb_carac = strlen( $tmp ) ;
3717
- $nb_spaces = substr_count( $tmp ,' ' ) ;
3718
  list($charspacing,$ws) = $this->GetJspacing($nb_carac,$nb_spaces,((($wmax) - $len_ligne) * _MPDFK),false);
3719
  $this->SetSpacing($charspacing,$ws);
3720
  //////////////////////////////////////////
@@ -3757,13 +3756,13 @@ function saveInlineProperties() {
3757
  $saved[ 'style' ] = $this->FontStyle;
3758
  $saved[ 'sizePt' ] = $this->FontSizePt;
3759
  $saved[ 'size' ] = $this->FontSize;
3760
- $saved[ 'HREF' ] = $this->HREF;
3761
- $saved[ 'underline' ] = $this->U;
3762
  $saved[ 'smCaps' ] = $this->S;
3763
  $saved[ 'strike' ] = $this->strike;
3764
  $saved[ 'textshadow' ] = $this->textshadow;
3765
- $saved[ 'SUP' ] = $this->SUP;
3766
- $saved[ 'SUB' ] = $this->SUB;
3767
  $saved[ 'linewidth' ] = $this->LineWidth;
3768
  $saved[ 'drawcolor' ] = $this->DrawColor;
3769
  $saved[ 'is_outline' ] = $this->outline_on;
@@ -3779,7 +3778,7 @@ function saveInlineProperties() {
3779
  $saved[ 'colorarray' ] = $this->colorarray;
3780
  $saved[ 'bgcolorarray' ] = $this->spanbgcolorarray;
3781
  $saved[ 'border' ] = $this->spanborddet;
3782
- $saved[ 'color' ] = $this->TextColor;
3783
  $saved[ 'bgcolor' ] = $this->FillColor;
3784
  $saved['lang'] = $this->currentLang;
3785
  $saved['display_off'] = $this->inlineDisplayOff;
@@ -3795,14 +3794,14 @@ function restoreInlineProperties( &$saved) {
3795
 
3796
  $this->currentLang = $saved['lang'];
3797
  if ($this->useLang && !$this->usingCoreFont) {
3798
- if ($this->currentLang != $this->default_lang && ((strlen($this->currentLang) == 5 && $this->currentLang != 'UTF-8') || strlen($this->currentLang ) == 2)) {
3799
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($this->currentLang, $this->useAdobeCJK);
3800
  if ($mpdf_pdf_unifonts) { $this->RestrictUnicodeFonts($mpdf_pdf_unifonts); }
3801
  else { $this->RestrictUnicodeFonts($this->default_available_fonts ); }
3802
  }
3803
- else {
3804
  $this->RestrictUnicodeFonts($this->default_available_fonts );
3805
- }
3806
  }
3807
 
3808
  $this->ColorFlag = ($this->FillColor != $this->TextColor); //Restore ColorFlag as well
@@ -3830,7 +3829,7 @@ function restoreInlineProperties( &$saved) {
3830
  }
3831
  else { $this->fixedlSpacing = false; }
3832
  $this->wSpacingCSS = $saved[ 'wSpacingCSS' ];
3833
- if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
3834
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
3835
  }
3836
  else { $this->minwSpacing = 0; }
@@ -3890,13 +3889,13 @@ function saveFont() {
3890
  $saved[ 'sizePt' ] = $this->FontSizePt;
3891
  $saved[ 'size' ] = $this->FontSize;
3892
  $saved[ 'curr' ] = &$this->CurrentFont;
3893
- $saved[ 'color' ] = $this->TextColor;
3894
- $saved[ 'spanbgcolor' ] = $this->spanbgcolor;
3895
- $saved[ 'spanbgcolorarray' ] = $this->spanbgcolorarray;
3896
  $saved[ 'bord' ] = $this->spanborder;
3897
  $saved[ 'border' ] = $this->spanborddet;
3898
  $saved[ 'HREF' ] = $this->HREF;
3899
- $saved[ 'underline' ] = $this->U;
3900
  $saved[ 'smCaps' ] = $this->S;
3901
  $saved[ 'strike' ] = $this->strike;
3902
  $saved[ 'textshadow' ] = $this->textshadow;
@@ -3907,7 +3906,7 @@ function saveFont() {
3907
  $saved[ 'is_outline' ] = $this->outline_on;
3908
  $saved[ 'outlineparam' ] = $this->outlineparam;
3909
  $saved[ 'ReqFontStyle' ] = $this->ReqFontStyle;
3910
- $saved[ 'fontkerning' ] = $this->kerning;
3911
  $saved[ 'fixedlSpacing' ] = $this->fixedlSpacing;
3912
  $saved[ 'minwSpacing' ] = $this->minwSpacing;
3913
  return $saved;
@@ -3921,40 +3920,40 @@ function restoreFont( &$saved, $write=true) {
3921
  $this->FontSizePt = $saved[ 'sizePt' ];
3922
  $this->FontSize = $saved[ 'size' ];
3923
  $this->CurrentFont = &$saved[ 'curr' ];
3924
- $this->TextColor = $saved[ 'color' ];
3925
- $this->spanbgcolor = $saved[ 'spanbgcolor' ];
3926
- $this->spanbgcolorarray = $saved[ 'spanbgcolorarray' ];
3927
  $this->spanborder = $saved[ 'bord' ];
3928
  $this->spanborddet = $saved[ 'border' ];
3929
  $this->ColorFlag = ($this->FillColor != $this->TextColor); //Restore ColorFlag as well
3930
- $this->HREF = $saved[ 'HREF' ];
3931
- $this->U = $saved[ 'underline' ];
3932
  $this->S = $saved[ 'smCaps' ];
3933
  $this->kerning = $saved[ 'fontkerning' ];
3934
  $this->fixedlSpacing = $saved[ 'fixedlSpacing' ];
3935
  $this->minwSpacing = $saved[ 'minwSpacing' ];
3936
- $this->strike = $saved[ 'strike' ];
3937
  $this->textshadow = $saved[ 'textshadow' ];
3938
- $this->SUP = $saved[ 'SUP' ];
3939
- $this->SUB = $saved[ 'SUB' ];
3940
- $this->LineWidth = $saved[ 'linewidth' ];
3941
- $this->DrawColor = $saved[ 'drawcolor' ];
3942
- $this->outline_on = $saved[ 'is_outline' ];
3943
  $this->outlineparam = $saved[ 'outlineparam' ];
3944
- if ($write) {
3945
  $this->SetFont($saved[ 'family' ],$saved[ 'style' ].($this->U ? 'U' : '').($this->S ? 'S' : ''),$saved[ 'sizePt' ],true,true); // force output
3946
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
3947
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
3948
  $this->pageoutput[$this->page]['Font'] = $fontout;
3949
  }
3950
- else
3951
  $this->SetFont($saved[ 'family' ],$saved[ 'style' ].($this->U ? 'U' : '').($this->S ? 'S' : ''),$saved[ 'sizePt' ]);
3952
  $this->ReqFontStyle = $saved[ 'ReqFontStyle' ];
3953
  }
3954
 
3955
  function newFlowingBlock( $w, $h, $a = '', $is_table = false, $is_list = false, $blockstate = 0, $newblock=true, $blockdir='ltr')
3956
  {
3957
- if (!$a) {
3958
  if ($blockdir=='rtl') { $a = 'R'; }
3959
  else { $a = 'L'; }
3960
  }
@@ -4024,16 +4023,16 @@ function finishFlowingBlock($endofblock=false, $next='') {
4024
 
4025
  // Print out each chunk
4026
 
4027
- if ($is_table) {
4028
- $ipaddingL = 0;
4029
- $ipaddingR = 0;
4030
  $paddingL = 0;
4031
  $paddingR = 0;
4032
- }
4033
- else {
4034
- $ipaddingL = $this->blk[$this->blklvl]['padding_left'];
4035
- $ipaddingR = $this->blk[$this->blklvl]['padding_right'];
4036
- $paddingL = ($ipaddingL * _MPDFK);
4037
  $paddingR = ($ipaddingR * _MPDFK);
4038
  $this->cMarginL = $this->blk[$this->blklvl]['border_left']['w'];
4039
  $this->cMarginR = $this->blk[$this->blklvl]['border_right']['w'];
@@ -4043,47 +4042,47 @@ function finishFlowingBlock($endofblock=false, $next='') {
4043
  $fpaddingL = 0;
4044
 
4045
  $usey = $this->y + 0.002;
4046
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4047
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4048
  }
4049
  } // *TABLES*
4050
 
4051
  // Set Current lineheight (correction factor)
4052
- $lhfixed = false;
4053
  if ($is_list) {
4054
- if (preg_match('/([0-9.,]+)mm/',$this->list_lineheight[$this->listlvl][$this->listOcc],$am)) {
4055
- $lhfixed = true;
4056
  $def_fontsize = $this->InlineProperties['LISTITEM'][$this->listlvl][$this->listOcc][$this->listnum]['size'];
4057
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4058
  }
4059
- else {
4060
- $this->lineheight_correction = $this->list_lineheight[$this->listlvl][$this->listOcc];
4061
  }
4062
  }
4063
  else
4064
  if ($is_table) {
4065
- if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight,$am)) {
4066
- $lhfixed = true;
4067
  $def_fontsize = $this->FontSize; // needs to be default font-size for block ****
4068
- $this->lineheight_correction = $lineHeight / $def_fontsize ;
4069
  }
4070
- else {
4071
- $this->lineheight_correction = $this->table_lineheight;
4072
  }
4073
  }
4074
  else
4075
  if (isset($this->blk[$this->blklvl]['line_height']) && $this->blk[$this->blklvl]['line_height']) {
4076
- if (preg_match('/([0-9.,]+)mm/',$this->blk[$this->blklvl]['line_height'],$am)) {
4077
- $lhfixed = true;
4078
  $def_fontsize = $this->blk[$this->blklvl]['InlineProperties']['size']; // needs to be default font-size for block ****
4079
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4080
  }
4081
- else {
4082
- $this->lineheight_correction = $this->blk[$this->blklvl]['line_height'];
4083
  }
4084
- }
4085
  else {
4086
- $this->lineheight_correction = $this->normalLineheight;
4087
  }
4088
 
4089
  // correct lineheight to maximum fontsize
@@ -4096,10 +4095,10 @@ function finishFlowingBlock($endofblock=false, $next='') {
4096
  foreach ( $content as $k => $chunk )
4097
  {
4098
  $this->restoreFont( $font[ $k ],false );
4099
- if (!isset($this->objectbuffer[$k])) {
4100
  // Soft Hyphens chr(173)
4101
  if (!$this->usingCoreFont) {
4102
- $content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk );
4103
  }
4104
  else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
4105
  $content[$k] = $chunk = str_replace(chr(173),'',$chunk );
@@ -4108,8 +4107,8 @@ function finishFlowingBlock($endofblock=false, $next='') {
4108
  if (($this->SUB || $this->SUP) && count($content)==1) { $actfs = $this->FontSize*100/55; } // 55% is font change for sub/sup
4109
  else { $actfs = $this->FontSize; }
4110
  if (!$lhfixed) { $maxlineHeight = max($maxlineHeight,$actfs * $this->lineheight_correction ); }
4111
- if ($lhfixed && ($actfs > $def_fontsize || ($actfs > ($lineHeight * $this->lineheight_correction) && $is_list))) {
4112
- $this->forceExactLineheight = false;
4113
  }
4114
  $maxfontsize = max($maxfontsize,$actfs);
4115
  }
@@ -4140,12 +4139,12 @@ function finishFlowingBlock($endofblock=false, $next='') {
4140
 
4141
  $af = 0; // Above font
4142
  $bf = 0; // Below font
4143
- $mta = 0; // Maximum top-aligned
4144
- $mba = 0; // Maximum bottom-aligned
4145
 
4146
  foreach ( $content as $k => $chunk )
4147
  {
4148
- if (isset($this->objectbuffer[$k])) {
4149
  $oh = $this->objectbuffer[$k]['OUTER-HEIGHT'];
4150
  $va = $this->objectbuffer[$k]['vertical-align']; // = $objattr['vertical-align'] = set as M,T,B,S
4151
  if ($lhfixed && $oh > $def_fontsize) { $this->forceExactLineheight = false; }
@@ -4153,20 +4152,20 @@ function finishFlowingBlock($endofblock=false, $next='') {
4153
  if ($va == 'BS') { // (BASELINE default)
4154
  $af = max($af, ($oh - ($maxfontsize * (0.5 + $this->baselineC))));
4155
  }
4156
- else if ($va == 'M') {
4157
  $af = max($af, ($oh - $maxfontsize)/2);
4158
  $bf = max($bf, ($oh - $maxfontsize)/2);
4159
  }
4160
- else if ($va == 'TT') {
4161
  $bf = max($bf, ($oh - $maxfontsize));
4162
  }
4163
- else if ($va == 'TB') {
4164
  $af = max($af, ($oh - $maxfontsize));
4165
  }
4166
- else if ($va == 'T') {
4167
  $mta = max($mta, $oh);
4168
  }
4169
- else if ($va == 'B') {
4170
  $mba = max($mba, $oh);
4171
  }
4172
  }
@@ -4175,19 +4174,19 @@ function finishFlowingBlock($endofblock=false, $next='') {
4175
  $maxlineHeight = $maxfontsize + $af + $bf;
4176
  }
4177
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
4178
- if ($mta > $maxlineHeight) {
4179
  $bf += ($mta - $maxlineHeight);
4180
  $maxlineHeight = $mta;
4181
  }
4182
- if ($mba > $maxlineHeight) {
4183
  $af += ($mba - $maxlineHeight);
4184
  $maxlineHeight = $mba;
4185
  }
4186
 
4187
  $lineHeight = $maxlineHeight;
4188
  // If NOT images, and maxfontsize NOT > lineHeight - this value determines text baseline positioning
4189
- if ($lhfixed && $af==0 && $bf==0 && $maxfontsize<=($def_fontsize * $this->lineheight_correction * 0.8 )) {
4190
- $this->linemaxfontsize = $def_fontsize;
4191
  }
4192
  else { $this->linemaxfontsize = $maxfontsize; }
4193
 
@@ -4199,19 +4198,19 @@ function finishFlowingBlock($endofblock=false, $next='') {
4199
  // but ? needs to fix potentially more widespread...
4200
  // if (!$content) { $check_h = 0; }
4201
 
4202
- if ($this->blklvl > 0 && !$is_table) {
4203
- if ($endofblock && $blockstate > 1) {
4204
  if ($this->blk[$this->blklvl]['page_break_after_avoid']) { $check_h += $lineHeight; }
4205
  $check_h += ($this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w']);
4206
  }
4207
  // mPDF 5.4.03
4208
- if (($newblock && ($blockstate==1 || $blockstate==3) && $lineCount == 0) || ($endofblock && $blockstate ==3 && $lineCount == 0)) {
4209
  $check_h += ($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['border_top']['w']);
4210
  }
4211
  }
4212
 
4213
  // Force PAGE break if column height cannot take check-height
4214
- if ($this->ColActive && $check_h > ($this->PageBreakTrigger - $this->y0)) {
4215
  $this->SetCol($this->NbCol-1);
4216
  }
4217
 
@@ -4248,27 +4247,27 @@ function finishFlowingBlock($endofblock=false, $next='') {
4248
 
4249
 
4250
  // TOP MARGIN
4251
- if ($newblock && ($blockstate==1 || $blockstate==3) && ($this->blk[$this->blklvl]['margin_top']) && $lineCount == 0 && !$is_table && !$is_list) {
4252
- $this->DivLn($this->blk[$this->blklvl]['margin_top'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
4253
  }
4254
 
4255
- if ($newblock && ($blockstate==1 || $blockstate==3) && $lineCount == 0 && !$is_table && !$is_list) {
4256
  $this->blk[$this->blklvl]['y0'] = $this->y;
4257
  $this->blk[$this->blklvl]['startpage'] = $this->page;
4258
  }
4259
 
4260
  // ADDED for Paragraph_indent
4261
  $WidthCorrection = 0;
4262
- if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align != 'C')) {
4263
- $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4264
- $WidthCorrection = ($ti*_MPDFK);
4265
- }
4266
 
4267
 
4268
  // PADDING and BORDER spacing/fill
4269
- if (($newblock) && ($blockstate==1 || $blockstate==3) && (($this->blk[$this->blklvl]['padding_top']) || ($this->blk[$this->blklvl]['border_top'])) && ($lineCount == 0) && (!$is_table) && (!$is_list)) {
4270
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
4271
- $this->DivLn($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'],-3,true,false,1);
4272
  $this->x = $currentx;
4273
  }
4274
 
@@ -4278,7 +4277,7 @@ function finishFlowingBlock($endofblock=false, $next='') {
4278
  $fpaddingL = 0;
4279
 
4280
  $usey = $this->y + 0.002;
4281
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4282
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4283
  }
4284
 
@@ -4298,10 +4297,10 @@ function finishFlowingBlock($endofblock=false, $next='') {
4298
  $chunk = str_replace(chr(160),chr(32),$chunk );
4299
  }
4300
  else {
4301
- $chunk = str_replace(chr(194).chr(160),chr(32),$chunk );
4302
  }
4303
- $nb_carac += mb_strlen( $chunk, $this->mb_enc );
4304
- $nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc );
4305
  if ($checkCursive) {
4306
  }
4307
  }
@@ -4337,9 +4336,9 @@ function finishFlowingBlock($endofblock=false, $next='') {
4337
 
4338
  $empty /= _MPDFK;
4339
 
4340
- if (!$is_table) {
4341
- $this->maxPosR = max($this->maxPosR , ($this->w - $this->rMargin - $this->blk[$this->blklvl]['outer_right_margin'] - $empty));
4342
- $this->maxPosL = min($this->maxPosL , ($this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $empty));
4343
  }
4344
 
4345
  $arraysize = count($content);
@@ -4359,10 +4358,10 @@ function finishFlowingBlock($endofblock=false, $next='') {
4359
 
4360
 
4361
  // Paragraph INDENT
4362
- $WidthCorrection = 0;
4363
- if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align !='C')) {
4364
- $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4365
- $this->x += $ti;
4366
  }
4367
 
4368
 
@@ -4374,28 +4373,28 @@ function finishFlowingBlock($endofblock=false, $next='') {
4374
 
4375
  $va = 'M'; // default for text
4376
  if (isset($this->objectbuffer[$dirk]) && $this->objectbuffer[$dirk]) {
4377
- $xadj = $this->x - $this->objectbuffer[$dirk]['OUTER-X'];
4378
  $this->objectbuffer[$dirk]['OUTER-X'] += $xadj;
4379
  $this->objectbuffer[$dirk]['BORDER-X'] += $xadj;
4380
  $this->objectbuffer[$dirk]['INNER-X'] += $xadj;
4381
  $va = $this->objectbuffer[$dirk]['vertical-align'];
4382
  $yadj = $this->y - $this->objectbuffer[$dirk]['OUTER-Y'];
4383
- if ($va == 'BS') {
4384
  $yadj += $af + ($this->linemaxfontsize * (0.5 + $this->baselineC)) - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4385
  }
4386
- else if ($va == 'M' || $va == '') {
4387
  $yadj += $af + ($this->linemaxfontsize /2) - ($this->objectbuffer[$dirk]['OUTER-HEIGHT']/2);
4388
  }
4389
- else if ($va == 'TB') {
4390
  $yadj += $af + $this->linemaxfontsize - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4391
  }
4392
- else if ($va == 'TT') {
4393
  $yadj += $af;
4394
  }
4395
- else if ($va == 'B') {
4396
  $yadj += $af + $this->linemaxfontsize + $bf - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4397
  }
4398
- else if ($va == 'T') {
4399
  $yadj += 0;
4400
  }
4401
  $this->objectbuffer[$dirk]['OUTER-Y'] += $yadj;
@@ -4414,22 +4413,22 @@ function finishFlowingBlock($endofblock=false, $next='') {
4414
  $this->minwSpacing = 0;
4415
 
4416
  // *********** SPAN BACKGROUND COLOR ***************** //
4417
- if (isset($this->spanbgcolor) && $this->spanbgcolor) {
4418
  $cor = $this->spanbgcolorarray;
4419
  $this->SetFColor($cor);
4420
  $save_fill = $fill; $spanfill = 1; $fill = 1;
4421
  }
4422
- if (!empty($this->spanborddet)) {
4423
  if (strpos($contentB[$k],'L')!==false && isset($this->spanborddet['L'])) $this->x += $this->spanborddet['L']['w'];
4424
- if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0;
4425
- if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0;
4426
  }
4427
  // WORD SPACING
4428
- $stringWidth = $this->GetStringWidth($chunk ) + ( $this->charspacing * mb_strlen($chunk,$this->mb_enc ) / _MPDFK )
4429
  + ( $this->ws * mb_substr_count($chunk,' ',$this->mb_enc ) / _MPDFK );
4430
- if (isset($this->objectbuffer[$dirk])) {
4431
- if ($this->objectbuffer[$dirk]['type']=='dottab') {
4432
- $this->objectbuffer[$dirk]['OUTER-WIDTH'] +=$empty;
4433
  }
4434
  $stringWidth = $this->objectbuffer[$dirk]['OUTER-WIDTH'];
4435
  }
@@ -4438,12 +4437,12 @@ function finishFlowingBlock($endofblock=false, $next='') {
4438
  if ($k == $arraysize-1) $this->Cell( $stringWidth, $lineHeight, $chunk, '', 1, '', $fill, $this->HREF , $currentx,0,0,'M', $fill, $af, $bf, true ); //mono-style line or last part (skips line)
4439
  else $this->Cell( $stringWidth, $lineHeight, $chunk, '', 0, '', $fill, $this->HREF, 0, 0,0,'M', $fill, $af, $bf, true );//first or middle part
4440
 
4441
- if (!empty($this->spanborddet)) {
4442
  if (strpos($contentB[$k],'R')!==false && $k != $arraysize-1) $this->x += $this->spanborddet['R']['w'];
4443
  }
4444
  // *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
4445
- if (isset($spanfill) && $spanfill) {
4446
- $fill = $save_fill; $spanfill = 0;
4447
  if ($fill) { $this->SetFColor($bcor); }
4448
  }
4449
  }
@@ -4462,8 +4461,8 @@ function finishFlowingBlock($endofblock=false, $next='') {
4462
  $savedFont = $this->saveFont();
4463
 
4464
  $bull = $this->bulletarray;
4465
- if (isset($bull['level']) && isset($bull['occur']) && isset($this->InlineProperties['LIST'][$bull['level']][$bull['occur']])) {
4466
- $this->restoreInlineProperties($this->InlineProperties['LIST'][$bull['level']][$bull['occur']]);
4467
  }
4468
  if (isset($bull['level']) && isset($bull['occur']) && isset($bull['num']) && isset($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) && $this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) { $this->restoreInlineProperties($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]); }
4469
  if (isset($bull['font']) && $bull['font'] == 'czapfdingbats') {
@@ -4497,8 +4496,8 @@ function finishFlowingBlock($endofblock=false, $next='') {
4497
 
4498
 
4499
  // PADDING and BORDER spacing/fill
4500
- if ($endofblock && ($blockstate > 1) && ($this->blk[$this->blklvl]['padding_bottom'] || $this->blk[$this->blklvl]['border_bottom'] || $this->blk[$this->blklvl]['css_set_height']) && (!$is_table) && (!$is_list)) {
4501
- // If CSS height set, extend bottom - if on same page as block started, and CSS HEIGHT > actual height,
4502
  // and does not force pagebreak
4503
  $extra = 0;
4504
  if ($this->blk[$this->blklvl]['css_set_height'] && $this->blk[$this->blklvl]['startpage']==$this->page) {
@@ -4506,26 +4505,26 @@ function finishFlowingBlock($endofblock=false, $next='') {
4506
  $h1 = ($this->y-$this->blk[$this->blklvl]['y0']) + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'];
4507
  if ($h1 < ($this->blk[$this->blklvl]['css_set_height']+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['padding_top'])) { $extra = ($this->blk[$this->blklvl]['css_set_height']+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['padding_top']) - $h1; }
4508
  if($this->y + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'] + $extra > $this->PageBreakTrigger) {
4509
- $extra = $this->PageBreakTrigger - ($this->y + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w']);
4510
  }
4511
  }
4512
 
4513
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
4514
- $this->DivLn($this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'] + $extra,-3,true,false,2);
4515
  $this->x = $currentx;
4516
 
4517
 
4518
  }
4519
 
4520
  // SET Bottom y1 of block (used for painting borders)
4521
- if (($endofblock) && ($blockstate > 1) && (!$is_table) && (!$is_list)) {
4522
  $this->blk[$this->blklvl]['y1'] = $this->y;
4523
  }
4524
 
4525
  // BOTTOM MARGIN
4526
- if (($endofblock) && ($blockstate > 1) && ($this->blk[$this->blklvl]['margin_bottom']) && (!$is_table) && (!$is_list)) {
4527
  if($this->y+$this->blk[$this->blklvl]['margin_bottom'] < $this->PageBreakTrigger and !$this->InFooter) {
4528
- $this->DivLn($this->blk[$this->blklvl]['margin_bottom'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
4529
  }
4530
  }
4531
 
@@ -4539,7 +4538,7 @@ function finishFlowingBlock($endofblock=false, $next='') {
4539
 
4540
  function printobjectbuffer($is_table=false, $blockdir=false) {
4541
  if (!$blockdir) { $blockdir = $this->directionality; }
4542
- if ($is_table && $this->shrin_k > 1) { $k = $this->shrin_k; }
4543
  else { $k = 1; }
4544
  $save_y = $this->y;
4545
  $save_x = $this->x;
@@ -4547,14 +4546,14 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4547
  $save_currentfontsize = $this->FontSizePt;
4548
  $save_currentfontstyle = $this->FontStyle.($this->U ? 'U' : '').($this->S ? 'S' : '');
4549
  if ($blockdir == 'rtl') { $rtlalign = 'R'; } else { $rtlalign = 'L'; }
4550
- foreach ($this->objectbuffer AS $ib => $objattr) {
4551
  if ($objattr['type'] == 'bookmark' || $objattr['type'] == 'indexentry' || $objattr['type'] == 'toc') {
4552
- $x = $objattr['OUTER-X'];
4553
  $y = $objattr['OUTER-Y'];
4554
  $this->y = $y - $this->FontSize/2;
4555
  $this->x = $x;
4556
  }
4557
- else {
4558
  $y = $objattr['OUTER-Y'];
4559
  $x = $objattr['OUTER-X'];
4560
  $w = $objattr['OUTER-WIDTH'];
@@ -4605,7 +4604,7 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4605
  $sy = ($objattr['INNER-HEIGHT']*_MPDFK / $objattr['orig_h']);
4606
 
4607
  if (isset($objattr['ROTATE'])) { $rotate = $objattr['ROTATE']; }
4608
- if ($rotate==90) {
4609
  // Clockwise
4610
  $obiw = $objattr['INNER-HEIGHT'];
4611
  $obih = $objattr['INNER-WIDTH'];
@@ -4614,7 +4613,7 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4614
  $sx = $obiw*_MPDFK / $objattr['orig_h'];
4615
  $sy = $obih*_MPDFK / $objattr['orig_w'];
4616
  }
4617
- else if ($rotate==-90 || $rotate==270) {
4618
  // AntiClockwise
4619
  $obiw = $objattr['INNER-HEIGHT'];
4620
  $obih = $objattr['INNER-WIDTH'];
@@ -4623,7 +4622,7 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4623
  $sx = $obiw*_MPDFK / $objattr['orig_h'];
4624
  $sy = $obih*_MPDFK / $objattr['orig_w'];
4625
  }
4626
- else if ($rotate==180) {
4627
  // Mirror
4628
  $tr = $this->transformTranslate($objattr['INNER-WIDTH'], -$objattr['INNER-HEIGHT'], true) ;
4629
  $tr .= ' '. $this->transformRotate(180, $objattr['INNER-X'],($objattr['INNER-Y'] +$objattr['INNER-HEIGHT'] ),true) ;
@@ -4634,10 +4633,10 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4634
  $gradmask = '';
4635
 
4636
 
4637
- if (isset($objattr['itype']) && $objattr['itype']=='svg') {
4638
  $outstring = sprintf('q '.$tr.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']);
4639
  }
4640
- else {
4641
  $outstring = sprintf("q ".$tr."%.3F 0 0 %.3F %.3F %.3F cm ".$gradmask."/I%d Do Q",$obiw*_MPDFK, $obih*_MPDFK, $objattr['INNER-X'] *_MPDFK, ($this->h-($objattr['INNER-Y'] +$obih ))*_MPDFK,$objattr['ID'] );
4642
  }
4643
  $this->_out($outstring);
@@ -4721,7 +4720,7 @@ function printobjectbuffer($is_table=false, $blockdir=false) {
4721
 
4722
  function WriteFlowingBlock( $s)
4723
  {
4724
- $currentx = $this->x;
4725
  $is_table = $this->flowingBlockAttr[ 'is_table' ];
4726
  $is_list = $this->flowingBlockAttr[ 'is_list' ];
4727
  // width of all the content so far in points
@@ -4770,22 +4769,22 @@ function WriteFlowingBlock( $s)
4770
  $oldcolumn = $this->CurrCol;
4771
 
4772
 
4773
- if ($is_table) {
4774
- $ipaddingL = 0;
4775
- $ipaddingR = 0;
4776
- $paddingL = 0;
4777
- $paddingR = 0;
4778
  $cpaddingadjustL = 0;
4779
  $cpaddingadjustR = 0;
4780
  // Added mPDF 3.0
4781
  $fpaddingR = 0;
4782
  $fpaddingL = 0;
4783
- }
4784
- else {
4785
- $ipaddingL = $this->blk[$this->blklvl]['padding_left'];
4786
- $ipaddingR = $this->blk[$this->blklvl]['padding_right'];
4787
- $paddingL = ($ipaddingL * _MPDFK);
4788
- $paddingR = ($ipaddingR * _MPDFK);
4789
  $this->cMarginL = $this->blk[$this->blklvl]['border_left']['w'];
4790
  $cpaddingadjustL = -$this->cMarginL;
4791
  $this->cMarginR = $this->blk[$this->blklvl]['border_right']['w'];
@@ -4795,7 +4794,7 @@ function WriteFlowingBlock( $s)
4795
  $fpaddingL = 0;
4796
 
4797
  $usey = $this->y + 0.002;
4798
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4799
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4800
  }
4801
  } // *TABLES*
@@ -4803,13 +4802,13 @@ function WriteFlowingBlock( $s)
4803
  //OBJECTS - IMAGES & FORM Elements (NB has already skipped line/page if required - in printbuffer)
4804
  if (substr($s,0,3) == "\xbb\xa4\xac") { //identifier has been identified!
4805
  $objattr = $this->_getObjAttr($s);
4806
- $h_corr = 0;
4807
  if ($is_table) { // *TABLES*
4808
  $maximumW = ($maxWidth/_MPDFK) - ($this->cellPaddingL + $this->cMarginL + $this->cellPaddingR + $this->cMarginR); // *TABLES*
4809
  } // *TABLES*
4810
  else { // *TABLES*
4811
  if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) && (!$is_table)) { $h_corr = $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w']; }
4812
- $maximumW = ($maxWidth/_MPDFK) - ($this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_right'] + $this->blk[$this->blklvl]['border_right']['w'] + $fpaddingL + $fpaddingR );
4813
  } // *TABLES*
4814
  $objattr = $this->inlineObject($objattr['type'],$this->lMargin + $fpaddingL + ($contentWidth/_MPDFK),($this->y + $h_corr), $objattr, $this->lMargin,($contentWidth/_MPDFK),$maximumW,$lineHeight,true,$is_table);
4815
 
@@ -4823,7 +4822,7 @@ function WriteFlowingBlock( $s)
4823
  }
4824
 
4825
  $lbw = $rbw = 0; // Border widths
4826
- if (!empty($this->spanborddet)) {
4827
  if (isset($this->spanborddet['L'])) $lbw = $this->spanborddet['L']['w'];
4828
  if (isset($this->spanborddet['R'])) $rbw = $this->spanborddet['R']['w'];
4829
  }
@@ -4835,7 +4834,7 @@ function WriteFlowingBlock( $s)
4835
  $tmp = mb_strlen( $s, $this->mb_enc );
4836
  }
4837
 
4838
- $orphs = 0;
4839
  $check = 0;
4840
 
4841
  // for every character in the string
@@ -4847,7 +4846,7 @@ function WriteFlowingBlock( $s)
4847
  // Soft Hyphens chr(173)
4848
  $cw = ($this->GetCharWidthCore($c) * _MPDFK);
4849
  if ($this->kerning && $this->useKerning && $i > 0) {
4850
- if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$c])) {
4851
  $cw += ($this->CurrentFont['kerninfo'][$s[($i-1)]][$c] * $this->FontSizePt / 1000 );
4852
  }
4853
  }
@@ -4859,7 +4858,7 @@ function WriteFlowingBlock( $s)
4859
  $lastc = mb_substr($s,($i-1),1,$this->mb_enc );
4860
  $ulastc = $this->UTF8StringToArray($lastc, false);
4861
  $uc = $this->UTF8StringToArray($c, false);
4862
- if (isset($this->CurrentFont['kerninfo'][$ulastc[0]][$uc[0]])) {
4863
  $cw += ($this->CurrentFont['kerninfo'][$ulastc[0]][$uc[0]] * $this->FontSizePt / 1000 );
4864
  }
4865
  }
@@ -4897,18 +4896,18 @@ function WriteFlowingBlock( $s)
4897
  else { $orphs = 0; }
4898
 
4899
  // ADDED for Paragraph_indent
4900
- $WidthCorrection = 0;
4901
- if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align != 'C')) {
4902
- $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4903
- $WidthCorrection = ($ti*_MPDFK);
4904
- }
4905
 
4906
  // Added mPDF 3.0 Float DIV
4907
  $fpaddingR = 0;
4908
  $fpaddingL = 0;
4909
 
4910
  $usey = $this->y + 0.002;
4911
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4912
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4913
  }
4914
 
@@ -4927,7 +4926,7 @@ function WriteFlowingBlock( $s)
4927
  $savedObj = array();
4928
 
4929
  // cut off and save any partial words at the end of the string
4930
- $words = explode( ' ', $currContent );
4931
  ///////////////////
4932
  // HYPHENATION
4933
  $currWord = $words[count($words)-1] ;
@@ -4940,7 +4939,7 @@ function WriteFlowingBlock( $s)
4940
 
4941
  // mPDF 5.5.10
4942
  $lastchar = mb_substr($words[0],mb_strlen($words[0], $this->mb_enc)-1, 1, $this->mb_enc);
4943
- $lastContent = $words[0];
4944
  $savedFont = $this->saveFont();
4945
  // replace the current content with the cropped version
4946
  $currContent = rtrim( $lastContent );
@@ -4973,41 +4972,41 @@ function WriteFlowingBlock( $s)
4973
  }
4974
 
4975
  // Set Current lineheight (correction factor)
4976
- $lhfixed = false;
4977
  if ($is_list) {
4978
- if (preg_match('/([0-9.,]+)mm/',$this->list_lineheight[$this->listlvl][$this->listOcc],$am)) {
4979
- $lhfixed = true;
4980
  $def_fontsize = $this->InlineProperties['LISTITEM'][$this->listlvl][$this->listOcc][$this->listnum]['size'];
4981
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4982
  }
4983
- else {
4984
- $this->lineheight_correction = $this->list_lineheight[$this->listlvl][$this->listOcc];
4985
  }
4986
  }
4987
  else
4988
  if ($is_table) {
4989
- if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight,$am)) {
4990
- $lhfixed = true;
4991
  $def_fontsize = $this->FontSize; // needs to be default font-size for block ****
4992
- $this->lineheight_correction = $lineHeight / $def_fontsize ;
4993
  }
4994
- else {
4995
- $this->lineheight_correction = $this->table_lineheight;
4996
  }
4997
  }
4998
  else
4999
  if (isset($this->blk[$this->blklvl]['line_height']) && $this->blk[$this->blklvl]['line_height']) {
5000
- if (preg_match('/([0-9.,]+)mm/',$this->blk[$this->blklvl]['line_height'],$am)) {
5001
- $lhfixed = true;
5002
  $def_fontsize = $this->blk[$this->blklvl]['InlineProperties']['size']; // needs to be default font-size for block ****
5003
  $this->lineheight_correction = $am[1] / $def_fontsize ;
5004
  }
5005
- else {
5006
- $this->lineheight_correction = $this->blk[$this->blklvl]['line_height'];
5007
  }
5008
- }
5009
  else {
5010
- $this->lineheight_correction = $this->normalLineheight;
5011
  }
5012
  // update $contentWidth and $cutoffWidth since they changed with cropping
5013
  // Also correct lineheight to maximum fontsize (not for tables)
@@ -5022,24 +5021,24 @@ function WriteFlowingBlock( $s)
5022
  foreach ( $content as $k => $chunk )
5023
  {
5024
  $this->restoreFont( $font[ $k ]);
5025
- if (!isset($this->objectbuffer[$k])) {
5026
  if (!$this->usingCoreFont) {
5027
- $content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk );
5028
  }
5029
  // Soft Hyphens chr(173)
5030
  else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
5031
  $content[$k] = $chunk = str_replace(chr(173),'',$chunk );
5032
  }
5033
- $contentWidth += $this->GetStringWidth( $chunk ) * _MPDFK;
5034
- if (!empty($this->spanborddet)) {
5035
- if (strpos($contentB[$k],'L')!==false) $contentWidth += $this->spanborddet['L']['w'] * _MPDFK;
5036
- if (strpos($contentB[$k],'R')!==false) $contentWidth += $this->spanborddet['R']['w'] * _MPDFK;
5037
  }
5038
  if (!$lhfixed) { $maxlineHeight = max($maxlineHeight,$this->FontSize * $this->lineheight_correction ); }
5039
- if ($lhfixed && ($this->FontSize > $def_fontsize || ($this->FontSize > ($lineHeight * $this->lineheight_correction) && $is_list))) {
5040
- $this->forceExactLineheight = false;
5041
  }
5042
- $maxfontsize = max($maxfontsize,$this->FontSize);
5043
  }
5044
  }
5045
 
@@ -5062,12 +5061,12 @@ function WriteFlowingBlock( $s)
5062
 
5063
  $af = 0; // Above font
5064
  $bf = 0; // Below font
5065
- $mta = 0; // Maximum top-aligned
5066
- $mba = 0; // Maximum bottom-aligned
5067
 
5068
  foreach ( $content as $k => $chunk ) {
5069
- if (isset($this->objectbuffer[$k]) && $this->objectbuffer[$k]) {
5070
- $contentWidth += $this->objectbuffer[$k]['OUTER-WIDTH'] * _MPDFK;
5071
  $oh = $this->objectbuffer[$k]['OUTER-HEIGHT'];
5072
  $va = $this->objectbuffer[$k]['vertical-align']; // = $objattr['vertical-align'] = set as M,T,B,S
5073
  if ($lhfixed && $oh > $def_fontsize) { $this->forceExactLineheight = false; }
@@ -5075,20 +5074,20 @@ function WriteFlowingBlock( $s)
5075
  if ($va == 'BS') { // (BASELINE default)
5076
  $af = max($af, ($oh - ($maxfontsize * (0.5 + $this->baselineC))));
5077
  }
5078
- else if ($va == 'M') {
5079
  $af = max($af, ($oh - $maxfontsize)/2);
5080
  $bf = max($bf, ($oh - $maxfontsize)/2);
5081
  }
5082
- else if ($va == 'TT') {
5083
  $bf = max($bf, ($oh - $maxfontsize));
5084
  }
5085
- else if ($va == 'TB') {
5086
  $af = max($af, ($oh - $maxfontsize));
5087
  }
5088
- else if ($va == 'T') {
5089
  $mta = max($mta, $oh);
5090
  }
5091
- else if ($va == 'B') {
5092
  $mba = max($mba, $oh);
5093
  }
5094
  }
@@ -5098,21 +5097,21 @@ function WriteFlowingBlock( $s)
5098
  }
5099
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
5100
 
5101
- if ($mta > $maxlineHeight) {
5102
  $bf += ($mta - $maxlineHeight);
5103
  $maxlineHeight = $mta;
5104
  }
5105
- if ($mba > $maxlineHeight) {
5106
  $af += ($mba - $maxlineHeight);
5107
  $maxlineHeight = $mba;
5108
  }
5109
 
5110
 
5111
- $lineHeight = $maxlineHeight;
5112
  $cutoffWidth = $contentWidth;
5113
  // If NOT images, and maxfontsize NOT > lineHeight - this value determines text baseline positioning
5114
- if ($lhfixed && $af==0 && $bf==0 && $maxfontsize<=($def_fontsize * $this->lineheight_correction * 0.8 )) {
5115
- $this->linemaxfontsize = $def_fontsize;
5116
  }
5117
  else { $this->linemaxfontsize = $maxfontsize; }
5118
 
@@ -5124,7 +5123,7 @@ function WriteFlowingBlock( $s)
5124
  $content[$k] = str_replace(chr(160),chr(32),$chunk );
5125
  }
5126
  else {
5127
- $content[$k] = str_replace(chr(194).chr(160),chr(32),$chunk );
5128
  if ($checkCursive) {
5129
  }
5130
  }
@@ -5142,8 +5141,8 @@ function WriteFlowingBlock( $s)
5142
  // WORD SPACING
5143
  foreach ( $content as $k => $chunk ) {
5144
  if (!isset($this->objectbuffer[$k]) || (isset($this->objectbuffer[$k]) && !$this->objectbuffer[$k])) {
5145
- $nb_carac += mb_strlen( $chunk, $this->mb_enc ) ;
5146
- $nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc ) ;
5147
  }
5148
  }
5149
  list($jcharspacing,$jws) = $this->GetJspacing($nb_carac,$nb_spaces,($maxWidth-$lastitalic-$cutoffWidth-$WidthCorrection-(($this->cMarginL+$this->cMarginR)*_MPDFK)-($paddingL+$paddingR +(($fpaddingL + $fpaddingR) * _MPDFK) )),$inclCursive);
@@ -5160,16 +5159,16 @@ function WriteFlowingBlock( $s)
5160
  $b = ''; //do not use borders
5161
  // Get PAGEBREAK TO TEST for height including the top border/padding
5162
  $check_h = max($this->divheight,$lineHeight);
5163
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($this->blklvl > 0) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5164
  $check_h += ($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['border_top']['w']);
5165
  }
5166
 
5167
- if ($this->ColActive && $check_h > ($this->PageBreakTrigger - $this->y0)) {
5168
  $this->SetCol($this->NbCol-1);
5169
  }
5170
 
5171
  // PAGEBREAK
5172
- // 'If' below used in order to fix "first-line of other page with justify on" bug
5173
  if(!$is_table && ($this->y+$check_h) > $this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) {
5174
  $bak_x=$this->x;//Current X position
5175
 
@@ -5197,19 +5196,19 @@ function WriteFlowingBlock( $s)
5197
 
5198
 
5199
  // TOP MARGIN
5200
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($this->blk[$this->blklvl]['margin_top']) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5201
- $this->DivLn($this->blk[$this->blklvl]['margin_top'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
5202
  }
5203
 
5204
 
5205
  // Update y0 for top of block (used to paint border)
5206
- if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5207
  $this->blk[$this->blklvl]['y0'] = $this->y;
5208
  $this->blk[$this->blklvl]['startpage'] = $this->page;
5209
  }
5210
 
5211
  // TOP PADDING and BORDER spacing/fill
5212
- if (($newblock) && ($blockstate==1 || $blockstate==3) && (($this->blk[$this->blklvl]['padding_top']) || ($this->blk[$this->blklvl]['border_top'])) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5213
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
5214
  $this->DivLn($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'],-3,true,false,1);
5215
  }
@@ -5226,9 +5225,9 @@ function WriteFlowingBlock( $s)
5226
  else if ($align == 'C') { $this->x += ($empty / 2); }
5227
 
5228
  // Paragraph INDENT
5229
- if (isset($this->blk[$this->blklvl]['text_indent']) && ($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 1) && (!$is_table) && ($blockdir !='rtl') && ($align !='C')) {
5230
- $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
5231
- $this->x += $ti;
5232
  }
5233
 
5234
  // DIRECTIONALITY RTL
@@ -5242,28 +5241,28 @@ function WriteFlowingBlock( $s)
5242
 
5243
  $va = 'M'; // default for text
5244
  if (isset($this->objectbuffer[$dirk]) && $this->objectbuffer[$dirk]) {
5245
- $xadj = $this->x - $this->objectbuffer[$dirk]['OUTER-X'] ;
5246
  $this->objectbuffer[$dirk]['OUTER-X'] += $xadj;
5247
  $this->objectbuffer[$dirk]['BORDER-X'] += $xadj;
5248
  $this->objectbuffer[$dirk]['INNER-X'] += $xadj;
5249
  $va = $this->objectbuffer[$dirk]['vertical-align'];
5250
  $yadj = $this->y - $this->objectbuffer[$dirk]['OUTER-Y'];
5251
- if ($va == 'BS') {
5252
  $yadj += $af + ($this->linemaxfontsize * (0.5 + $this->baselineC)) - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5253
  }
5254
- else if ($va == 'M' || $va == '') {
5255
  $yadj += $af + ($this->linemaxfontsize /2) - ($this->objectbuffer[$dirk]['OUTER-HEIGHT']/2);
5256
  }
5257
- else if ($va == 'TB') {
5258
  $yadj += $af + $this->linemaxfontsize - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5259
  }
5260
- else if ($va == 'TT') {
5261
  $yadj += $af;
5262
  }
5263
- else if ($va == 'B') {
5264
  $yadj += $af + $this->linemaxfontsize + $bf - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5265
  }
5266
- else if ($va == 'T') {
5267
  $yadj += 0;
5268
  }
5269
  $this->objectbuffer[$dirk]['OUTER-Y'] += $yadj;
@@ -5281,15 +5280,15 @@ function WriteFlowingBlock( $s)
5281
  $this->minwSpacing = 0;
5282
 
5283
  // *********** SPAN BACKGROUND COLOR ***************** //
5284
- if ($this->spanbgcolor) {
5285
  $cor = $this->spanbgcolorarray;
5286
  $this->SetFColor($cor);
5287
  $save_fill = $fill; $spanfill = 1; $fill = 1;
5288
  }
5289
- if (!empty($this->spanborddet)) {
5290
  if (strpos($contentB[$k],'L')!==false) $this->x += $this->spanborddet['L']['w'];
5291
- if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0;
5292
- if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0;
5293
  }
5294
 
5295
  // WORD SPACING
@@ -5300,23 +5299,23 @@ function WriteFlowingBlock( $s)
5300
 
5301
  if ($stringWidth==0) { $stringWidth = 0.000001; }
5302
  if ($k == $arraysize-1) {
5303
- $stringWidth -= ( $this->charspacing / _MPDFK );
5304
  $this->Cell( $stringWidth, $lineHeight, $chunk, '', 1, '', $fill, $this->HREF, $currentx,0,0,'M', $fill, $af, $bf, true ); //mono-style line or last part (skips line)
5305
  }
5306
- else $this->Cell( $stringWidth, $lineHeight, $chunk, '', 0, '', $fill, $this->HREF, 0, 0,0,'M', $fill, $af, $bf, true );//first or middle part
5307
 
5308
- if (!empty($this->spanborddet)) {
5309
  if (strpos($contentB[$k],'R')!==false && $k != $arraysize-1) $this->x += $this->spanborddet['R']['w'];
5310
  }
5311
  // *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
5312
- if (isset($spanfill) && $spanfill) {
5313
- $fill = $save_fill; $spanfill = 0;
5314
  if ($fill) { $this->SetFColor($bcor); }
5315
  }
5316
  }
5317
- if (!$is_table) {
5318
- $this->maxPosR = max($this->maxPosR , ($this->w - $this->rMargin - $this->blk[$this->blklvl]['outer_right_margin']));
5319
- $this->maxPosL = min($this->maxPosL , ($this->lMargin + $this->blk[$this->blklvl]['outer_left_margin']));
5320
  }
5321
 
5322
  // move on to the next line, reset variables, tack on saved content and current char
@@ -5330,8 +5329,8 @@ function WriteFlowingBlock( $s)
5330
  $this->ResetSpacing();
5331
 
5332
  $bull = $this->bulletarray;
5333
- if (isset($bull['level']) && isset($bull['occur']) && isset($this->InlineProperties['LIST'][$bull['level']][$bull['occur']])) {
5334
- $this->restoreInlineProperties($this->InlineProperties['LIST'][$bull['level']][$bull['occur']]);
5335
  }
5336
  if (isset($bull['level']) && isset($bull['occur']) && isset($bull['num']) && isset($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) && $this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) { $this->restoreInlineProperties($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]); }
5337
  if (isset($bull['font']) && $bull['font'] == 'czapfdingbats') {
@@ -5363,7 +5362,7 @@ function WriteFlowingBlock( $s)
5363
 
5364
  $this->restoreFont( $savedFont );
5365
  $lbw = $rbw = 0; // Border widths
5366
- if (!empty($this->spanborddet)) {
5367
  $lbw = $this->spanborddet['L']['w'];
5368
  $rbw = $this->spanborddet['R']['w'];
5369
  }
@@ -5445,7 +5444,7 @@ function WordWrap(&$text, $maxwidth, $forcewrap = 0) {
5445
  }
5446
  $word = mb_substr($word,$i,mb_strlen($word, $this->mb_enc )-$i,$this->mb_enc );
5447
  $wordwidth = $this->GetStringWidth($word);
5448
- $width = $maxwidth;
5449
  break;
5450
  }
5451
  }
@@ -5468,53 +5467,53 @@ function WordWrap(&$text, $maxwidth, $forcewrap = 0) {
5468
  }
5469
  $text = rtrim($text);
5470
 
5471
- //Return -(wordsize) if word is bigger than maxwidth
5472
 
5473
  // ADDED
5474
  if ($forcewrap) { return $count; }
5475
  if (($toonarrow) && ($this->table_error_report)) {
5476
- $this->Error("Word is too long to fit in table - ".$this->table_error_report_param);
5477
  }
5478
  if ($toonarrow) return -$biggestword;
5479
  else return $count;
5480
  }
5481
 
5482
 
5483
- function _SetTextRendering($mode) {
5484
- if (!(($mode == 0) || ($mode == 1) || ($mode == 2)))
5485
- $this->Error("Text rendering mode should be 0, 1 or 2 (value : $mode)");
5486
- $tr = ($mode.' Tr');
5487
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5488
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5489
 
5490
- }
5491
 
5492
  function SetTextOutline($width, $col=0) {
5493
  if ($width == false) //Now resets all values
5494
- {
5495
  $this->outline_on = false;
5496
- $this->SetLineWidth(0.2);
5497
  $this->SetDColor($this->ConvertColor(0));
5498
- $this->_SetTextRendering(0);
5499
- $tr = ('0 Tr');
5500
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5501
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5502
  }
5503
  else
5504
- {
5505
- $this->SetLineWidth($width);
5506
  $this->SetDColor($col);
5507
- $tr = ('2 Tr');
5508
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5509
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5510
- }
5511
  }
5512
 
5513
  function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=true, $watermark=false, $shownoimg=true, $allowvector=true) {
5514
  if(!file_exists($file))
5515
  {
5516
  return false;
5517
- }
5518
 
5519
  $orig_srcpath = $file;
5520
  $this->GetFullPath($file);
@@ -5522,8 +5521,8 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t
5522
  $info=$this->_getImage($file, true, $allowvector, $orig_srcpath );
5523
  if(!$info && $paint) {
5524
  $info = $this->_getImage($this->noImageFile);
5525
- if ($info) {
5526
- $file = $this->noImageFile;
5527
  $w = ($info['w'] * (25.4/$this->dpi)); // 14 x 16px
5528
  $h = ($info['h'] * (25.4/$this->dpi)); // 14 x 16px
5529
  }
@@ -5531,7 +5530,7 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t
5531
  if(!$info) return false;
5532
  //Automatic width and height calculation if needed
5533
  if($w==0 and $h==0) {
5534
- if ($info['type']=='svg') {
5535
  // returned SVG units are pts
5536
  // divide by k to get user units (mm)
5537
  $w = abs($info['w'])/_MPDFK;
@@ -5543,8 +5542,8 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t
5543
  $h=($info['h']/_MPDFK) * (72/$this->img_dpi);
5544
  }
5545
  }
5546
- if($w==0) $w=abs($h*$info['w']/$info['h']);
5547
- if($h==0) $h=abs($w*$info['h']/$info['w']);
5548
 
5549
 
5550
  if ($constrain) {
@@ -5581,12 +5580,12 @@ function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=t
5581
  }
5582
  } // end of IF constrain
5583
 
5584
- if ($info['type']=='svg') {
5585
  $sx = $w*_MPDFK / $info['w'];
5586
  $sy = -$h*_MPDFK / $info['h'];
5587
  $outstring = sprintf('q %.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, $sy, $x*_MPDFK-$sx*$info['x'], (($this->h-$y)*_MPDFK)-$sy*$info['y'], $info['i']);
5588
  }
5589
- else {
5590
  $outstring = sprintf("q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q",$w*_MPDFK,$h*_MPDFK,$x*_MPDFK,($this->h-($y+$h))*_MPDFK,$info['i']);
5591
  }
5592
 
@@ -5636,7 +5635,7 @@ function inlineObject($type,$x,$y,$objattr,$Lmargin,$widthUsed,$maxWidth,$lineHe
5636
 
5637
  // NB $x is only used when paint=true
5638
  // Lmargin not used
5639
- $w = 0;
5640
  if (isset($objattr['width'])) { $w = $objattr['width']/$k; }
5641
  $h = 0;
5642
  if (isset($objattr['height'])) { $h = abs($objattr['height']/$k); }
@@ -5724,7 +5723,7 @@ function inlineObject($type,$x,$y,$objattr,$Lmargin,$widthUsed,$maxWidth,$lineHe
5724
  $objattr['ID'] = $info['i'];
5725
  }
5726
 
5727
- if ($type == 'input' && $objattr['subtype'] == 'IMAGE') {
5728
  $img_w = $w - $extraWidth ;
5729
  $img_h = $h - $extraHeight ;
5730
  $objattr['BORDER-WIDTH'] = $img_w + (($objattr['border_left']['w']/$k + $objattr['border_right']['w']/$k)/2) ;
@@ -5763,14 +5762,14 @@ function inlineObject($type,$x,$y,$objattr,$Lmargin,$widthUsed,$maxWidth,$lineHe
5763
  }
5764
 
5765
  if ($type == 'hr') {
5766
- if ($is_table) {
5767
- $objattr['INNER-WIDTH'] = $maxWidth * $objattr['W-PERCENT']/100;
5768
- $objattr['width'] = $objattr['INNER-WIDTH'];
5769
  $w = $maxWidth;
5770
  }
5771
- else {
5772
  if ($w>$maxWidth) { $w = $maxWidth; }
5773
- $objattr['INNER-WIDTH'] = $w;
5774
  $w = $maxWidth;
5775
  }
5776
  }
@@ -5859,7 +5858,7 @@ function DivLn($h,$level=-3,$move_y=true,$collapsible=false,$state=0) {
5859
  // otherwise, now uses PaintDivBB()
5860
  if (!$this->ColActive && !$this->keep_block_together && !$this->kwt) {
5861
  if ($move_y && !$this->ColActive) { $this->y += $h; }
5862
- return;
5863
  }
5864
 
5865
  if ($level == -3) { $level = $this->blklvl; }
@@ -5889,7 +5888,7 @@ function DivLn($h,$level=-3,$move_y=true,$collapsible=false,$state=0) {
5889
  $last_fc = $this->FillColor;
5890
  }
5891
  // Reset current block fill
5892
- if (isset($this->blk[$this->blklvl]['bgcolorarray'])) {
5893
  $bcor = $this->blk[$this->blklvl]['bgcolorarray'];
5894
  $this->SetFColor($bcor);
5895
  }
@@ -5938,13 +5937,13 @@ function Output($name='',$dest='')
5938
  if($this->state < 3) $this->Close();
5939
  // fn. error_get_last is only in PHP>=5.2
5940
  if ($this->debug && function_exists('error_get_last') && error_get_last()) {
5941
- $e = error_get_last();
5942
  if (($e['type'] < 2048 && $e['type'] != 8) || (intval($e['type']) & intval(ini_get("error_reporting")))) {
5943
- echo "<p>Error message detected - PDF file generation aborted.</p>";
5944
  echo $e['message'].'<br />';
5945
  echo 'File: '.$e['file'].'<br />';
5946
  echo 'Line: '.$e['line'].'<br />';
5947
- exit;
5948
  }
5949
  }
5950
 
@@ -6004,9 +6003,9 @@ function Output($name='',$dest='')
6004
  header('Content-Length: '.strlen($this->buffer));
6005
  }
6006
  header('Content-disposition: inline; filename="'.$name.'"');
6007
- header('Cache-Control: public, must-revalidate, max-age=0');
6008
  header('Pragma: public');
6009
- header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
6010
  header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
6011
  }
6012
  echo $this->buffer;
@@ -6051,12 +6050,12 @@ function Output($name='',$dest='')
6051
  // Delete any files in tmp/ directory that are >1 hrs old
6052
  $interval = 3600;
6053
  if ($handle = opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) {
6054
- while (false !== ($file = readdir($handle))) {
6055
  if (!is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { // mPDF 5.4.19
6056
- unlink(_MPDF_TEMP_PATH.$file);
6057
  }
6058
  }
6059
- closedir($handle);
6060
  }
6061
  //==============================================================================================================
6062
 
@@ -6118,7 +6117,7 @@ function _putpages()
6118
  // Select unused fonts (usually default font)
6119
  $unused = array();
6120
  foreach($this->fonts as $fk=>$font) {
6121
- if (!$font['used'] && ($font['type']=='TTF')) {
6122
  $unused[] = $fk;
6123
  }
6124
  }
@@ -6128,13 +6127,13 @@ function _putpages()
6128
  {
6129
  $thispage = $this->pages[$n];
6130
  unset($this->pages[$n]);
6131
- if(isset($this->OrientationChanges[$n])) {
6132
  $hPt=$this->pageDim[$n]['w']*_MPDFK;
6133
  $wPt=$this->pageDim[$n]['h']*_MPDFK;
6134
  $owidthPt_LR = $this->pageDim[$n]['outer_width_TB']*_MPDFK;
6135
  $owidthPt_TB = $this->pageDim[$n]['outer_width_LR']*_MPDFK;
6136
  }
6137
- else {
6138
  $wPt=$this->pageDim[$n]['w']*_MPDFK;
6139
  $hPt=$this->pageDim[$n]['h']*_MPDFK;
6140
  $owidthPt_LR = $this->pageDim[$n]['outer_width_LR']*_MPDFK;
@@ -6144,11 +6143,11 @@ function _putpages()
6144
  foreach($unused as $fk) {
6145
  if ($this->fonts[$fk]['sip'] || $this->fonts[$fk]['smp']) {
6146
  foreach($this->fonts[$fk]['subsetfontids'] AS $k => $fid) {
6147
- $thispage = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$thispage);
6148
  }
6149
  }
6150
- else {
6151
- $thispage = preg_replace('/\s\/F'.$this->fonts[$fk]['i'].' \d[\d.]* Tf\s/is',' ',$thispage);
6152
  }
6153
  }
6154
  //Replace number of pages
@@ -6168,7 +6167,7 @@ function _putpages()
6168
  $x2 = $this->GetStringWidth($nb);
6169
  $xadj = $x1 - $x2;
6170
  if ($pos=='C') { $xadj /= 2; }
6171
- $rep = sprintf(' q 1 0 0 1 %.3F 0 cm ', $xadj*_MPDFK);
6172
  $thispage = str_replace($m[0][$hi], $rep, $thispage);
6173
  }
6174
  }
@@ -6179,7 +6178,7 @@ function _putpages()
6179
  $r = '';
6180
  $nstr = "$nb";
6181
  for($i=0;$i<strlen($nstr);$i++) {
6182
- $r .= sprintf("%02s", strtoupper(dechex(intval($nstr[$i])+48)));
6183
  }
6184
  $thispage=str_replace($this->aliasNbPgHex,$r,$thispage);
6185
 
@@ -6187,9 +6186,9 @@ function _putpages()
6187
  //Replace number of pages in group
6188
  if(!empty($this->aliasNbPgGp)) {
6189
  if (!$this->onlyCoreFonts) { $s1 = $this->UTF8ToUTF16BE($this->aliasNbPgGp, false); }
6190
- $s2 = $this->aliasNbPgGp;
6191
  $nbt = $this->docPageNumTotal($n);
6192
- if (!$this->onlyCoreFonts) { $r1 = $this->UTF8ToUTF16BE($nbt, false); }
6193
  $r2 = $nbt;
6194
  if (preg_match_all('/{mpdfheadernbpggp (C|R) ff=(\S*) fs=(\S*) fz=(.*?)}/',$thispage,$m)) {
6195
  for($hi=0;$hi<count($m[0]);$hi++) {
@@ -6202,7 +6201,7 @@ function _putpages()
6202
  $x2 = $this->GetStringWidth($nbt);
6203
  $xadj = $x1 - $x2;
6204
  if ($pos=='C') { $xadj /= 2; }
6205
- $rep = sprintf(' q 1 0 0 1 %.3F 0 cm ', $xadj*_MPDFK);
6206
  $thispage = str_replace($m[0][$hi], $rep, $thispage);
6207
  }
6208
  }
@@ -6213,7 +6212,7 @@ function _putpages()
6213
  $r = '';
6214
  $nstr = "$nbt";
6215
  for($i=0;$i<strlen($nstr);$i++) {
6216
- $r .= sprintf("%02s", strtoupper(dechex(intval($nstr[$i])+48)));
6217
  }
6218
  $thispage=str_replace($this->aliasNbPgGpHex,$r,$thispage);
6219
 
@@ -6238,7 +6237,7 @@ function _putpages()
6238
  $y1 = $wPt-$owidthPt_LR+$bleedMargin;
6239
  $this->_out(sprintf('/BleedBox [%.3F %.3F %.3F %.3F]', $x0, $y0, $x1, $y1));
6240
  }
6241
- $this->_out(sprintf('/TrimBox [%.3F %.3F %.3F %.3F]', $owidthPt_TB, $owidthPt_LR, ($hPt-$owidthPt_TB), ($wPt-$owidthPt_LR)));
6242
  if (isset($this->OrientationChanges[$n]) && $this->displayDefaultOrientation) {
6243
  if ($this->DefOrientation=='P') { $this->_out('/Rotate 270'); }
6244
  else { $this->_out('/Rotate 90'); }
@@ -6255,17 +6254,17 @@ function _putpages()
6255
  $y1 = $hPt-$owidthPt_TB+$bleedMargin;
6256
  $this->_out(sprintf('/BleedBox [%.3F %.3F %.3F %.3F]', $x0, $y0, $x1, $y1));
6257
  }
6258
- $this->_out(sprintf('/TrimBox [%.3F %.3F %.3F %.3F]', $owidthPt_LR, $owidthPt_TB, ($wPt-$owidthPt_LR), ($hPt-$owidthPt_TB)));
6259
  }
6260
  $this->_out('/Resources 2 0 R');
6261
 
6262
  // Important to keep in RGB colorSpace when using transparency
6263
- if (!$this->PDFA && !$this->PDFX) {
6264
  if ($this->restrictColorSpace == 3)
6265
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceCMYK >> ');
6266
  else if ($this->restrictColorSpace == 1)
6267
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceGray >> ');
6268
- else
6269
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceRGB >> ');
6270
  }
6271
 
@@ -6274,9 +6273,9 @@ function _putpages()
6274
 
6275
  if ($annotsnum || $formsnum) {
6276
  $s = '/Annots [ ';
6277
- for($i=0;$i<$annotsnum;$i++) {
6278
  $s .= ($annotid + $i) . ' 0 R ';
6279
- }
6280
  $annotid += $annotsnum;
6281
  $s .= '] ';
6282
  $this->_out($s);
@@ -6376,8 +6375,8 @@ function _putfonts() {
6376
  $used = true;
6377
  $asSubset = false;
6378
  foreach($this->fonts AS $k=>$f) {
6379
- if ($f['fontkey'] == $fontkey && $f['type']=='TTF') {
6380
- $used = $f['used'];
6381
  if ($used) {
6382
  $nChars = (ord($f['cw'][0]) << 8) + ord($f['cw'][1]);
6383
  $usage = intval(count($f['subset'])*100 / $nChars);
@@ -6482,7 +6481,7 @@ function _putfonts() {
6482
  }
6483
  $this->_out('>>');
6484
  $this->_out('endobj');
6485
- }
6486
  // TrueType embedded SUBSETS for SIP (CJK extB containing Supplementary Ideographic Plane 2)
6487
  // Or Unicode Plane 1 - Supplementary Multilingual Plane
6488
  else if ($type=='TTF' && ($font['sip'] || $font['smp'])) {
@@ -6502,7 +6501,7 @@ function _putfonts() {
6502
  $widthstring = '';
6503
  $toUnistring = '';
6504
  foreach($font['subsets'][$sfid] AS $cp=>$u) {
6505
- $w = $this->_getCharWidth($font['cw'], $u);
6506
  if ($w !== false) {
6507
  $widthstring .= $w.' ';
6508
  }
@@ -6578,7 +6577,7 @@ function _putfonts() {
6578
  $this->_putstream($toUni);
6579
  $this->_out('endobj');
6580
 
6581
- //Font file
6582
  $this->_newobj();
6583
  $this->_out('<</Length '.strlen($fontstream));
6584
  $this->_out('/Filter /FlateDecode');
@@ -6588,7 +6587,7 @@ function _putfonts() {
6588
  $this->_out('endobj');
6589
  } // foreach subset
6590
  unset($ttf);
6591
- }
6592
  // TrueType embedded SUBSETS or FULL
6593
  else if ($type=='TTF') {
6594
  $this->fonts[$k]['n']=$this->n+1;
@@ -6612,7 +6611,7 @@ function _putfonts() {
6612
  $this->_out('<</Type /Font');
6613
  $this->_out('/Subtype /Type0');
6614
  $this->_out('/BaseFont /'.$fontname.'');
6615
- $this->_out('/Encoding /Identity-H');
6616
  $this->_out('/DescendantFonts ['.($this->n + 1).' 0 R]');
6617
  $this->_out('/ToUnicode '.($this->n + 2).' 0 R');
6618
  $this->_out('>>');
@@ -6624,10 +6623,10 @@ function _putfonts() {
6624
  $this->_out('<</Type /Font');
6625
  $this->_out('/Subtype /CIDFontType2');
6626
  $this->_out('/BaseFont /'.$fontname.'');
6627
- $this->_out('/CIDSystemInfo '.($this->n + 2).' 0 R');
6628
  $this->_out('/FontDescriptor '.($this->n + 3).' 0 R');
6629
  if (isset($font['desc']['MissingWidth'])){
6630
- $this->_out('/DW '.$font['desc']['MissingWidth'].'');
6631
  }
6632
 
6633
  if (!$asSubset && file_exists(_MPDF_TTFONTDATAPATH.$font['fontkey'].'.cw')) {
@@ -6672,7 +6671,7 @@ function _putfonts() {
6672
 
6673
  // CIDSystemInfo dictionary
6674
  $this->_newobj();
6675
- $this->_out('<</Registry (Adobe)');
6676
  $this->_out('/Ordering (UCS)');
6677
  $this->_out('/Supplement 0');
6678
  $this->_out('>>');
@@ -6743,7 +6742,7 @@ function _putfonts() {
6743
  $this->_putstream($cidtogidmap);
6744
  $this->_out('endobj');
6745
 
6746
- //Font file
6747
  if ($asSubset ) {
6748
  $this->_newobj();
6749
  $this->_out('<</Length '.strlen($fontstream));
@@ -6754,7 +6753,7 @@ function _putfonts() {
6754
  $this->_out('endobj');
6755
  unset($ttf);
6756
  }
6757
- }
6758
  else { $this->Error('Unsupported font type: '.$type.' ('.$name.')'); }
6759
  }
6760
  }
@@ -7153,7 +7152,7 @@ function _putoutputintent() {
7153
  $this->_newobj();
7154
  if ($this->ICCProfile)
7155
  $s = file_get_contents(_MPDF_PATH.'iccprofiles/'.$this->ICCProfile.'.icc');
7156
- else
7157
  $s = file_get_contents(_MPDF_PATH.'iccprofiles/sRGB_IEC61966-2-1.icc');
7158
  if ($this->compress) { $s = gzcompress($s); }
7159
  $this->_out('<<');
@@ -7187,11 +7186,11 @@ function _putcatalog() {
7187
  if(is_int(strpos($this->DisplayPreferences,'FullScreen'))) $this->_out('/PageMode /FullScreen');
7188
 
7189
  // Metadata
7190
- if ($this->PDFA || $this->PDFX) {
7191
  $this->_out('/Metadata '.$this->MetadataRoot.' 0 R');
7192
  }
7193
  // OutputIntents
7194
- if ($this->PDFA || $this->PDFX || $this->ICCProfile) {
7195
  $this->_out('/OutputIntents ['.$this->OutputIntentRoot.' 0 R]');
7196
  }
7197
 
@@ -7208,7 +7207,7 @@ function _putcatalog() {
7208
  if(is_int(strpos($this->DisplayPreferences,'CenterWindow'))) $this->_out('/CenterWindow true');
7209
  if(is_int(strpos($this->DisplayPreferences,'FitWindow'))) $this->_out('/FitWindow true');
7210
  // /PrintScaling is PDF 1.6 spec.
7211
- if(is_int(strpos($this->DisplayPreferences,'NoPrintScaling')) && !$this->PDFA && !$this->PDFX)
7212
  $this->_out('/PrintScaling /None');
7213
  if($this->directionality == 'rtl') $this->_out('/Direction /R2L');
7214
  // /Duplex is PDF 1.7 spec.
@@ -7254,17 +7253,17 @@ function SetUserRights($enable=true, $annots="", $form="", $signature="") {
7254
  function _enddoc() {
7255
  // Remove references to unused fonts (usually default font)
7256
  foreach($this->fonts as $fk=>$font) {
7257
- if (!$font['used'] && ($font['type']=='TTF')) {
7258
  if ($font['sip'] || $font['smp']) {
7259
  foreach($font['subsetfontids'] AS $k => $fid) {
7260
- foreach($this->pages AS $pn=>$page) {
7261
- $this->pages[$pn] = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]);
7262
  }
7263
  }
7264
  }
7265
- else {
7266
- foreach($this->pages AS $pn=>$page) {
7267
- $this->pages[$pn] = preg_replace('/\s\/F'.$font['i'].' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]);
7268
  }
7269
  }
7270
  }
@@ -7272,7 +7271,7 @@ function _enddoc() {
7272
 
7273
  // mPDF 5.6.01 - LAYERS
7274
  if (count($this->layers)) {
7275
- foreach($this->pages AS $pn=>$page) {
7276
  preg_match_all('/\/OCZ-index \/ZI(\d+) BDC(.*?)(EMCZ)-index/is',$this->pages[$pn],$m1);
7277
  preg_match_all('/\/OCBZ-index \/ZI(\d+) BDC(.*?)(EMCBZ)-index/is',$this->pages[$pn],$m2);
7278
  preg_match_all('/\/OCGZ-index \/ZI(\d+) BDC(.*?)(EMCGZ)-index/is',$this->pages[$pn],$m3);
@@ -7287,14 +7286,14 @@ function _enddoc() {
7287
  if ($m[3][$i]=='EMCZ') $key +=2; // background first then gradient then normal
7288
  else if ($m[3][$i]=='EMCGZ') $key +=1;
7289
  $sortarr[$i] = $key;
7290
- }
7291
  asort($sortarr);
7292
  foreach($sortarr AS $i=>$k) {
7293
  $this->pages[$pn] = str_replace($m[0][$i],'',$this->pages[$pn] );
7294
  $this->pages[$pn] .= "\n".$m[0][$i]."\n";
7295
- }
7296
- $this->pages[$pn] = preg_replace('/\/OC[BG]{0,1}Z-index \/ZI(\d+) BDC/is','/OC /ZI\\1 BDC ',$this->pages[$pn]);
7297
- $this->pages[$pn] = preg_replace('/EMC[BG]{0,1}Z-index/is','EMC',$this->pages[$pn]);
7298
  }
7299
  }
7300
  }
@@ -7341,7 +7340,7 @@ function _enddoc() {
7341
  }
7342
 
7343
  function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='',$ohname='',$ehname='',$ofname='',$efname='',$ohvalue=0,$ehvalue=0,$ofvalue=0,$efvalue=0,$pagesel='',$newformat='') {
7344
- if (!($pagesel && $this->page==1 && (sprintf("%0.4f", $this->y)==sprintf("%0.4f", $this->tMargin)))) {
7345
  $this->page++;
7346
  $this->pages[$this->page]='';
7347
  }
@@ -7400,8 +7399,8 @@ function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf=''
7400
  $this->pageDim[$this->page]['w']=$this->w ;
7401
  $this->pageDim[$this->page]['h']=$this->h ;
7402
 
7403
- $this->pageDim[$this->page]['outer_width_LR'] = isset($this->page_box['outer_width_LR']) ? $this->page_box['outer_width_LR'] : 0;
7404
- $this->pageDim[$this->page]['outer_width_TB'] = isset($this->page_box['outer_width_TB']) ? $this->page_box['outer_width_TB'] : 0;
7405
  if (!isset($this->page_box['outer_width_LR']) && !isset($this->page_box['outer_width_TB'])) {
7406
  $this->pageDim[$this->page]['bleedMargin'] = 0;
7407
  }
@@ -7438,44 +7437,44 @@ function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf=''
7438
  $this->FontFamily='';
7439
 
7440
  // HEADERS AND FOOTERS
7441
- if ($ohvalue<0 || strtoupper($ohvalue)=='OFF') {
7442
- $this->HTMLHeader = '';
7443
- $this->headerDetails['odd'] = array();
7444
  }
7445
  else if ($ohname && $ohvalue>0) {
7446
- if (isset($this->pageheaders[$ohname])) { $this->headerDetails['odd'] = $this->pageheaders[$ohname]; }
7447
  else if ($ohname!='_default') { $this->headerDetails['odd'] = array(); }
7448
- $this->HTMLHeader = '';
7449
  }
7450
 
7451
- if ($ehvalue<0 || strtoupper($ehvalue)=='OFF') {
7452
- $this->HTMLHeaderE = '';
7453
- $this->headerDetails['even'] = array();
7454
  }
7455
  else if ($ehname && $ehvalue>0) {
7456
  if (isset($this->pageheaders[$ehname])) { $this->headerDetails['even'] = $this->pageheaders[$ehname]; }
7457
  else if ($ehname!='_default') { $this->headerDetails['even'] = array(); }
7458
- $this->HTMLHeaderE = '';
7459
  }
7460
 
7461
- if ($ofvalue<0 || strtoupper($ofvalue)=='OFF') {
7462
- $this->HTMLFooter = '';
7463
- $this->footerDetails['odd'] = array();
7464
  }
7465
  else if ($ofname && $ofvalue>0) {
7466
  if (isset($this->pagefooters[$ofname])) { $this->footerDetails['odd'] = $this->pagefooters[$ofname]; }
7467
  else if ($ofname!='_default') { $this->footerDetails['odd'] = array(); }
7468
- $this->HTMLFooter = '';
7469
  }
7470
 
7471
- if ($efvalue<0 || strtoupper($efvalue)=='OFF') {
7472
- $this->HTMLFooterE = '';
7473
- $this->footerDetails['even'] = array();
7474
  }
7475
  else if ($efname && $efvalue>0) {
7476
- if (isset($this->pagefooters[$efname])) { $this->footerDetails['even'] = $this->pagefooters[$efname]; }
7477
  else if ($efname!='_default') { $this->footerDetails['even'] = array(); }
7478
- $this->HTMLFooterE = '';
7479
  }
7480
 
7481
 
@@ -7495,10 +7494,10 @@ function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf=''
7495
  $this->y=$this->tMargin;
7496
  }
7497
 
7498
- /*
7499
- * Blue Liquid Designs Edit
7500
- * Add isset() to if statement as it throws errors
7501
- */
7502
  function _setAutoHeaderHeight(&$det, &$htmlh) {
7503
  if ($this->setAutoTopMargin=='pad') {
7504
  if (isset($htmlh['h']) && $htmlh['h']) { $h = $htmlh['h']; }
@@ -7515,9 +7514,9 @@ function _setAutoHeaderHeight(&$det, &$htmlh) {
7515
  }
7516
 
7517
 
7518
- /*
7519
- * Blue Liquid Designs Edit
7520
- * Add isset() to if statement as it throws errors
7521
  */
7522
  function _setAutoFooterHeight(&$det, &$htmlf) {
7523
  if ($this->setAutoBottomMargin=='pad') {
@@ -7577,7 +7576,7 @@ function _newobj($obj_id=false,$onlynewobj=false) {
7577
  function _dounderline($x,$y,$txt) {
7578
  // Now print line exactly where $y secifies - called from Text() and Cell() - adjust position there
7579
  // WORD SPACING
7580
- $w =($this->GetStringWidth($txt)*_MPDFK) + ($this->charspacing * mb_strlen( $txt, $this->mb_enc ))
7581
  + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ));
7582
  //Draw a line
7583
  return sprintf('%.3F %.3F m %.3F %.3F l S',$x*_MPDFK,($this->h-$y)*_MPDFK,($x*_MPDFK)+$w,($this->h-$y)*_MPDFK);
@@ -7594,15 +7593,15 @@ function _imageError($file, $firsttime, $msg) {
7594
  }
7595
 
7596
 
7597
- function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=false) {
7598
  // firsttime i.e. whether to add to this->images - use false when calling iteratively
7599
  // Image Data passed directly as var:varname
7600
- if (preg_match('/var:\s*(.*)/',$file, $v)) {
7601
  $data = $this->$v[1];
7602
  $file = md5($data);
7603
  }
7604
  // mPDF 5.5.13
7605
- if (preg_match('/data:image\/(gif|jpeg|png);base64,(.*)/',$file, $v)) {
7606
  $type = $v[1];
7607
  $data = base64_decode($v[2]);
7608
  $file = md5($data);
@@ -7618,19 +7617,19 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7618
  else if ($orig_srcpath && isset($this->formobjects[$orig_srcpath])) { $file=$orig_srcpath; return $this->formobjects[$file]; }
7619
  else if (isset($this->formobjects[$file])) { return $this->formobjects[$file]; }
7620
  // Save re-trying image URL's which have already failed
7621
- else if ($firsttime && isset($this->failedimages[$file])) { return $this->_imageError($file, $firsttime, ''); }
7622
  if (empty($data)) {
7623
  $type = '';
7624
  $data = '';
7625
 
7626
  if ($orig_srcpath && $this->basepathIsLocal && $check = @fopen($orig_srcpath,"rb")) {
7627
- fclose($check);
7628
  $file=$orig_srcpath;
7629
  $data = file_get_contents($file);
7630
  $type = $this->_imageTypeFromString($data);
7631
  }
7632
  if (!$data && $check = @fopen($file,"rb")) {
7633
- fclose($check);
7634
  $data = file_get_contents($file);
7635
  $type = $this->_imageTypeFromString($data);
7636
  }
@@ -7646,7 +7645,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7646
  {
7647
  /* Blue Liquid Designs Edit
7648
  Ensure Wordpress compatibility
7649
- */
7650
  if( !class_exists( 'WP_Http' ) ) {
7651
  include_once( ABSPATH . WPINC. '/class-http.php' );
7652
  }
@@ -7655,12 +7654,12 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7655
  if ( !is_wp_error($result) ) {
7656
  $data = $result['body'];
7657
  $type = $this->_imageTypeFromString($data);
7658
- }
7659
  }
7660
 
7661
  }
7662
  if (!$data) { return $this->_imageError($file, $firsttime, 'Could not find image file'); }
7663
- if (empty($type)) { $type = $this->_imageTypeFromString($data); }
7664
  if (($type == 'wmf' || $type == 'svg') && !$allowvector) { return $this->_imageError($file, $firsttime, 'WMF or SVG image file not supported in this context'); }
7665
 
7666
  // SVG
@@ -7686,7 +7685,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7686
  if (!$hdr) { return $this->_imageError($file, $firsttime, 'Error parsing JPG header'); }
7687
  $a = $this->_jpgDataFromHeader($hdr);
7688
  $j = strpos($data,'JFIF');
7689
- if ($j) {
7690
  //Read resolution
7691
  $unitSp=ord(substr($data,($j+7),1));
7692
  if ($unitSp > 0) {
@@ -7744,31 +7743,31 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7744
  // PNG
7745
  else if ($type == 'png') {
7746
  //Check signature
7747
- if(substr($data,0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
7748
- return $this->_imageError($file, $firsttime, 'Error parsing PNG identifier');
7749
  }
7750
  //Read header chunk
7751
- if(substr($data,12,4)!='IHDR') {
7752
- return $this->_imageError($file, $firsttime, 'Incorrect PNG file (no IHDR block found)');
7753
  }
7754
 
7755
  $w=$this->_fourbytes2int(substr($data,16,4));
7756
  $h=$this->_fourbytes2int(substr($data,20,4));
7757
  $bpc=ord(substr($data,24,1));
7758
  $errpng = false;
7759
- $pngalpha = false;
7760
  if($bpc>8) { $errpng = 'not 8-bit depth'; }
7761
  $ct=ord(substr($data,25,1));
7762
  if($ct==0) { $colspace='DeviceGray'; }
7763
  elseif($ct==2) { $colspace='DeviceRGB'; }
7764
  elseif($ct==3) { $colspace='Indexed'; }
7765
  elseif($ct==4) { $colspace='DeviceGray'; $errpng = 'alpha channel'; $pngalpha = true; }
7766
- else { $colspace='DeviceRGB'; $errpng = 'alpha channel'; $pngalpha = true; }
7767
  if(ord(substr($data,26,1))!=0) { $errpng = 'compression method'; }
7768
  if(ord(substr($data,27,1))!=0) { $errpng = 'filter method'; }
7769
  if(ord(substr($data,28,1))!=0) { $errpng = 'interlaced file'; }
7770
  $j = strpos($data,'pHYs');
7771
- if ($j) {
7772
  //Read resolution
7773
  $unitSp=ord(substr($data,($j+12),1));
7774
  if ($unitSp == 1) {
@@ -7832,8 +7831,8 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7832
  }
7833
  // create temp alpha file
7834
  $tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.RAND(1,10000).'.png';
7835
- if (!is_writable($tempfile_alpha)) {
7836
- ob_start();
7837
  $check = @imagepng($imgalpha);
7838
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7839
  imagedestroy($imgalpha);
@@ -7846,7 +7845,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7846
  // create temp image file
7847
  $minfo = $this->_getImage($this->_tempimglnk, false);
7848
  if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
7849
- ob_start();
7850
  $check = @imagepng($imgplain);
7851
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7852
  $this->_tempimg = ob_get_contents();
@@ -7899,10 +7898,10 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7899
  }
7900
  else { // No alpha/transparency set
7901
  imagealphablending($im, false);
7902
- imagesavealpha($im, false);
7903
  imageinterlace($im, false);
7904
- if (!is_writable($tempfile)) {
7905
- ob_start();
7906
  $check = @imagepng($im);
7907
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7908
  $this->_tempimg = ob_get_contents();
@@ -7917,7 +7916,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7917
  if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile.') parsing PNG image ('.$errpng.')'); }
7918
  imagedestroy($im);
7919
  $info = $this->_getImage($tempfile, false) ;
7920
- unlink($tempfile );
7921
  if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse PNG image'); }
7922
  }
7923
  if ($ppUx) { $info['set-dpi'] = $ppUx; }
@@ -7992,10 +7991,10 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
7992
  if ($im) {
7993
  $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png';
7994
  imagealphablending($im, false);
7995
- imagesavealpha($im, false);
7996
  imageinterlace($im, false);
7997
- if (!is_writable($tempfile)) {
7998
- ob_start();
7999
  $check = @imagepng($im);
8000
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse GIF image'); }
8001
  $this->_tempimg = ob_get_contents();
@@ -8023,8 +8022,8 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
8023
  else { return $this->_imageError($file, $firsttime, 'Error creating GD image file from GIF image'); }
8024
  }
8025
 
8026
- if (!class_exists('gif', false)) {
8027
- include_once(_MPDF_PATH.'classes/gif.php');
8028
  }
8029
  $gif=new CGIF();
8030
 
@@ -8063,15 +8062,15 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
8063
  $gif->ClearData();
8064
 
8065
  if($colspace=='Indexed' and empty($pal)) {
8066
- return $this->_imageError($file, $firsttime, 'Error parsing GIF image - missing colour palette');
8067
  }
8068
  if ($this->compress) {
8069
  $gifdata=gzcompress($gifdata);
8070
  $info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'f'=>'FlateDecode', 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
8071
- }
8072
  else {
8073
  $info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
8074
- }
8075
  $info['type']='gif';
8076
  if ($firsttime) {
8077
  $info['i']=count($this->images)+1;
@@ -8090,7 +8089,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
8090
  if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); }
8091
  $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png';
8092
  imagealphablending($im, false);
8093
- imagesavealpha($im, false);
8094
  imageinterlace($im, false);
8095
  $check = @imagepng($im, $tempfile);
8096
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse unknown image type'); }
@@ -8107,7 +8106,7 @@ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=fal
8107
  }
8108
  }
8109
 
8110
- return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised');
8111
  }
8112
  //==============================================================
8113
  function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
@@ -8121,17 +8120,17 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
8121
  //Read transparency info
8122
  $trns=array();
8123
  $trnsrgb = false;
8124
- if (!$this->PDFA && !$this->PDFX) {
8125
  $p = strpos($data,'tRNS');
8126
- if ($p) {
8127
  $n=$this->_fourbytes2int(substr($data,($p-4),4));
8128
- $t = substr($data,($p+4),$n);
8129
- if ($colspace=='DeviceGray') {
8130
- $trns=array(ord(substr($t,1,1)));
8131
  $trnsrgb = array($trns[0],$trns[0],$trns[0]);
8132
  }
8133
- else if ($colspace=='DeviceRGB') {
8134
- $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
8135
  $trnsrgb = $trns;
8136
  if ($targetcs=='DeviceCMYK') {
8137
  $col = $this->rgb2cmyk(array(3,$trns[0],$trns[1],$trns[2]));
@@ -8228,8 +8227,8 @@ function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
8228
  $info = array('w'=>$w,'h'=>$h,'cs'=>$targetcs,'bpc'=>8,'f'=>'FlateDecode','data'=>$imgdata, 'type'=>'png',
8229
  'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
8230
  if ($dpi) { $info['set-dpi'] = $dpi; }
8231
- if ($mask) {
8232
- $mimgdata = gzcompress($mimgdata);
8233
  $minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png',
8234
  'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
8235
  if ($dpi) { $minfo['set-dpi'] = $dpi; }
@@ -8325,20 +8324,20 @@ function file_get_contents_by_socket($url, &$data) {
8325
 
8326
  function _imageTypeFromString(&$data) {
8327
  $type = '';
8328
- if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif') {
8329
- $type = 'jpeg';
8330
  }
8331
- else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") {
8332
  $type = 'gif';
8333
  }
8334
- else if (substr($data, 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
8335
  $type = 'png';
8336
  }
8337
- else if (preg_match('/<svg.*<\/svg>/is',$data)) {
8338
  $type = 'svg';
8339
  }
8340
  // BMP images
8341
- else if (substr($data, 0, 2)== "BM") {
8342
  $type = 'bmp';
8343
  }
8344
  return $type;
@@ -8410,15 +8409,15 @@ function _out($s,$ln=true) {
8410
  $this->headerbuffer.= $s."\n";
8411
  }
8412
  else if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) {
8413
- // Captures eveything in buffer for rotated tables;
8414
  $this->tablebuffer .= $s . "\n";
8415
  }
8416
  else if ($this->kwt && !$this->processingHeader && !$this->processingFooter) {
8417
- // Captures eveything in buffer for keep-with-table (h1-6);
8418
  $this->kwt_buffer[] = array(
8419
- 's' => $s, // Text string to output
8420
- 'x' => $this->x, // x when printed
8421
- 'y' => $this->y, // y when printed
8422
  );
8423
  }
8424
  else if (($this->keep_block_together) && !$this->processingHeader && !$this->processingFooter) {
@@ -8426,8 +8425,8 @@ function _out($s,$ln=true) {
8426
  $this->ktBlock[$this->page]['bottom_margin'] = $this->y;
8427
  }
8428
 
8429
- // Captures eveything in buffer;
8430
- if (preg_match('/q \d+\.\d\d+ 0 0 (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ cm \/(I|FO)\d+ Do Q/',$s,$m)) { // Image data
8431
  $h = ($m[1]/_MPDFK);
8432
  // Update/overwrite the lowest bottom of printing y value for Keep together block
8433
  $this->ktBlock[$this->page]['bottom_margin'] = $this->y+$h;
@@ -8439,8 +8438,8 @@ function _out($s,$ln=true) {
8439
  if ($h < 0) { $h = -$h; }
8440
  $this->divbuffer[] = array(
8441
  'page' => $this->page,
8442
- 's' => $s, // Text string to output
8443
- 'x' => $this->x, // x when printed
8444
  'y' => $this->y, // y when printed (after column break)
8445
  'h' => $h // actual y at bottom when printed = y+h
8446
  );
@@ -8570,7 +8569,7 @@ function UTF8toSubset($str) {
8570
  $orig_fid = $this->CurrentFont['subsetfontids'][0];
8571
  $last_fid = $this->CurrentFont['subsetfontids'][0];
8572
  foreach($unicode as $c) {
8573
- if ($c == 7 || $c == 8) {
8574
  if ($orig_fid != $last_fid) {
8575
  $ret .= '> Tj /F'.$orig_fid.' '.$this->FontSizePt.' Tf <';
8576
  $last_fid = $orig_fid;
@@ -8620,13 +8619,13 @@ function UTF8toSubset($str) {
8620
 
8621
  // Converts UTF-8 strings to UTF16-BE.
8622
  function UTF8ToUTF16BE($str, $setbom=true) {
8623
- if ($this->checkSIP && preg_match("/([\x{20000}-\x{2FFFF}])/u", $str)) {
8624
  if (!in_array($this->currentfontfamily, array('gb','big5','sjis','uhc','gbB','big5B','sjisB','uhcB','gbI','big5I','sjisI','uhcI',
8625
  'gbBI','big5BI','sjisBI','uhcBI'))) {
8626
  $str = preg_replace("/[\x{20000}-\x{2FFFF}]/u", chr(0), $str);
8627
  }
8628
  }
8629
- if ($this->checkSMP && preg_match("/([\x{10000}-\x{1FFFF}])/u", $str )) {
8630
  $str = preg_replace("/[\x{10000}-\x{1FFFF}]/u", chr(0), $str );
8631
  }
8632
  $outstr = ""; // string to be returned
@@ -8655,7 +8654,7 @@ function SetAutoFont($af = AUTOFONT_ALL) {
8655
  if ($this->onlyCoreFonts) { return false; }
8656
  if (!$af && $af !== 0) { $af = AUTOFONT_ALL; }
8657
  $this->autoFontGroups = $af;
8658
- if ($this->autoFontGroups ) {
8659
  $this->useLang = true;
8660
  }
8661
  }
@@ -8692,7 +8691,7 @@ function SetDefaultBodyCSS($prop, $val) {
8692
 
8693
 
8694
  function SetDirectionality($dir='ltr') {
8695
- $this->directionality = 'ltr';
8696
  $this->defaultAlign = 'L';
8697
  $this->defaultTableAlign = 'L';
8698
  $this->CSS['BODY']['DIRECTION'] = $this->directionality;
@@ -8710,11 +8709,11 @@ function SetLineHeightCorrection($val) {
8710
  function SetLineHeight($FontPt='',$spacing = '') {
8711
  if ($this->shrin_k > 1) { $k = $this->shrin_k; }
8712
  else { $k = 1; }
8713
- if ($spacing > 0) {
8714
- if (preg_match('/mm/',$spacing)) {
8715
  $this->lineheight = ($spacing + 0.0) / $k; // convert to number
8716
  }
8717
- else {
8718
  if ($FontPt) { $this->lineheight = (($FontPt/_MPDFK) *$spacing); }
8719
  else { $this->lineheight = (($this->FontSizePt/_MPDFK) *$spacing); }
8720
  }
@@ -8729,14 +8728,14 @@ function _computeLineheight($lh, $fs='') {
8729
  if ($this->shrin_k > 1) { $k = $this->shrin_k; }
8730
  else { $k = 1; }
8731
  if (!$fs) { $fs = $this->FontSize; }
8732
- if (preg_match('/mm/',$lh)) {
8733
  return (($lh + 0.0) / $k); // convert to number
8734
  }
8735
- else if ($lh > 0) {
8736
  return ($fs * $lh);
8737
  }
8738
  else if (isset($this->normalLineheight)) { return ($fs * $this->normalLineheight); }
8739
- else return ($fs * $this->default_lineheight_correction);
8740
  }
8741
 
8742
 
@@ -8744,19 +8743,19 @@ function SetBasePath($str='') {
8744
  if ( isset($_SERVER['HTTP_HOST']) ) { $host = $_SERVER['HTTP_HOST']; }
8745
  else if ( isset($_SERVER['SERVER_NAME']) ) { $host = $_SERVER['SERVER_NAME']; }
8746
  else { $host = ''; }
8747
- if (!$str) {
8748
  if ($_SERVER['SCRIPT_NAME']) { $currentPath = dirname($_SERVER['SCRIPT_NAME']); }
8749
  else { $currentPath = dirname($_SERVER['PHP_SELF']); }
8750
  $currentPath = str_replace("\\","/",$currentPath);
8751
  if ($currentPath == '/') { $currentPath = ''; }
8752
  if ($host) { $currpath = 'http://' . $host . $currentPath .'/'; }
8753
  else { $currpath = ''; }
8754
- $this->basepath = $currpath;
8755
- $this->basepathIsLocal = true;
8756
- return;
8757
  }
8758
  $str = preg_replace('/\?.*/','',$str);
8759
- if (!preg_match('/(http|https|ftp):\/\/.*\//i',$str)) { $str .= '/'; }
8760
  $str .= 'xxx'; // in case $str ends in / e.g. http://www.bbc.co.uk/
8761
  $this->basepath = dirname($str) . "/"; // returns e.g. e.g. http://www.google.com/dir1/dir2/dir3/
8762
  $this->basepath = str_replace("\\","/",$this->basepath); //If on Windows
@@ -8789,10 +8788,10 @@ function GetFullPath(&$path,$basepath='') {
8789
  $path = $path . "/" . $filepath; //Make it an absolute path
8790
  }
8791
  else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link
8792
- if (substr($path,0,1) == "/") {
8793
  $tr = parse_url($basepath);
8794
  $root = $tr['scheme'].'://'.$tr['host'];
8795
- $path = $root . $path;
8796
  }
8797
  else { $path = $basepath . $path; }
8798
  }
@@ -8812,9 +8811,9 @@ function _get_file($path) {
8812
  $ap=realpath($lp);
8813
  $ap=str_replace("\\","/",$ap);
8814
  $docroot=substr($ap,0,strpos($ap,$lp));
8815
- // WriteHTML parses all paths to full URLs; may be local file name
8816
- if ($tr['scheme'] && $tr['host'] && $_SERVER["DOCUMENT_ROOT"] ) {
8817
- $localpath = $_SERVER["DOCUMENT_ROOT"] . $tr['path'];
8818
  }
8819
  // DOCUMENT_ROOT is not returned on IIS
8820
  else if ($docroot) {
@@ -8845,9 +8844,9 @@ function docPageNum($num = 0, $extras = false) {
8845
  $lastreset = 0;
8846
  foreach($this->PageNumSubstitutions AS $psarr) {
8847
  if ($num >= $psarr['from']) {
8848
- if ($psarr['reset']) {
8849
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8850
- $ppgno = $num - $psarr['from'] + 1 + $offset;
8851
  $lastreset = $psarr['from'];
8852
  }
8853
  if ($psarr['type']) { $type = $psarr['type']; }
@@ -8872,7 +8871,7 @@ function docPageNum($num = 0, $extras = false) {
8872
 
8873
 
8874
  function docPageSettings($num = 0) {
8875
- // Returns current type (numberstyle), suppression state for this page number;
8876
  // reset is only returned if set for this page number
8877
  if ($num < 1) { $num = $this->page; }
8878
  $type = '1'; // set default decimal
@@ -8882,9 +8881,9 @@ function docPageSettings($num = 0) {
8882
  $reset = '';
8883
  foreach($this->PageNumSubstitutions AS $psarr) {
8884
  if ($num >= $psarr['from']) {
8885
- if ($psarr['reset']) {
8886
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8887
- $ppgno = $num - $psarr['from'] + 1 + $offset;
8888
  }
8889
  if ($psarr['type']) { $type = $psarr['type']; }
8890
  if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
@@ -8901,29 +8900,29 @@ function docPageNumTotal($num = 0, $extras = false) {
8901
  if ($num < 1) { $num = $this->page; }
8902
  $type = '1'; // set default decimal
8903
  $ppgstart = 1;
8904
- $ppgend = count($this->pages)+1;
8905
  $suppress = 0;
8906
  $offset = 0;
8907
  foreach($this->PageNumSubstitutions AS $psarr) {
8908
  if ($num >= $psarr['from']) {
8909
- if ($psarr['reset']) {
8910
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8911
- $ppgstart = $psarr['from'] + $offset;
8912
- $ppgend = count($this->pages)+1 + $offset;
8913
  }
8914
  if ($psarr['type']) { $type = $psarr['type']; }
8915
  if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
8916
  else if (strtoupper($psarr['suppress'])=='OFF') { $suppress = 0; }
8917
  }
8918
  if ($num < $psarr['from']) {
8919
- if ($psarr['reset']) {
8920
- $ppgend = $psarr['from'] + $offset;
8921
  break;
8922
  }
8923
  }
8924
  }
8925
  if ($suppress) { return ''; }
8926
- $ppgno = $ppgend-$ppgstart+$offset;
8927
  if ($extras) { $ppgno = $this->nbpgPrefix . $ppgno . $this->nbpgSuffix; }
8928
  return $ppgno;
8929
  }
@@ -8956,8 +8955,8 @@ function Header($content='') {
8956
  $headerlmargin = $this->orig_lMargin;
8957
  }
8958
  }
8959
- else {
8960
- $yadj = 0;
8961
  $headerpgwidth = $this->pgwidth;
8962
  $headerlmargin = $this->lMargin;
8963
  }
@@ -8969,7 +8968,7 @@ function Header($content='') {
8969
  $this->bullet = false;
8970
 
8971
  // only show pagenumber if numbering on
8972
- $pgno = $this->docPageNum($this->page, true);
8973
 
8974
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
8975
  $side = 'even';
@@ -8997,11 +8996,11 @@ function Header($content='') {
8997
  else { $hfsz = $this->original_default_font_size; } // pts
8998
  $maxfontheight = max($maxfontheight,$hfsz);
8999
  $hfst = '';
9000
- if (isset($h[$side][$pos]['font-style']) && $h[$side][$pos]['font-style']) {
9001
  $hfst = $h[$side][$pos]['font-style'];
9002
  }
9003
- if (isset($h[$side][$pos]['color']) && $h[$side][$pos]['color']) {
9004
- $hfcol = $h[$side][$pos]['color'];
9005
  $cor = $this->ConvertColor($hfcol);
9006
  if ($cor) { $this->SetTColor($cor); }
9007
  }
@@ -9019,13 +9018,13 @@ function Header($content='') {
9019
  // DIRECTIONALITY RTL
9020
  // Font-specific ligature substitution for Indic fonts
9021
  $align = $pos;
9022
- if ($pos!='L' && (strpos($hd,$this->aliasNbPg)!==false || strpos($hd,$this->aliasNbPgGp)!==false)) {
9023
  if (strpos($hd,$this->aliasNbPgGp)!==false) { $type= 'nbpggp'; } else { $type= 'nbpg'; }
9024
- $this->_out('{mpdfheader'.$type.' '.$pos.' ff='.$hff.' fs='.$hfst.' fz='.$hfsz.'}');
9025
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9026
  $this->_out('Q');
9027
  }
9028
- else {
9029
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9030
  }
9031
  if ($hfcol) { $this->SetTColor($this->ConvertColor(0)); }
@@ -9034,7 +9033,7 @@ function Header($content='') {
9034
  //Return Font to normal
9035
  $this->SetFont($this->default_font,'',$this->original_default_font_size);
9036
  // LINE
9037
- if (isset($h[$side]['line']) && $h[$side]['line']) {
9038
  $this->SetLineWidth(0.1);
9039
  $this->SetDColor($this->ConvertColor(0));
9040
  $this->Line($headerlmargin , $this->margin_header + ($maxfontheight*(1+$this->header_line_spacing)/_MPDFK) - $yadj , $headerlmargin + $headerpgwidth, $this->margin_header + ($maxfontheight*(1+$this->header_line_spacing)/_MPDFK) - $yadj );
@@ -9058,12 +9057,12 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9058
  if ($horf=='H') { // Only if header
9059
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; }
9060
  else { $adv = $table['max_cell_border_width']['T'] /2 ; }
9061
- if ($adv) {
9062
  if ($this->table_rotate) {
9063
  $this->y += ($adv);
9064
  }
9065
  else {
9066
- $this->DivLn($adv,$this->blklvl,true);
9067
  }
9068
  }
9069
  }
@@ -9131,7 +9130,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9131
  $this->x = $x;
9132
 
9133
  if ($this->ColActive) {
9134
- if ($table['borders_separate']) {
9135
  $tablefill = isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0;
9136
  if ($tablefill) {
9137
  $color = $this->ConvertColor($tablefill);
@@ -9162,7 +9161,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9162
  }
9163
 
9164
  if ($table['empty_cells']!='hide' || !empty($textbuffer) || !$table['borders_separate']) { $paintcell = true; }
9165
- else { $paintcell = false; }
9166
 
9167
  //Vertical align
9168
  if ($R && INTVAL($R) > 0 && isset($va) && $va!='B') { $va='B';}
@@ -9173,7 +9172,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9173
 
9174
  //TABLE ROW OR CELL FILL BGCOLOR
9175
  $fill = 0;
9176
- if (isset($tablehf['bgcolor']) && $tablehf['bgcolor'] && $tablehf['bgcolor']!='transparent') {
9177
  $fill = $tablehf['bgcolor'];
9178
  $leveladj = 6;
9179
  }
@@ -9184,7 +9183,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9184
  if ($fill && $paintcell) {
9185
  $color = $this->ConvertColor($fill);
9186
  if ($color) {
9187
- if ($table['borders_separate']) {
9188
  if ($this->ColActive) {
9189
  $this->SetFColor($color);
9190
  $this->Rect($x+ ($table['border_spacing_H']/2), $y+ ($table['border_spacing_V']/2), $w- $table['border_spacing_H'], $h- $table['border_spacing_V'], 'F');
@@ -9193,7 +9192,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9193
  $this->tableBackgrounds[$level*9+$leveladj][] = array('gradient'=>false, 'x'=>($x + ($table['border_spacing_H']/2)), 'y'=>($y + ($table['border_spacing_V']/2)), 'w'=>($w - $table['border_spacing_H']), 'h'=>($h - $table['border_spacing_V']), 'col'=>$color);
9194
  }
9195
  }
9196
- else {
9197
  if ($this->ColActive) {
9198
  $this->SetFColor($color);
9199
  $this->Rect($x, $y, $w, $h, 'F');
@@ -9208,15 +9207,15 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9208
 
9209
 
9210
  //Cell Border
9211
- if ($table['borders_separate'] && $paintcell && $border) {
9212
  $this->_tableRect($x+ ($table['border_spacing_H']/2)+($border_details['L']['w'] /2), $y+ ($table['border_spacing_V']/2)+($border_details['T']['w'] /2), $w-$table['border_spacing_H']-($border_details['L']['w'] /2)-($border_details['R']['w'] /2), $h- $table['border_spacing_V']-($border_details['T']['w'] /2)-($border_details['B']['w']/2), $border, $border_details, false, $table['borders_separate']);
9213
  }
9214
- else if ($paintcell && $border) {
9215
  $this->_tableRect($x, $y, $w, $h, $border, $border_details, true, $table['borders_separate']); // true causes buffer
9216
  }
9217
 
9218
  //Print cell content
9219
- //$this->divheight = $this->table_lineheight*$this->lineheight;
9220
  if (!empty($textbuffer)) {
9221
  if ($horf=='F' && preg_match('/{colsum([0-9]*)[_]*}/', $textbuffer[0][0], $m)) {
9222
  $rep = sprintf("%01.".intval($m[1])."f", $this->colsums[$colctr-1]);
@@ -9236,30 +9235,30 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9236
  else if ($angle > 0 && $angle <45) { $angle = 45; }
9237
  else if ($angle < 0) { $angle = -90; }
9238
  $offset = ((sin(deg2rad($angle))) * 0.37 * $cellFontHeight);
9239
- if (isset($align) && $align =='R') {
9240
- $this->x += ($w) + ($offset) - ($cellFontHeight/3) - ($padding['R'] + $border_details['R']['w']);
9241
  }
9242
- else if (!isset($align ) || $align =='C') {
9243
- $this->x += ($w/2) + ($offset);
9244
  }
9245
- else {
9246
- $this->x += ($offset) + ($cellFontHeight/3)+($padding['L'] + $border_details['L']['w']);
9247
  }
9248
  $str = '';
9249
  foreach($tablehf['textbuffer'] AS $t) { $str .= $t[0].' '; }
9250
  $str = trim($str);
9251
 
9252
- if (!isset($va) || $va=='M') {
9253
  $this->y -= ($h-$mih)/2; //Undo what was added earlier VERTICAL ALIGN
9254
  if ($angle > 0) { $this->y += (($h-$mih)/2)+($padding['T'] + $border_details['T']['w']) + ($mih-($padding['T'] + $border_details['T']['w']+$border_details['B']['w']+$padding['B'])); }
9255
  else if ($angle < 0) { $this->y += (($h-$mih)/2)+($padding['T'] + $border_details['T']['w']); }
9256
  }
9257
- else if (isset($va) && $va=='B') {
9258
  $this->y -= $h-$mih; //Undo what was added earlier VERTICAL ALIGN
9259
  if ($angle > 0) { $this->y += $h-($border_details['B']['w']+$padding['B']); }
9260
  else if ($angle < 0) { $this->y += $h-$mih+($padding['T'] + $border_details['T']['w']); }
9261
  }
9262
- else if (isset($va) && $va=='T') {
9263
  if ($angle > 0) { $this->y += $mih-($border_details['B']['w']+$padding['B']); }
9264
  else if ($angle < 0) { $this->y += ($padding['T'] + $border_details['T']['w']); }
9265
  }
@@ -9270,7 +9269,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9270
  $s_st = $this->FontStyle;
9271
  if (!empty($textbuffer[0][3])) { //Font Color
9272
  $cor = $textbuffer[0][3];
9273
- $this->SetTColor($cor);
9274
  }
9275
  $s_str = $this->strike;
9276
  $this->strike = $textbuffer[0][8]; //Strikethrough
@@ -9306,7 +9305,7 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9306
 
9307
 
9308
  // TABLE BORDER - if separate OR collapsed and only table border
9309
- if (($table['borders_separate'] || ($this->simpleTables && !$table['simple']['border'])) && $table['border']) {
9310
  $halfspaceL = $table['padding']['L'] + ($table['border_spacing_H']/2);
9311
  $halfspaceR = $table['padding']['R'] + ($table['border_spacing_H']/2);
9312
  $halfspaceT = $table['padding']['T'] + ($table['border_spacing_V']/2);
@@ -9320,23 +9319,23 @@ function TableHeaderFooter($content='',$tablestartpage='',$tablestartcolumn ='',
9320
  if ($i == $firstrow && $horf=='H') { // Top
9321
  $tby -= $halfspaceT + ($table['border_details']['T']['w']/2);
9322
  $tbh += $halfspaceT + ($table['border_details']['T']['w']/2);
9323
- $this->setBorder($tab_bord , _BORDER_TOP);
9324
  $corner .= 'T';
9325
  }
9326
  if (($i == ($lastrow) || (isset($tablehf['rowspan']) && ($i+$tablehf['rowspan']) == ($lastrow+1))) && $horf=='F') { // Bottom
9327
  $tbh += $halfspaceB + ($table['border_details']['B']['w']/2);
9328
- $this->setBorder($tab_bord , _BORDER_BOTTOM);
9329
  $corner .= 'B';
9330
  }
9331
  if ($colctr == 1 && $firstSpread) { // Left
9332
  $tbx -= $halfspaceL + ($table['border_details']['L']['w']/2);
9333
  $tbw += $halfspaceL + ($table['border_details']['L']['w']/2);
9334
- $this->setBorder($tab_bord , _BORDER_LEFT);
9335
  $corner .= 'L';
9336
  }
9337
  if ($colctr == count($content[$i]) && $finalSpread) { // Right
9338
  $tbw += $halfspaceR + ($table['border_details']['R']['w']/2);
9339
- $this->setBorder($tab_bord , _BORDER_RIGHT);
9340
  $corner .= 'R';
9341
  }
9342
  $this->_tableRect($tbx, $tby, $tbw, $tbh, $tab_bord , $table['border_details'], false, $table['borders_separate'], 'table', $corner, $table['border_spacing_V'], $table['border_spacing_H'] );
@@ -9420,10 +9419,10 @@ function SetHeader($Harray=array(),$side='',$write=false) {
9420
  else { $this->headerDetails = $Harray; }
9421
  }
9422
 
9423
- if ($write) {
9424
  $save_y = $this->y;
9425
  $this->Header();
9426
- $this->SetY($save_y) ;
9427
  }
9428
  }
9429
 
@@ -9498,8 +9497,8 @@ function Footer() {
9498
  $headerlmargin = $this->orig_lMargin;
9499
  }
9500
  }
9501
- else {
9502
- $yadj = 0;
9503
  $headerpgwidth = $this->pgwidth;
9504
  $headerlmargin = $this->lMargin;
9505
  }
@@ -9511,7 +9510,7 @@ function Footer() {
9511
  $this->bullet = false;
9512
 
9513
  // only show pagenumber if numbering on
9514
- $pgno = $this->docPageNum($this->page, true);
9515
 
9516
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
9517
  $side = 'even';
@@ -9540,8 +9539,8 @@ function Footer() {
9540
  $maxfontheight = max($maxfontheight,$hfsz);
9541
  if (isset($h[$side][$pos]['font-style']) && $h[$side][$pos]['font-style']) { $hfst = $h[$side][$pos]['font-style']; }
9542
  else { $hfst = ''; }
9543
- if (isset($h[$side][$pos]['color']) && $h[$side][$pos]['color']) {
9544
- $hfcol = $h[$side][$pos]['color'];
9545
  $cor = $this->ConvertColor($hfcol);
9546
  if ($cor) { $this->SetTColor($cor); }
9547
  }
@@ -9558,18 +9557,18 @@ function Footer() {
9558
  // DIRECTIONALITY RTL
9559
  // Font-specific ligature substitution for Indic fonts
9560
  $align = $pos;
9561
- if ($this->directionality == 'rtl') {
9562
  if ($pos == 'L') { $align = 'R'; }
9563
  else if ($pos == 'R') { $align = 'L'; }
9564
  }
9565
 
9566
- if ($pos!='L' && (strpos($hd,$this->aliasNbPg)!==false || strpos($hd,$this->aliasNbPgGp)!==false)) {
9567
  if (strpos($hd,$this->aliasNbPgGp)!==false) { $type= 'nbpggp'; } else { $type= 'nbpg'; }
9568
- $this->_out('{mpdfheader'.$type.' '.$pos.' ff='.$hff.' fs='.$hfst.' fz='.$hfsz.'}');
9569
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9570
  $this->_out('Q');
9571
  }
9572
- else {
9573
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9574
  }
9575
  if ($hfcol) { $this->SetTColor($this->ConvertColor(0)); }
@@ -9580,7 +9579,7 @@ function Footer() {
9580
 
9581
  // LINE
9582
 
9583
- if (isset($h[$side]['line']) && $h[$side]['line']) {
9584
  $this->SetLineWidth(0.1);
9585
  $this->SetDColor($this->ConvertColor(0));
9586
  $this->Line($headerlmargin , $this->y-($maxfontheight*($this->footer_line_spacing)/_MPDFK), $headerlmargin +$headerpgwidth, $this->y-($maxfontheight*($this->footer_line_spacing)/_MPDFK));
@@ -9614,11 +9613,11 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9614
  if ($sub == 1) { $html = '<style> '.$html.' </style>'; } // stylesheet only
9615
 
9616
  if ($this->allow_charset_conversion) {
9617
- if ($sub < 1) {
9618
- $this->ReadCharset($html);
9619
  }
9620
- if ($this->charset_in && $sub!=4) { // mPDF 5.4.14
9621
- $success = iconv($this->charset_in,'UTF-8//TRANSLIT',$html);
9622
  if ($success) { $html = $success; }
9623
  }
9624
  }
@@ -9634,33 +9633,33 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9634
  }
9635
 
9636
  $zproperties = array();
9637
- if ($sub < 2) {
9638
- $this->ReadMetaTags($html);
9639
 
9640
  // NB default stylesheet now in mPDF.css - read on initialising class
9641
- $html = $this->ReadCSS($html);
9642
 
9643
- if ($this->useLang && !$this->usingCoreFont && preg_match('/<html [^>]*lang=[\'\"](.*?)[\'\"]/ism',$html,$m)) {
9644
- $html_lang = $m[1];
9645
  }
9646
 
9647
- if (preg_match('/<html [^>]*dir=[\'\"]\s*rtl\s*[\'\"]/ism',$html)) {
9648
- $zproperties['DIRECTION'] = 'rtl';
9649
  }
9650
 
9651
  // allow in-line CSS for body tag to be parsed // Get <body> tag inline CSS
9652
- if (preg_match('/<body([^>]*)>(.*?)<\/body>/ism',$html,$m) || preg_match('/<body([^>]*)>(.*)$/ism',$html,$m)) {
9653
- $html = $m[2];
9654
  // Changed to allow style="background: url('bg.jpg')"
9655
- if (preg_match('/style=[\"](.*?)[\"]/ism',$m[1],$mm) || preg_match('/style=[\'](.*?)[\']/ism',$m[1],$mm)) {
9656
- $zproperties = $this->readInlineCSS($mm[1]);
9657
  }
9658
- if (preg_match('/dir=[\'\"]\s*rtl\s*[\'\"]/ism',$m[1])) {
9659
- $zproperties['DIRECTION'] = 'rtl';
9660
  }
9661
  if (isset($html_lang) && $html_lang) { $zproperties['LANG'] = $html_lang; }
9662
  if ($this->useLang && !$this->onlyCoreFonts && preg_match('/lang=[\'\"](.*?)[\'\"]/ism',$m[1],$mm)) {
9663
- $zproperties['LANG'] = $mm[1];
9664
  }
9665
 
9666
  }
@@ -9669,14 +9668,14 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9669
  if ($zproperties) { $properties = $this->array_merge_recursive_unique($properties,$zproperties); }
9670
 
9671
  if (isset($properties['DIRECTION']) && $properties['DIRECTION']) {
9672
- $this->CSS['BODY']['DIRECTION'] = $properties['DIRECTION'];
9673
  }
9674
  if (!isset($this->CSS['BODY']['DIRECTION'])) {
9675
- $this->CSS['BODY']['DIRECTION'] = $this->directionality;
9676
  }
9677
  else { $this->SetDirectionality($this->CSS['BODY']['DIRECTION']); }
9678
 
9679
- $this->setCSS($properties,'','BODY');
9680
  $this->blk[0]['InlineProperties'] = $this->saveInlineProperties();
9681
 
9682
  if ($sub == 1) { return ''; }
@@ -9684,29 +9683,29 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9684
 
9685
 
9686
 
9687
- $parseonly = false;
9688
- $this->bufferoutput = false;
9689
- if ($sub == 3) {
9690
- $parseonly = true;
9691
  // Close any open block tags
9692
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
9693
  // Output any text left in buffer
9694
  if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
9695
  $this->textbuffer=array();
9696
- }
9697
- else if ($sub == 4) {
9698
  // Close any open block tags
9699
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
9700
  // Output any text left in buffer
9701
  if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
9702
- $this->bufferoutput = true;
9703
  $this->textbuffer=array();
9704
  $this->headerbuffer='';
9705
  $properties = $this->MergeCSS('BLOCK','BODY','');
9706
- $this->setCSS($properties,'','BODY');
9707
- }
9708
 
9709
- mb_internal_encoding('UTF-8');
9710
 
9711
  $html = $this->AdjustHTML($html, $this->tabSpaces); //Try to make HTML look more like XHTML
9712
 
@@ -9724,8 +9723,8 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9724
  $html=str_replace('<?','< ',$html); //Fix '<?XML' bug from HTML code generated by MS Word
9725
 
9726
  $this->checkSIP = false;
9727
- $this->checkSMP = false;
9728
- $this->checkCJK = false;
9729
  if ($this->onlyCoreFonts) { $html = $this->SubstituteChars($html); }
9730
  else {
9731
  if (preg_match("/([\x{20000}-\x{2FFFF}])/u", $html)) { $this->checkSIP = true; }
@@ -9733,10 +9732,10 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9733
  }
9734
 
9735
  // Don't allow non-breaking spaces that are converted to substituted chars or will break anyway and mess up table width calc.
9736
- $html = str_replace('<tta>160</tta>',chr(32),$html);
9737
- $html = str_replace('</tta><tta>','|',$html);
9738
- $html = str_replace('</tts><tts>','|',$html);
9739
- $html = str_replace('</ttz><ttz>','|',$html);
9740
 
9741
  //Add new supported tags in the DisableTags function
9742
  $html=strip_tags($html,$this->enabledtags); //remove all unsupported tags, but the ones inside the 'enabledtags' string
@@ -9747,8 +9746,8 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9747
  // if changing - also change in fn.SubstituteChars()
9748
  // $a = preg_split ('/<((?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
9749
 
9750
- if ($this->mb_enc) {
9751
- mb_internal_encoding($this->mb_enc);
9752
  }
9753
  $pbc = 0;
9754
  $this->subPos = -1;
@@ -9766,23 +9765,23 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9766
  $e = strcode2utf($e);
9767
  $e = $this->lesser_entity_decode($e);
9768
 
9769
- if ($this->usingCoreFont) {
9770
  // If core font is selected in document which is not onlyCoreFonts - substitute with non-core font
9771
  if ($this->useSubstitutions && !$this->onlyCoreFonts && $this->subPos<$i && !$this->specialcontent) {
9772
- $cnt += $this->SubstituteCharsNonCore($a, $i, $e);
9773
  }
9774
  // CONVERT ENCODING
9775
- $e = mb_convert_encoding($e,$this->mb_enc,'UTF-8');
9776
  if ($this->toupper) { $e = strtoupper($e); }
9777
  if ($this->tolower) { $e = strtolower($e); }
9778
  if ($this->capitalize) { $e = ucwords($e); }
9779
  }
9780
  else {
9781
- if ($this->checkSIP && $this->CurrentFont['sipext'] && $this->subPos<$i && !$this->specialcontent) {
9782
- $cnt += $this->SubstituteCharsSIP($a, $i, $e);
9783
  }
9784
  if ($this->useSubstitutions && !$this->onlyCoreFonts && $this->CurrentFont['type']!='Type0' && $this->subPos<$i && !$this->specialcontent) {
9785
- $cnt += $this->SubstituteCharsMB($a, $i, $e);
9786
  }
9787
  // mPDF 5.4.05 removes U+200E/U+200F LTR and RTL mark
9788
  // mPDF 5.4.06 removes U+200C/U+200D Zero-width Joiner and Non-joiner
@@ -9814,10 +9813,10 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9814
  if (($this->blockjustfinished || $this->listjustfinished) && $this->cell[$this->row][$this->col]['s']>0) {
9815
  $this->_saveCellTextBuffer("\n");
9816
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
9817
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
9818
  }
9819
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
9820
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
9821
  }
9822
  $this->cell[$this->row][$this->col]['s'] = 0;// reset
9823
  }
@@ -9827,17 +9826,17 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9827
  $this->_saveCellTextBuffer($e, $this->HREF);
9828
 
9829
  if (!isset($this->cell[$this->row][$this->col]['R']) || !$this->cell[$this->row][$this->col]['R']) {
9830
- if (isset($this->cell[$this->row][$this->col]['s'])) {
9831
  $this->cell[$this->row][$this->col]['s'] += $this->GetStringWidth($e, false);
9832
  }
9833
  else { $this->cell[$this->row][$this->col]['s'] = $this->GetStringWidth($e, false); }
9834
- if (!empty($this->spanborddet)) {
9835
  $this->cell[$this->row][$this->col]['s'] += $this->spanborddet['L']['w'] + $this->spanborddet['R']['w'];
9836
  }
9837
  }
9838
 
9839
 
9840
- if ($this->tableLevel==1 && $this->useGraphs) {
9841
  $this->graphs[$this->currentGraphId]['data'][$this->row][$this->col] = $e;
9842
  }
9843
  $this->nestedtablejustfinished = false;
@@ -9859,14 +9858,14 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9859
 
9860
 
9861
  // Check for tags where HTML specifies optional end tags,
9862
- // and/or does not allow nesting e.g. P inside P, or
9863
  $endtag = trim(strtoupper(substr($e,1))); // mPDF 5.4.20
9864
- if($this->blk[$this->blklvl]['hide']) {
9865
- if (in_array($endtag, $this->outerblocktags) || in_array($endtag, $this->innerblocktags)) {
9866
  unset($this->blk[$this->blklvl]);
9867
- $this->blklvl--;
9868
  }
9869
- continue;
9870
  }
9871
 
9872
  if ($this->allow_html_optional_endtags && !$parseonly) {
@@ -9877,13 +9876,13 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9877
  if ($this->lastoptionaltag == 'DT' && $endtag == 'DL') { $this->CloseTag($this->lastoptionaltag ); }
9878
  if ($this->lastoptionaltag == 'OPTION' && $endtag == 'SELECT') { $this->CloseTag($this->lastoptionaltag ); }
9879
  if ($endtag == 'TABLE') {
9880
- if ($this->lastoptionaltag == 'THEAD' || $this->lastoptionaltag == 'TBODY' || $this->lastoptionaltag == 'TFOOT') {
9881
  $this->CloseTag($this->lastoptionaltag);
9882
  }
9883
  if ($this->lastoptionaltag == 'TR') { $this->CloseTag('TR'); }
9884
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); }
9885
  }
9886
- if ($endtag == 'THEAD' || $endtag == 'TBODY' || $endtag == 'TFOOT') {
9887
  if ($this->lastoptionaltag == 'TR') { $this->CloseTag('TR'); }
9888
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); }
9889
  }
@@ -9891,25 +9890,25 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9891
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); }
9892
  }
9893
  }
9894
- $this->CloseTag($endtag);
9895
  }
9896
 
9897
  else { // OPENING TAG
9898
- if($this->blk[$this->blklvl]['hide']) {
9899
  if (strpos($e,' ')) { $te = strtoupper(substr($e,0,strpos($e,' '))); }
9900
- else { $te = strtoupper($e); }
9901
- if (in_array($te, $this->outerblocktags) || in_array($te, $this->innerblocktags)) {
9902
  $this->blklvl++;
9903
  $this->blk[$this->blklvl]['hide']=true;
9904
  }
9905
- continue;
9906
  }
9907
 
9908
  $regexp = '|=\'(.*?)\'|s'; // eliminate single quotes, if any
9909
  $e = preg_replace($regexp,"=\"\$1\"",$e);
9910
  // changes anykey=anyvalue to anykey="anyvalue" (only do this inside tags)
9911
  if (substr($e,0,10)!='pageheader' && substr($e,0,10)!='pagefooter') {
9912
- $regexp = '| (\\w+?)=([^\\s>"]+)|si';
9913
  $e = preg_replace($regexp," \$1=\"\$2\"",$e);
9914
  }
9915
 
@@ -9922,9 +9921,9 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
9922
  preg_match($regexp,$e,$auxiliararray);
9923
  if (isset($auxiliararray[2])) { $path = $auxiliararray[2]; }
9924
  else { $path = ''; }
9925
- if (trim($path) != '' && !(stristr($e,"src=") !== false && substr($path,0,4)=='var:')) {
9926
  $orig_srcpath = $path;
9927
- $this->GetFullPath($path);
9928
  $regexp = '/ (href|src)="(.*?)"/i';
9929
  $e = preg_replace($regexp,' \\1="'.$path.'"',$e);
9930
  }
@@ -10000,7 +9999,7 @@ function WriteHTML($html,$sub=0,$init=true,$close=true) {
10000
  $this->linemaxfontsize = '';
10001
  $this->lineheight_correction = $this->default_lineheight_correction;
10002
 
10003
- $this->bufferoutput = false;
10004
 
10005
 
10006
  }
@@ -10022,17 +10021,17 @@ function initialiseBlock(&$blk) {
10022
  $blk['border_left']['w'] = 0;
10023
  $blk['border_bottom']['w'] = 0;
10024
  $blk['border_right']['w'] = 0;
10025
- $blk['hide'] = false;
10026
- $blk['outer_left_margin'] = 0;
10027
- $blk['outer_right_margin'] = 0;
10028
- $blk['cascadeCSS'] = array();
10029
- $blk['block-align'] = false;
10030
- $blk['bgcolor'] = false;
10031
- $blk['page_break_after_avoid'] = false;
10032
- $blk['keep_block_together'] = false;
10033
- $blk['float'] = false;
10034
- $blk['line_height'] = '';
10035
- $blk['margin_collapse'] = false;
10036
  }
10037
 
10038
 
@@ -10042,7 +10041,7 @@ function border_details($bd) {
10042
  if (isset($this->blk[$this->blklvl]['inner_width'])) { $refw = $this->blk[$this->blklvl]['inner_width']; }
10043
  else if (isset($this->blk[$this->blklvl-1]['inner_width'])) { $refw = $this->blk[$this->blklvl-1]['inner_width']; }
10044
  else { $refw = $this->w; }
10045
- if ( count($prop) == 1 ) {
10046
  $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
10047
  if ($bsize > 0) {
10048
  return array('s' => 1, 'w' => $bsize, 'c' => $this->ConvertColor(0), 'style'=>'solid');
@@ -10050,12 +10049,12 @@ function border_details($bd) {
10050
  else { return array('w' => 0, 's' => 0); }
10051
  }
10052
 
10053
- else if (count($prop) == 2 ) {
10054
- // 1px solid
10055
  if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $prop[2] = ''; }
10056
- // solid #000000
10057
  else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $prop[0] = ''; $prop[1] = $prop[0]; $prop[2] = $prop[1]; }
10058
- // 1px #000000
10059
  else { $prop[1] = ''; $prop[2] = $prop[1]; }
10060
  }
10061
  else if ( count($prop) == 3 ) {
@@ -10064,20 +10063,20 @@ function border_details($bd) {
10064
  // Change solid #000000 1px to 1px solid #000000 (proper)
10065
  else if (substr($prop[0],1,1) == '#') { $tmp = $prop[1]; $prop[0] = $prop[2]; $prop[1] = $prop[0]; $prop[2] = $tmp; }
10066
  // Change solid 1px #000000 to 1px solid #000000 (proper)
10067
- else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
10068
- $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $tmp;
10069
  }
10070
  }
10071
- else { return array(); }
10072
  // Size
10073
  $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
10074
  //color
10075
  $coul = $this->ConvertColor($prop[2]); // returns array
10076
  // Style
10077
  $prop[1] = strtolower($prop[1]);
10078
- if (in_array($prop[1],$this->borderstyles) && $bsize > 0) { $on = 1; }
10079
- else if ($prop[1] == 'hidden') { $on = 1; $bsize = 0; $coul = ''; }
10080
- else if ($prop[1] == 'none') { $on = 0; $bsize = 0; $coul = ''; }
10081
  else { $on = 0; $bsize = 0; $coul = ''; $prop[1] = ''; }
10082
  return array('s' => $on, 'w' => $bsize, 'c' => $coul, 'style'=> $prop[1] );
10083
  }
@@ -10086,10 +10085,10 @@ function border_details($bd) {
10086
  function _fix_borderStr($bd) {
10087
  // mPDF 5.5.04
10088
  preg_match_all("/\((.*?)\)/", $bd, $m);
10089
- if (count($m[1])) {
10090
  for($i=0;$i<count($m[1]);$i++) {
10091
  $sub = preg_replace("/ /", "", $m[1][$i]);
10092
- $bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd);
10093
  }
10094
  }
10095
 
@@ -10098,20 +10097,20 @@ function _fix_borderStr($bd) {
10098
  $c = '#000000';
10099
  $s = 'none';
10100
 
10101
- if ( count($prop) == 1 ) {
10102
  // solid
10103
  if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
10104
  // #000000
10105
  else if (is_array($this->ConvertColor($prop[0]))) { $c = $prop[0]; }
10106
- // 1px
10107
  else { $w = $prop[0]; }
10108
  }
10109
- else if (count($prop) == 2 ) {
10110
- // 1px solid
10111
  if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
10112
- // solid #000000
10113
  else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
10114
- // 1px #000000
10115
  else { $w = $prop[0]; $c = $prop[1]; }
10116
  }
10117
  else if ( count($prop) == 3 ) {
@@ -10120,12 +10119,12 @@ function _fix_borderStr($bd) {
10120
  // Change solid #000000 1px to 1px solid #000000 (proper)
10121
  else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
10122
  // Change solid 1px #000000 to 1px solid #000000 (proper)
10123
- else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
10124
- $s = $prop[0]; $w = $prop[1]; $c = $prop[2];
10125
  }
10126
  else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
10127
  }
10128
- else { return ''; }
10129
  $s = strtolower($s);
10130
  return $w.' '.$s.' '.$c;
10131
  }
@@ -10134,8 +10133,8 @@ function _fix_borderStr($bd) {
10134
 
10135
  // NEW FUNCTION FOR CSS MARGIN or PADDING called from SetCSS
10136
  function fixCSS($prop) {
10137
- if (!is_array($prop) || (count($prop)==0)) return array();
10138
- $newprop = array();
10139
  foreach($prop AS $k => $v) {
10140
  if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
10141
  $v = strtolower($v);
@@ -10145,28 +10144,28 @@ function fixCSS($prop) {
10145
  $s = trim($v);
10146
  preg_match_all('/\"(.*?)\"/',$s,$ff);
10147
  if (count($ff[1])) {
10148
- foreach($ff[1] AS $ffp) {
10149
  $w = preg_split('/\s+/',$ffp);
10150
- $s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
10151
  }
10152
  }
10153
  preg_match_all('/\'(.*?)\'/',$s,$ff);
10154
  if (count($ff[1])) {
10155
- foreach($ff[1] AS $ffp) {
10156
  $w = preg_split('/\s+/',$ffp);
10157
- $s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
10158
  }
10159
  }
10160
- $s = preg_replace('/\s*,\s*/',',',$s);
10161
  $bits = preg_split('/\s+/',$s);
10162
  if (count($bits)>1) {
10163
  $k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
10164
  $fs = $bits[(count($bits)-2)];
10165
- if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
10166
  $newprop['FONT-SIZE'] = $fsp[1];
10167
  $newprop['LINE-HEIGHT'] = $fsp[2];
10168
  }
10169
- else { $newprop['FONT-SIZE'] = $fs; }
10170
  if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
10171
  else { $newprop['FONT-STYLE'] = 'normal'; }
10172
  if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
@@ -10183,11 +10182,11 @@ function fixCSS($prop) {
10183
  $fonttype = preg_replace('/ /','',$fonttype);
10184
  $v = strtolower(trim($fonttype));
10185
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
10186
- if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) ||
10187
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
10188
- ($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
10189
- in_array($v, array('sjis','uhc','big5','gb'))) {
10190
- $newprop[$k] = $v;
10191
  $found = 1;
10192
  break;
10193
  }
@@ -10199,7 +10198,7 @@ function fixCSS($prop) {
10199
  $fonttype = preg_replace('/ /','',$fonttype);
10200
  $v = strtolower(trim($fonttype));
10201
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
10202
- if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
10203
  $newprop[$k] = $v;
10204
  break;
10205
  }
@@ -10264,11 +10263,11 @@ function fixCSS($prop) {
10264
 
10265
  else if ($k == 'BORDER-SPACING') {
10266
  $prop = preg_split('/\s+/',trim($v));
10267
- if (count($prop) == 1 ) {
10268
  $newprop['BORDER-SPACING-H'] = $prop[0];
10269
  $newprop['BORDER-SPACING-V'] = $prop[0];
10270
  }
10271
- else if (count($prop) == 2 ) {
10272
  $newprop['BORDER-SPACING-H'] = $prop[0];
10273
  $newprop['BORDER-SPACING-V'] = $prop[1];
10274
  }
@@ -10316,11 +10315,11 @@ function fixCSS($prop) {
10316
  $angle = ($angle % 360);
10317
  $angle /= 90;
10318
  $angle = round($angle) * 90;
10319
- $newprop['IMAGE-ORIENTATION'] = $angle;
10320
  }
10321
  }
10322
- else {
10323
- $newprop[$k] = $v;
10324
  }
10325
  }
10326
 
@@ -10343,12 +10342,12 @@ function setCSSboxshadow($v) {
10343
  if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
10344
  if (isset($p[2])) {
10345
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
10346
- $new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10347
  }
10348
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
10349
  if (isset($p[3])) {
10350
  if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
10351
- $new['spread'] = $this->ConvertSize(trim($p[3]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10352
  }
10353
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[3])); }
10354
  if (isset($p[4])) {
@@ -10377,7 +10376,7 @@ function setCSStextshadow($v) {
10377
  if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
10378
  if (isset($p[2])) {
10379
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
10380
- $new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10381
  }
10382
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
10383
  if (isset($p[3])) {
@@ -10406,20 +10405,20 @@ function parseCSSbackground($s) {
10406
 
10407
  function expand24($mp) {
10408
  $prop = preg_split('/\s+/',trim($mp));
10409
- if (count($prop) == 1 ) {
10410
  return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
10411
  }
10412
- if (count($prop) == 2 ) {
10413
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
10414
  }
10415
 
10416
- if (count($prop) == 3 ) {
10417
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
10418
  }
10419
- if (count($prop) == 4 ) {
10420
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
10421
  }
10422
- return array();
10423
  }
10424
 
10425
 
@@ -10430,11 +10429,11 @@ function expand24($mp) {
10430
  function fixLineheight($v) {
10431
  $lh = false;
10432
  if (preg_match('/^[0-9\.,]*$/',$v) && $v >= 0) { return ($v + 0); }
10433
- else if (strtoupper($v) == 'NORMAL') {
10434
- return $this->normalLineheight;
10435
  }
10436
- else {
10437
- $tlh = $this->ConvertSize($v,$this->FontSize,$this->FontSize,true);
10438
  if ($tlh) { return ($tlh.'mm'); }
10439
  }
10440
  return $this->normalLineheight;
@@ -10454,7 +10453,7 @@ function setBorderDominance($prop, $val) {
10454
  function _mergeCSS($p, &$t) {
10455
  // Save Cascading CSS e.g. "div.topic p" at this block level
10456
  if (isset($p) && $p) {
10457
- if ($t) {
10458
  $t = $this->array_merge_recursive_unique($t, $p);
10459
  }
10460
  else { $t = $p; }
@@ -10479,7 +10478,7 @@ function array_merge_recursive_unique($array1, $array2) {
10479
  $ret[$key] = $value;
10480
  }
10481
  }
10482
- }
10483
  }
10484
  return $ret;
10485
  }
@@ -10541,8 +10540,8 @@ function _set_mergedCSS(&$m, &$p, $d=true, $bd=false) {
10541
  if (isset($m)) {
10542
  if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
10543
  if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
10544
- if (is_array($m)) {
10545
- $p = array_merge($p,$m);
10546
  $this->_mergeBorders($p,$m);
10547
  }
10548
  }
@@ -10579,7 +10578,7 @@ function _mergeBorders(&$b, &$a) { // Merges $a['BORDER-TOP-STYLE'] to $b['BORDE
10579
 
10580
  function MergeCSS($inherit,$tag,$attr) {
10581
  $p = array();
10582
- $zp = array();
10583
 
10584
  $classes = array();
10585
  if (isset($attr['CLASS'])) {
@@ -10610,7 +10609,7 @@ function MergeCSS($inherit,$tag,$attr) {
10610
  }
10611
  $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
10612
  //===============================================
10613
- // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
10614
  //===============================================
10615
  // STYLESHEET TAG e.g. table
10616
  $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
@@ -10639,7 +10638,7 @@ function MergeCSS($inherit,$tag,$attr) {
10639
  }
10640
  $this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
10641
  //===============================================
10642
- // Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS
10643
  //===============================================
10644
  // STYLESHEET TAG e.g. table
10645
  $this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
@@ -10669,13 +10668,13 @@ function MergeCSS($inherit,$tag,$attr) {
10669
 
10670
  if (isset($this->blk[$this->blklvl-1]['direction']) && $this->blk[$this->blklvl-1]['direction']) { $p['DIRECTION'] = $this->blk[$this->blklvl-1]['direction']; }
10671
 
10672
- if (isset($this->blk[$this->blklvl-1]['align']) && $this->blk[$this->blklvl-1]['align']) {
10673
- if ($this->blk[$this->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
10674
- else if ($this->blk[$this->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
10675
- else if ($this->blk[$this->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
10676
- else if ($this->blk[$this->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
10677
  }
10678
- if ($this->ColActive || $this->keep_block_together) {
10679
  if (isset($this->blk[$this->blklvl-1]['bgcolor']) && $this->blk[$this->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
10680
  $cor = $this->blk[$this->blklvl-1]['bgcolorarray' ];
10681
  $p['BACKGROUND-COLOR'] = $this->_colAtoString($cor);
@@ -10691,7 +10690,7 @@ function MergeCSS($inherit,$tag,$attr) {
10691
  if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
10692
  if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; }
10693
  if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
10694
- if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) {
10695
  $cor = $biilp[ 'colorarray' ];
10696
  $p['COLOR'] = $this->_colAtoString($cor);
10697
  }
@@ -10700,11 +10699,11 @@ function MergeCSS($inherit,$tag,$attr) {
10700
  else { $p['FONT-KERNING'] = 'none'; }
10701
  }
10702
  if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; }
10703
- if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; }
10704
  if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
10705
  else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
10706
  else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
10707
- // CSS says text-decoration is not inherited, but IE7 does??
10708
  if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
10709
  if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
10710
 
@@ -10719,7 +10718,7 @@ function MergeCSS($inherit,$tag,$attr) {
10719
  if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
10720
  if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; }
10721
  if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
10722
- if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) {
10723
  $cor = $bilp[ 'colorarray' ];
10724
  $p['COLOR'] = $this->_colAtoString($cor);
10725
  }
@@ -10744,7 +10743,7 @@ function MergeCSS($inherit,$tag,$attr) {
10744
  //===============================================
10745
  //===============================================
10746
  // DEFAULT for this TAG set in DefaultCSS
10747
- if (isset($this->defaultCSS[$tag])) {
10748
  $zp = $this->fixCSS($this->defaultCSS[$tag]);
10749
  if (is_array($zp)) { // Default overwrites Inherited
10750
  $p = array_merge($p,$zp); // !! Note other way round !!
@@ -10753,7 +10752,7 @@ function MergeCSS($inherit,$tag,$attr) {
10753
  }
10754
  //===============================================
10755
  // cellPadding overwrites TD/TH default but not specific CSS set on cell
10756
- if (($tag=='TD' || $tag=='TH') && isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']) && ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'] || $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']===0)) {
10757
  $p['PADDING-LEFT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
10758
  $p['PADDING-RIGHT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
10759
  $p['PADDING-TOP'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
@@ -10761,10 +10760,10 @@ function MergeCSS($inherit,$tag,$attr) {
10761
  }
10762
  //===============================================
10763
  // STYLESHEET TAG e.g. h1 p div table
10764
- if (isset($this->CSS[$tag]) && $this->CSS[$tag]) {
10765
  $zp = $this->CSS[$tag];
10766
- if (is_array($zp)) {
10767
- $p = array_merge($p,$zp);
10768
  $this->_mergeBorders($p,$zp);
10769
  }
10770
  }
@@ -10773,8 +10772,8 @@ function MergeCSS($inherit,$tag,$attr) {
10773
  foreach($classes AS $class) {
10774
  $zp = array();
10775
  if (isset($this->CSS['CLASS>>'.$class]) && $this->CSS['CLASS>>'.$class]) { $zp = $this->CSS['CLASS>>'.$class]; }
10776
- if (is_array($zp)) {
10777
- $p = array_merge($p,$zp);
10778
  $this->_mergeBorders($p,$zp);
10779
  }
10780
  }
@@ -10806,8 +10805,8 @@ function MergeCSS($inherit,$tag,$attr) {
10806
  if ($select) {
10807
  $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
10808
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); }
10809
- if (is_array($zp)) {
10810
- $p = array_merge($p,$zp);
10811
  $this->_mergeBorders($p,$zp);
10812
  }
10813
  }
@@ -10818,8 +10817,8 @@ function MergeCSS($inherit,$tag,$attr) {
10818
  // STYLESHEET ID e.g. #smallone{} #redletter{}
10819
  if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) {
10820
  $zp = $this->CSS['ID>>'.$attr['ID']];
10821
- if (is_array($zp)) {
10822
- $p = array_merge($p,$zp);
10823
  $this->_mergeBorders($p,$zp);
10824
  }
10825
  }
@@ -10828,8 +10827,8 @@ function MergeCSS($inherit,$tag,$attr) {
10828
  foreach($classes AS $class) {
10829
  $zp = array();
10830
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class]) && $this->CSS[$tag.'>>CLASS>>'.$class]) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
10831
- if (is_array($zp)) {
10832
- $p = array_merge($p,$zp);
10833
  $this->_mergeBorders($p,$zp);
10834
  }
10835
  }
@@ -10837,8 +10836,8 @@ function MergeCSS($inherit,$tag,$attr) {
10837
  // STYLESHEET CLASS e.g. p#smallone{} div#redletter{}
10838
  if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) {
10839
  $zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
10840
- if (is_array($zp)) {
10841
- $p = array_merge($p,$zp);
10842
  $this->_mergeBorders($p,$zp);
10843
  }
10844
  }
@@ -10910,7 +10909,7 @@ function MergeCSS($inherit,$tag,$attr) {
10910
  }
10911
  //===============================================
10912
  else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS
10913
- // false = don't check for 'depth'
10914
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false);
10915
  foreach($classes AS $class) {
10916
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false);
@@ -10926,8 +10925,8 @@ function MergeCSS($inherit,$tag,$attr) {
10926
  // INLINE STYLE e.g. style="CSS:property"
10927
  if (isset($attr['STYLE'])) {
10928
  $zp = $this->readInlineCSS($attr['STYLE']);
10929
- if (is_array($zp)) {
10930
- $p = array_merge($p,$zp);
10931
  $this->_mergeBorders($p,$zp);
10932
  }
10933
  }
@@ -10986,24 +10985,24 @@ function MergeCSS($inherit,$tag,$attr) {
10986
  function PreviewBlockCSS($tag,$attr) {
10987
  // Looks ahead from current block level to a new level
10988
  $p = array();
10989
- $zp = array();
10990
  $oldcascadeCSS = $this->blk[$this->blklvl]['cascadeCSS'];
10991
  $classes = array();
10992
  if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
10993
  //===============================================
10994
  // DEFAULT for this TAG set in DefaultCSS
10995
- if (isset($this->defaultCSS[$tag])) {
10996
  $zp = $this->fixCSS($this->defaultCSS[$tag]);
10997
  if (is_array($zp)) { $p = array_merge($zp,$p); } // Inherited overwrites default
10998
  }
10999
  // STYLESHEET TAG e.g. h1 p div table
11000
- if (isset($this->CSS[$tag])) {
11001
  $zp = $this->CSS[$tag];
11002
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11003
  }
11004
  // STYLESHEET CLASS e.g. .smallone{} .redletter{}
11005
  foreach($classes AS $class) {
11006
- $zp = array();
11007
  if (isset($this->CSS['CLASS>>'.$class])) { $zp = $this->CSS['CLASS>>'.$class]; }
11008
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11009
  }
@@ -11014,7 +11013,7 @@ function PreviewBlockCSS($tag,$attr) {
11014
  }
11015
  // STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
11016
  foreach($classes AS $class) {
11017
- $zp = array();
11018
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class])) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
11019
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11020
  }
@@ -11068,7 +11067,7 @@ function OpenTag($tag,$attr)
11068
 
11069
  // What this gets: < $tag $attr['WIDTH']="90px" > does not get content here </closeTag here>
11070
  // Correct tags where HTML specifies optional end tags,
11071
- // and/or does not allow nesting e.g. P inside P, or
11072
  if ($this->allow_html_optional_endtags) {
11073
  if (($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag=='PRE' || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DL' || $tag == 'HR' ) && $this->lastoptionaltag == 'P') { $this->CloseTag($this->lastoptionaltag ); }
11074
  if ($tag == 'DD' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); }
@@ -11091,7 +11090,7 @@ function OpenTag($tag,$attr)
11091
  //Opening tag
11092
  switch($tag){
11093
 
11094
- case 'DOTTAB':
11095
  $objattr = array();
11096
  $objattr['type'] = 'dottab';
11097
  $dots=str_repeat('.', 3)." "; // minimum number of dots
@@ -11113,7 +11112,7 @@ function OpenTag($tag,$attr)
11113
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11114
  }
11115
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11116
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11117
  }
11118
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11119
  $this->_saveCellTextBuffer($e);
@@ -11123,9 +11122,9 @@ function OpenTag($tag,$attr)
11123
  } // *TABLES*
11124
  break;
11125
 
11126
- case 'PAGEHEADER':
11127
  case 'PAGEFOOTER':
11128
- $this->ignorefollowingspaces = true;
11129
  if ($attr['NAME']) { $pname = $attr['NAME']; }
11130
  else { $pname = '_default'; }
11131
 
@@ -11135,9 +11134,9 @@ function OpenTag($tag,$attr)
11135
  $p['L']=array();
11136
  $p['C']=array();
11137
  $p['R']=array();
11138
- $p['L']['font-style'] = '';
11139
- $p['C']['font-style'] = '';
11140
- $p['R']['font-style'] = '';
11141
 
11142
  if (isset($attr['CONTENT-LEFT'])) {
11143
  $p['L']['content'] = $attr['CONTENT-LEFT'];
@@ -11152,30 +11151,30 @@ function OpenTag($tag,$attr)
11152
  if (isset($attr['HEADER-STYLE']) || isset($attr['FOOTER-STYLE'])) { // font-family,size,weight,style,color
11153
  if ($tag=='PAGEHEADER') { $properties = $this->readInlineCSS($attr['HEADER-STYLE']); }
11154
  else { $properties = $this->readInlineCSS($attr['FOOTER-STYLE']); }
11155
- if (isset($properties['FONT-FAMILY'])) {
11156
- $p['L']['font-family'] = $properties['FONT-FAMILY'];
11157
- $p['C']['font-family'] = $properties['FONT-FAMILY'];
11158
- $p['R']['font-family'] = $properties['FONT-FAMILY'];
11159
  }
11160
- if (isset($properties['FONT-SIZE'])) {
11161
- $p['L']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11162
- $p['C']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11163
- $p['R']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11164
  }
11165
  if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='bold') {
11166
- $p['L']['font-style'] = 'B';
11167
- $p['C']['font-style'] = 'B';
11168
- $p['R']['font-style'] = 'B';
11169
  }
11170
- if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') {
11171
- $p['L']['font-style'] .= 'I';
11172
- $p['C']['font-style'] .= 'I';
11173
- $p['R']['font-style'] .= 'I';
11174
  }
11175
- if (isset($properties['COLOR'])) {
11176
- $p['L']['color'] = $properties['COLOR'];
11177
- $p['C']['color'] = $properties['COLOR'];
11178
- $p['R']['color'] = $properties['COLOR'];
11179
  }
11180
  }
11181
  if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) {
@@ -11214,9 +11213,9 @@ function OpenTag($tag,$attr)
11214
 
11215
 
11216
 
11217
- case 'SETPAGEHEADER':
11218
  case 'SETPAGEFOOTER':
11219
- $this->ignorefollowingspaces = true;
11220
  if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
11221
  else { $pname = '_default'; }
11222
  if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
@@ -11275,13 +11274,13 @@ function OpenTag($tag,$attr)
11275
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
11276
  if(!empty($this->textbuffer)) { //Output previously buffered content
11277
  $this->printbuffer($this->textbuffer);
11278
- $this->textbuffer=array();
11279
  }
11280
  $this->ignorefollowingspaces = true;
11281
  $save_cols = false;
11282
 
11283
 
11284
- if (isset($attr['SHEET-SIZE']) && $tag != 'FORMFEED' && !$this->restoreBlockPageBreaks) {
11285
  // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
11286
  $prop = preg_split('/\s+/',trim($attr['SHEET-SIZE']));
11287
  if (count($prop) == 2 ) {
@@ -11344,14 +11343,14 @@ function OpenTag($tag,$attr)
11344
  // Re-open block tags
11345
  $t = $this->blk[0]['tag'];
11346
  $a = $this->blk[0]['attr'];
11347
- $this->blklvl = 0;
11348
  for ($b=0; $b<=$save_blklvl;$b++) {
11349
  $tc = $t;
11350
  $ac = $a;
11351
  $t = $this->blk[$b+1]['tag'];
11352
  $a = $this->blk[$b+1]['attr'];
11353
  unset($this->blk[$b+1]);
11354
- $this->OpenTag($tc,$ac);
11355
  }
11356
  $this->spanlvl = $save_spanlvl;
11357
  $this->InlineProperties = $save_ilp;
@@ -11393,7 +11392,7 @@ function OpenTag($tag,$attr)
11393
  if (in_array($this->FontFamily,$this->mono_fonts)) {
11394
  $this->setCSS(array('FONT-FAMILY'=>'ccourier'),'INLINE');
11395
  }
11396
- else if (in_array($this->FontFamily,$this->serif_fonts)) {
11397
  $this->setCSS(array('FONT-FAMILY'=>'ctimes'),'INLINE');
11398
  }
11399
  else {
@@ -11435,7 +11434,7 @@ function OpenTag($tag,$attr)
11435
  $this->spanlvl++;
11436
  $this->InlineProperties['SPAN'][$this->spanlvl] = $this->saveInlineProperties();
11437
  }
11438
- else {
11439
  if (!isset($this->InlineProperties[$tag])) $this->InlineProperties[$tag] = $this->saveInlineProperties(); // mPDF 5.4.13
11440
  }
11441
  $properties = $this->MergeCSS('INLINE',$tag,$attr);
@@ -11444,7 +11443,7 @@ function OpenTag($tag,$attr)
11444
 
11445
 
11446
  case 'A':
11447
- if (isset($attr['NAME']) and $attr['NAME'] != '') {
11448
  $e = '';
11449
  if($this->tableLevel) { // *TABLES*
11450
  $this->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
@@ -11453,7 +11452,7 @@ function OpenTag($tag,$attr)
11453
  $this->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
11454
  } // *TABLES*
11455
  }
11456
- if (isset($attr['HREF'])) {
11457
  $this->InlineProperties['A'] = $this->saveInlineProperties();
11458
  $properties = $this->MergeCSS('',$tag,$attr);
11459
  if (!empty($properties)) $this->setCSS($properties,'INLINE');
@@ -11480,7 +11479,7 @@ function OpenTag($tag,$attr)
11480
  if ($max < $min) { $max = $min; }
11481
 
11482
  if (isset($attr['VALUE']) && ($attr['VALUE'] || $attr['VALUE']==='0')) {
11483
- $value = $attr['VALUE'];
11484
  if ($value < $min) { $value = $min; }
11485
  else if ($value > $max) { $value = $max; }
11486
  }
@@ -11517,14 +11516,14 @@ function OpenTag($tag,$attr)
11517
  $objattr['border_right']['w'] = 0;
11518
 
11519
  $properties = $this->MergeCSS('',$tag,$attr);
11520
- if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
11521
- return;
11522
  }
11523
- $objattr['visibility'] = 'visible';
11524
  if (isset($properties['VISIBILITY'])) {
11525
  $v = strtolower($properties['VISIBILITY']);
11526
- if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
11527
- $objattr['visibility'] = $v;
11528
  }
11529
  }
11530
 
@@ -11565,8 +11564,8 @@ function OpenTag($tag,$attr)
11565
  $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
11566
 
11567
  // Image file
11568
- if (!class_exists('meter', false)) {
11569
- include(_MPDF_PATH.'classes/meter.php');
11570
  }
11571
  $this->meter = new meter();
11572
  $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
@@ -11574,14 +11573,14 @@ function OpenTag($tag,$attr)
11574
  $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.strtolower($tag).'.svg';
11575
  file_put_contents($srcpath, $svg);
11576
  $orig_srcpath = $srcpath;
11577
- $this->GetFullPath($srcpath);
11578
 
11579
  $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
11580
  if(!$info) {
11581
  $info = $this->_getImage($this->noImageFile);
11582
- if ($info) {
11583
- $srcpath = $this->noImageFile;
11584
- $w = ($info['w'] * (25.4/$this->dpi));
11585
  $h = ($info['h'] * (25.4/$this->dpi));
11586
  }
11587
  }
@@ -11595,7 +11594,7 @@ function OpenTag($tag,$attr)
11595
  $h = $this->FontSize/(10/_MPDFK) * abs($info['h'])/_MPDFK;
11596
  }
11597
  // IF WIDTH OR HEIGHT SPECIFIED
11598
- if($w==0) $w=abs($h*$info['w']/$info['h']);
11599
  if($h==0) $h=abs($w*$info['h']/$info['w']);
11600
 
11601
  // Resize to maximum dimensions of page
@@ -11650,10 +11649,10 @@ function OpenTag($tag,$attr)
11650
 
11651
  $this->_saveCellTextBuffer("\n");
11652
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
11653
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11654
  }
11655
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11656
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11657
  }
11658
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11659
  }
@@ -11663,7 +11662,7 @@ function OpenTag($tag,$attr)
11663
  }
11664
  $this->_saveTextBuffer("\n");
11665
  } // *TABLES*
11666
- $this->ignorefollowingspaces = true;
11667
  $this->blockjustfinished=false;
11668
  $this->listjustfinished=false;
11669
 
@@ -11682,7 +11681,7 @@ function OpenTag($tag,$attr)
11682
  case 'CENTER':
11683
 
11684
  case 'BLOCKQUOTE':
11685
- case 'ADDRESS':
11686
 
11687
  case 'CAPTION':
11688
  case 'P':
@@ -11710,10 +11709,10 @@ function OpenTag($tag,$attr)
11710
  case 'NAV':
11711
  case 'SECTION':
11712
  $p = $this->PreviewBlockCSS($tag,$attr);
11713
- if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') {
11714
  $this->blklvl++;
11715
- $this->blk[$this->blklvl]['hide'] = true;
11716
- return;
11717
  }
11718
  if($tag == 'CAPTION') {
11719
  // position is written in AdjstHTML
@@ -11725,15 +11724,15 @@ function OpenTag($tag,$attr)
11725
  if (isset($attr['ALIGN'])) { unset($attr['ALIGN']); }
11726
  if ($cappos != $divpos) {
11727
  $this->blklvl++;
11728
- $this->blk[$this->blklvl]['hide'] = true;
11729
- return;
11730
  }
11731
  }
11732
 
11733
 
11734
 
11735
  // Start Block
11736
- $this->ignorefollowingspaces = true;
11737
 
11738
  if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
11739
  else { $lastbottommargin = 0; }
@@ -11742,7 +11741,7 @@ function OpenTag($tag,$attr)
11742
 
11743
  if ($this->listlvl>0) { return; }
11744
 
11745
- $this->InlineProperties = array();
11746
  $this->spanlvl = 0;
11747
  $this->listjustfinished=false;
11748
  $this->divbegin=true;
@@ -11758,7 +11757,7 @@ function OpenTag($tag,$attr)
11758
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11759
  }
11760
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11761
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11762
  }
11763
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11764
  }
@@ -11798,7 +11797,7 @@ function OpenTag($tag,$attr)
11798
 
11799
  $this->Reset();
11800
  $properties = $this->MergeCSS('BLOCK',$tag,$attr);
11801
- $pagesel = '';
11802
 
11803
  // If page-box has changed AND/OR PAGE-BREAK-BEFORE
11804
  $save_cols = false;
@@ -11831,7 +11830,7 @@ function OpenTag($tag,$attr)
11831
  $this->blk[0]['inner_width'] =& $this->pgwidth;
11832
  $this->blk[0]['blockContext'] = $this->blockContext;
11833
  $properties = $this->MergeCSS('BLOCK','BODY','');
11834
- $this->setCSS($properties,'','BODY');
11835
  $this->blklvl++;
11836
  $currblk =& $this->blk[$this->blklvl];
11837
  $prevblk =& $this->blk[$this->blklvl-1];
@@ -11848,14 +11847,14 @@ function OpenTag($tag,$attr)
11848
  // Re-open block tags
11849
  $t = $this->blk[0]['tag'];
11850
  $a = $this->blk[0]['attr'];
11851
- $this->blklvl = 0;
11852
  for ($b=0; $b<=$save_blklvl;$b++) {
11853
  $tc = $t;
11854
  $ac = $a;
11855
  $t = $this->blk[$b+1]['tag'];
11856
  $a = $this->blk[$b+1]['attr'];
11857
  unset($this->blk[$b+1]);
11858
- $this->OpenTag($tc,$ac);
11859
  }
11860
  $this->spanlvl = $save_spanlvl;
11861
  $this->InlineProperties = $save_ilp;
@@ -11881,9 +11880,9 @@ function OpenTag($tag,$attr)
11881
 
11882
  // mPDF 5.6.01 - LAYERS
11883
  if (isset($properties['Z-INDEX']) && $this->currentlayer==0) {
11884
- $v = intval($properties['Z-INDEX']);
11885
  if ($v > 0) {
11886
- $currblk['z-index'] = $v;
11887
  $this->BeginLayer($v);
11888
  }
11889
  }
@@ -11893,8 +11892,8 @@ function OpenTag($tag,$attr)
11893
 
11894
  if (isset($properties['VISIBILITY'])) {
11895
  $v = strtolower($properties['VISIBILITY']);
11896
- if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible' && !$this->tableLevel) {
11897
- $currblk['visibility'] = $v;
11898
  $this->SetVisibility($v);
11899
  }
11900
  }
@@ -11902,8 +11901,8 @@ function OpenTag($tag,$attr)
11902
  if(isset($attr['DIR']) && $attr['DIR']) { $currblk['direction'] = strtolower($attr['DIR']); }
11903
  if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; }
11904
 
11905
- if (isset($properties['HEIGHT'])) {
11906
- $currblk['css_set_height'] = $this->ConvertSize($properties['HEIGHT'],($this->h - $this->tMargin - $this->bMargin),$this->FontSize,false);
11907
  if (($currblk['css_set_height'] + $this->y) > $this->PageBreakTrigger && $this->y > $this->tMargin+5 && $currblk['css_set_height'] < ($this->h - ($this->tMargin + $this->bMargin))) { $this->AddPage($this->CurOrientation); }
11908
  }
11909
  else { $currblk['css_set_height'] = false; }
@@ -11928,14 +11927,14 @@ function OpenTag($tag,$attr)
11928
  // Hanging indent - if negative indent: ensure padding is >= indent
11929
  if(!isset($currblk['text_indent'])) { $currblk['text_indent'] = null; }
11930
  if(!isset($currblk['inner_width'])) { $currblk['inner_width'] = null; }
11931
- $cbti = $this->ConvertSize($currblk['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
11932
  if ($cbti < 0) {
11933
  $hangind = -($cbti);
11934
  $currblk['padding_left'] = max($currblk['padding_left'],$hangind);
11935
  }
11936
 
11937
  if (isset($currblk['css_set_width'])) {
11938
- if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') {
11939
  // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width)
11940
  $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
11941
  if ($anyextra>0) {
@@ -11945,21 +11944,21 @@ function OpenTag($tag,$attr)
11945
  $currblk['margin_left'] = $currblk['margin_right'] = 0;
11946
  }
11947
  }
11948
- else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
11949
  // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
11950
  $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']);
11951
  if ($currblk['margin_left'] < 0) {
11952
  $currblk['margin_left'] = 0;
11953
  }
11954
  }
11955
- else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
11956
  // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
11957
  $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
11958
  if ($currblk['margin_right'] < 0) {
11959
  $currblk['margin_right'] = 0;
11960
  }
11961
  }
11962
- else {
11963
  // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
11964
  // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
11965
  $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
@@ -12008,8 +12007,8 @@ function OpenTag($tag,$attr)
12008
  $this->kwt_BMoutlines = array();
12009
  $this->kwt_toc = array();
12010
  }
12011
- else {
12012
- $this->kwt = false;
12013
  } // *TABLES*
12014
 
12015
  //Save x,y coords in case we need to print borders...
@@ -12028,7 +12027,7 @@ function OpenTag($tag,$attr)
12028
  $properties = $this->readInlineCSS($attr['STYLE']);
12029
  }
12030
 
12031
- $this->ignorefollowingspaces = true;
12032
 
12033
  $objattr = array();
12034
  $objattr['margin_top'] = 0;
@@ -12047,12 +12046,12 @@ function OpenTag($tag,$attr)
12047
  if (isset($properties['WIDTH'])) { $objattr['width'] = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']); }
12048
  if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
12049
 
12050
- if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12051
  $objattr['align'] = 'R';
12052
  }
12053
- if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12054
  $objattr['align'] = 'L';
12055
- if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12056
  $objattr['align'] = 'C';
12057
  }
12058
  }
@@ -12065,12 +12064,12 @@ function OpenTag($tag,$attr)
12065
 
12066
  if ($this->tableLevel) {
12067
  $objattr['W-PERCENT'] = 100;
12068
- if (isset($properties['WIDTH']) && stristr($properties['WIDTH'],'%')) {
12069
- $properties['WIDTH'] += 0; //make "90%" become simply "90"
12070
  $objattr['W-PERCENT'] = $properties['WIDTH'];
12071
  }
12072
- if (isset($attr['WIDTH']) && stristr($attr['WIDTH'],'%')) {
12073
- $attr['WIDTH'] += 0; //make "90%" become simply "90"
12074
  $objattr['W-PERCENT'] = $attr['WIDTH'];
12075
  }
12076
  }
@@ -12088,7 +12087,7 @@ function OpenTag($tag,$attr)
12088
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
12089
  }
12090
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
12091
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
12092
  }
12093
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
12094
  $this->_saveCellTextBuffer($e, $this->HREF);
@@ -12116,15 +12115,15 @@ function OpenTag($tag,$attr)
12116
  $this->graphs[$gid]['attr'] = $attr;
12117
 
12118
 
12119
- if (isset($this->graphs[$gid]['attr']['WIDTH']) && $this->graphs[$gid]['attr']['WIDTH']) {
12120
- $this->graphs[$gid]['attr']['cWIDTH']=$this->ConvertSize($this->graphs[$gid]['attr']['WIDTH'],$pgwidth);
12121
  } // mm
12122
- if (isset($this->graphs[$gid]['attr']['HEIGHT']) && $this->graphs[$gid]['attr']['HEIGHT']) {
12123
- $this->graphs[$gid]['attr']['cHEIGHT']=$this->ConvertSize($this->graphs[$gid]['attr']['HEIGHT'],$pgwidth);
12124
  }
12125
 
12126
  $graph_img = print_graph($this->graphs[$gid],$this->blk[$this->blklvl]['inner_width']);
12127
- if ($graph_img) {
12128
  if(isset($attr['ROTATE'])) {
12129
  if ($attr['ROTATE']==90 || $attr['ROTATE']==-90) {
12130
  $tmpw = $graph_img['w'];
@@ -12132,9 +12131,9 @@ function OpenTag($tag,$attr)
12132
  $graph_img['h']= $tmpw;
12133
  }
12134
  }
12135
- $attr['SRC'] = $graph_img['file'];
12136
- $attr['WIDTH'] = $graph_img['w'];
12137
- $attr['HEIGHT'] = $graph_img['h'];
12138
  }
12139
  else { break; }
12140
 
@@ -12159,22 +12158,22 @@ function OpenTag($tag,$attr)
12159
  $srcpath = $attr['SRC'];
12160
  $orig_srcpath = $attr['ORIG_SRC'];
12161
  $properties = $this->MergeCSS('',$tag,$attr);
12162
- if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
12163
- return;
12164
  }
12165
  // mPDF 5.6.01 - LAYERS
12166
  if (isset($properties['Z-INDEX']) && $this->currentlayer==0) {
12167
- $v = intval($properties['Z-INDEX']);
12168
  if ($v > 0) {
12169
- $objattr['z-index'] = $v;
12170
  }
12171
  }
12172
 
12173
- $objattr['visibility'] = 'visible';
12174
  if (isset($properties['VISIBILITY'])) {
12175
  $v = strtolower($properties['VISIBILITY']);
12176
- if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
12177
- $objattr['visibility'] = $v;
12178
  }
12179
  }
12180
 
@@ -12226,9 +12225,9 @@ function OpenTag($tag,$attr)
12226
  $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
12227
  if(!$info) {
12228
  $info = $this->_getImage($this->noImageFile);
12229
- if ($info) {
12230
- $srcpath = $this->noImageFile;
12231
- $w = ($info['w'] * (25.4/$this->dpi));
12232
  $h = ($info['h'] * (25.4/$this->dpi));
12233
  }
12234
  }
@@ -12249,7 +12248,7 @@ function OpenTag($tag,$attr)
12249
  $objattr['file'] = $srcpath;
12250
  //Default width and height calculation if needed
12251
  if($w==0 and $h==0) {
12252
- if ($info['type']=='svg') {
12253
  // SVG units are pixels
12254
  $w = abs($info['w'])/_MPDFK;
12255
  $h = abs($info['h'])/_MPDFK;
@@ -12259,13 +12258,13 @@ function OpenTag($tag,$attr)
12259
  $w=($info['w']/_MPDFK) * (72/$this->img_dpi);
12260
  $h=($info['h']/_MPDFK) * (72/$this->img_dpi);
12261
  }
12262
- if (isset($properties['IMAGE-RESOLUTION'])) {
12263
  if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi']>0) {
12264
  $w *= $this->img_dpi / $info['set-dpi'];
12265
  $h *= $this->img_dpi / $info['set-dpi'];
12266
  }
12267
  else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
12268
- $dpi = $m[1];
12269
  if ($dpi > 0) {
12270
  $w *= $this->img_dpi / $dpi;
12271
  $h *= $this->img_dpi / $dpi;
@@ -12274,7 +12273,7 @@ function OpenTag($tag,$attr)
12274
  }
12275
  }
12276
  // IF WIDTH OR HEIGHT SPECIFIED
12277
- if($w==0) $w=abs($h*$info['w']/$info['h']);
12278
  if($h==0) $h=abs($w*$info['h']/$info['w']);
12279
 
12280
  // mPDF 5.5.15
@@ -12353,35 +12352,35 @@ function OpenTag($tag,$attr)
12353
  $this->InlineProperties[$tag] = $this->saveInlineProperties();
12354
  $properties = $this->MergeCSS('INLINE',$tag,$attr);
12355
 
12356
- if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
12357
- return;
12358
  }
12359
  if (isset($attr['R'])) { $objattr['r']=$this->ConvertSize($attr['R'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
12360
- if(isset($attr['TOP-TEXT'])) {
12361
  $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
12362
  $objattr['top-text'] = $this->lesser_entity_decode($objattr['top-text']);
12363
  if ($this->onlyCoreFonts)
12364
- $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mb_enc,'UTF-8');
12365
  }
12366
- if(isset($attr['BOTTOM-TEXT'])) {
12367
  $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
12368
  $objattr['bottom-text'] = $this->lesser_entity_decode($objattr['bottom-text']);
12369
  if ($this->onlyCoreFonts)
12370
- $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mb_enc,'UTF-8');
12371
  }
12372
  if(isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) { $objattr['space-width'] = $attr['SPACE-WIDTH']; }
12373
  if(isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) { $objattr['char-width'] = $attr['CHAR-WIDTH']; }
12374
 
12375
  // VISIBILITY
12376
- $objattr['visibility'] = 'visible';
12377
  if (isset($properties['VISIBILITY'])) {
12378
  $v = strtolower($properties['VISIBILITY']);
12379
- if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
12380
- $objattr['visibility'] = $v;
12381
  }
12382
  }
12383
  // mPDF 5.5.23
12384
- if (isset($properties['FONT-SIZE'])) {
12385
  if (strtolower($properties['FONT-SIZE'])=='auto') {
12386
  if ($objattr['top-text'] && $objattr['bottom-text']) {
12387
  $objattr['fontsize'] = -2;
@@ -12401,7 +12400,7 @@ function OpenTag($tag,$attr)
12401
  $objattr['divider'] = strcode2utf($attr['DIVIDER']);
12402
  $objattr['divider'] = $this->lesser_entity_decode($objattr['divider']);
12403
  if ($this->onlyCoreFonts)
12404
- $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mb_enc,'UTF-8');
12405
 
12406
  }
12407
 
@@ -12415,7 +12414,7 @@ function OpenTag($tag,$attr)
12415
  if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $objattr['fontstyle'] .= 'I'; }
12416
  }
12417
 
12418
- if (isset($properties['FONT-FAMILY'])) {
12419
  $this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
12420
  }
12421
  $objattr['fontfamily'] = $this->FontFamily;
@@ -12519,8 +12518,8 @@ function OpenTag($tag,$attr)
12519
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['levelid'] = $this->tbctr[$this->tableLevel];
12520
 
12521
  if ($this->tableLevel > $this->innermostTableLevel) { $this->innermostTableLevel = $this->tableLevel; }
12522
- if ($this->tableLevel > 1) {
12523
- $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nestedpos'] = array($this->row,$this->col,$this->tbctr[($this->tableLevel-1)]);
12524
  }
12525
  //++++++++++++++++++++++++++++
12526
 
@@ -12585,15 +12584,15 @@ function OpenTag($tag,$attr)
12585
  $this->lastblockbottommargin = 0;
12586
  $this->blockjustfinished=false;
12587
 
12588
- if ($this->tableLevel==1) {
12589
  $this->tableCJK = false;
12590
  $this->table_lineheight = $this->normalLineheight;
12591
  $table['headernrows'] = 0;
12592
- $table['footernrows'] = 0;
12593
  $this->base_table_properties = array();
12594
  }
12595
 
12596
- // ADDED CSS FUNCIONS FOR TABLE
12597
  if ($this->tbCSSlvl==1) {
12598
  $properties = $this->MergeCSS('TOPTABLE',$tag,$attr);
12599
  }
@@ -12611,17 +12610,17 @@ function OpenTag($tag,$attr)
12611
  else if (isset($properties['BACKGROUND'])) { $table['bgcolor'][-1] = $properties['BACKGROUND']; }
12612
  if (isset($properties['VERTICAL-ALIGN'])) { $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
12613
  if (isset($properties['TEXT-ALIGN'])) { $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
12614
- if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->tableLevel ==1) {
12615
- $this->shrink_this_table_to_fit = $properties['AUTOSIZE'];
12616
  if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 0; }
12617
  }
12618
- if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->tableLevel ==1) {
12619
- $this->table_rotate = $properties['ROTATE'];
12620
  }
12621
  if (isset($properties['TOPNTAIL'])) { $table['topntail'] = $properties['TOPNTAIL']; }
12622
  if (isset($properties['THEAD-UNDERLINE'])) { $table['thead-underline'] = $properties['THEAD-UNDERLINE']; }
12623
 
12624
- if (isset($properties['BORDER'])) {
12625
  $bord = $this->border_details($properties['BORDER']);
12626
  if ($bord['s']) {
12627
  $table['border'] = _BORDER_ALL;
@@ -12631,21 +12630,21 @@ function OpenTag($tag,$attr)
12631
  $table['border_details']['B'] = $bord;
12632
  }
12633
  }
12634
- if (isset($properties['BORDER-RIGHT'])) {
12635
  $table['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
12636
- $this->setBorder($table['border'], _BORDER_RIGHT, $table['border_details']['R']['s']);
12637
  }
12638
- if (isset($properties['BORDER-LEFT'])) {
12639
  $table['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
12640
- $this->setBorder($table['border'], _BORDER_LEFT, $table['border_details']['L']['s']);
12641
  }
12642
- if (isset($properties['BORDER-BOTTOM'])) {
12643
  $table['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
12644
- $this->setBorder($table['border'], _BORDER_BOTTOM, $table['border_details']['B']['s']);
12645
  }
12646
- if (isset($properties['BORDER-TOP'])) {
12647
  $table['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
12648
- $this->setBorder($table['border'], _BORDER_TOP, $table['border_details']['T']['s']);
12649
  }
12650
  if ($table['border']){
12651
  $this->table_border_css_set = 1;
@@ -12654,13 +12653,13 @@ function OpenTag($tag,$attr)
12654
  $this->table_border_css_set = 0;
12655
  }
12656
 
12657
- if (isset($properties['FONT-FAMILY'])) {
12658
  $this->default_font = $properties['FONT-FAMILY'];
12659
  $this->SetFont($this->default_font,'',0,false);
12660
  }
12661
  $this->base_table_properties['FONT-FAMILY'] = $this->FontFamily; // mPDF 5.4.10
12662
 
12663
- if (isset($properties['FONT-SIZE'])) {
12664
  // mPDF 5.4.10
12665
  if ($this->tableLevel>1) { $mmsize = $this->ConvertSize($properties['FONT-SIZE'], $this->base_table_properties['FONT-SIZE']); }
12666
  else { $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK); }
@@ -12690,84 +12689,84 @@ function OpenTag($tag,$attr)
12690
  $this->base_table_properties['WORD-SPACING'] = $properties['WORD-SPACING'];
12691
  }
12692
 
12693
- if (isset($properties['PADDING-LEFT'])) {
12694
  $table['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12695
  }
12696
- if (isset($properties['PADDING-RIGHT'])) {
12697
  $table['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12698
  }
12699
- if (isset($properties['PADDING-TOP'])) {
12700
  $table['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12701
  }
12702
- if (isset($properties['PADDING-BOTTOM'])) {
12703
  $table['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12704
  }
12705
 
12706
- if (isset($properties['MARGIN-TOP'])) {
12707
- if ($lastbottommargin) {
12708
  $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12709
  if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
12710
  else { $properties['MARGIN-TOP'] = 0; }
12711
  }
12712
- $table['margin']['T'] = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12713
  }
12714
 
12715
- if (isset($properties['MARGIN-BOTTOM'])) {
12716
- $table['margin']['B'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12717
  }
12718
  if (isset($properties['MARGIN-LEFT'])) {
12719
- $table['margin']['L'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12720
  }
12721
 
12722
  if (isset($properties['MARGIN-RIGHT'])) {
12723
- $table['margin']['R'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12724
  }
12725
- if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12726
- $table['a'] = 'C';
12727
  }
12728
- else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12729
- $table['a'] = 'R';
12730
  }
12731
- else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12732
- $table['a'] = 'L';
12733
  }
12734
 
12735
- if (isset($properties['LINE-HEIGHT']) && $this->tableLevel==1) {
12736
  $this->table_lineheight = $this->fixLineheight($properties['LINE-HEIGHT']);
12737
  if (!$this->table_lineheight) { $this->table_lineheight = $this->normalLineheight; }
12738
  }
12739
 
12740
- if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE'])=='SEPARATE') {
12741
- $table['borders_separate'] = true;
12742
  }
12743
- else {
12744
- $table['borders_separate'] = false;
12745
  }
12746
 
12747
- if (isset($properties['BORDER-SPACING-H'])) {
12748
- $table['border_spacing_H'] = $this->ConvertSize($properties['BORDER-SPACING-H'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12749
  }
12750
- if (isset($properties['BORDER-SPACING-V'])) {
12751
- $table['border_spacing_V'] = $this->ConvertSize($properties['BORDER-SPACING-V'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12752
  }
12753
 
12754
- if (isset($properties['EMPTY-CELLS'])) {
12755
  $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
12756
  }
12757
- else { $table['empty_cells'] = ''; }
12758
 
12759
  if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE'])=='AVOID' && $this->tableLevel==1 && !$this->writingHTMLfooter) {
12760
- $this->table_keep_together = true;
12761
  }
12762
- else if ($this->tableLevel==1) {
12763
- $this->table_keep_together = false;
12764
  }
12765
  if (isset($properties['PAGE-BREAK-AFTER']) && $this->tableLevel==1) {
12766
  $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
12767
  }
12768
 
12769
 
12770
- if (isset($properties['OVERFLOW'])) {
12771
  $table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
12772
  if (($this->ColActive || $this->tableLevel>1) && $table['overflow']=='visible') { unset($table['overflow']); }
12773
  }
@@ -12775,8 +12774,8 @@ function OpenTag($tag,$attr)
12775
  $properties = array();
12776
 
12777
  if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; }
12778
- else if (isset($attr['CELLSPACING'])) {
12779
- $table['border_spacing_H'] = $table['border_spacing_V'] = $this->ConvertSize($attr['CELLSPACING'],$this->blk[$this->blklvl]['inner_width']);
12780
  }
12781
 
12782
 
@@ -12802,7 +12801,7 @@ function OpenTag($tag,$attr)
12802
  $this->table_border_attr_set = 0;
12803
  }
12804
  if (isset($attr['ALIGN'])) { $table['a'] = $align[strtolower($attr['ALIGN'])]; }
12805
- if (!$table['a']) {
12806
  if ($table['direction'] == 'rtl' ) { $table['a'] = 'R'; }
12807
  else { $table['a'] = 'L'; }
12808
  }
@@ -12811,19 +12810,19 @@ function OpenTag($tag,$attr)
12811
  if (isset($attr['WIDTH']) && $attr['WIDTH']) { $w = $attr['WIDTH']; }
12812
  if ($w) { // set here or earlier in $properties
12813
  $maxwidth = $this->blk[$this->blklvl]['inner_width'];
12814
- if ($table['borders_separate']) {
12815
  $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['border_details']['L']['w']/2 + $table['border_details']['R']['w']/2;
12816
  }
12817
- else {
12818
  $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2;
12819
  }
12820
- if (strpos($w,'%') && $this->tableLevel == 1 && !$this->ignore_table_percents ) {
12821
  // % needs to be of inner box without table margins etc.
12822
  $maxwidth -= $tblblw ;
12823
  $wmm = $this->ConvertSize($w,$maxwidth,$this->FontSize,false);
12824
  $table['w'] = $wmm + $tblblw ;
12825
  }
12826
- if (strpos($w,'%') && $this->tableLevel > 1 && !$this->ignore_table_percents && $this->keep_table_proportions) {
12827
  $table['wpercent'] = $w + 0; // makes 80% -> 80
12828
  }
12829
  if (!strpos($w,'%') && !$this->ignore_table_widths ) {
@@ -12835,12 +12834,12 @@ function OpenTag($tag,$attr)
12835
  }
12836
  }
12837
 
12838
- if (isset($attr['AUTOSIZE']) && $this->tableLevel==1) {
12839
- $this->shrink_this_table_to_fit = $attr['AUTOSIZE'];
12840
  if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 1; }
12841
  }
12842
- if (isset($attr['ROTATE']) && $this->tableLevel==1) {
12843
- $this->table_rotate = $attr['ROTATE'];
12844
  }
12845
 
12846
  //++++++++++++++++++++++++++++
@@ -12866,7 +12865,7 @@ function OpenTag($tag,$attr)
12866
  $this->kwt_saved = true;
12867
  }
12868
 
12869
- if ($this->tableLevel==1 && $this->useGraphs) {
12870
  if (isset($attr['ID']) && $attr['ID']) { $this->currentGraphId = strtoupper($attr['ID']); }
12871
  else { $this->currentGraphId = '0'; }
12872
  $this->graphs[$this->currentGraphId] = array();
@@ -12880,7 +12879,7 @@ function OpenTag($tag,$attr)
12880
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12881
  $this->tbCSSlvl++;
12882
  $this->tablethead = 1;
12883
- $this->tabletfoot = 0;
12884
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12885
  if (isset($properties['FONT-WEIGHT'])) {
12886
  if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->thead_font_weight = 'B'; }
@@ -12908,7 +12907,7 @@ function OpenTag($tag,$attr)
12908
  case 'TFOOT':
12909
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12910
  $this->tbCSSlvl++;
12911
- $this->tabletfoot = 1;
12912
  $this->tablethead = 0;
12913
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12914
  if (isset($properties['FONT-WEIGHT'])) {
@@ -12920,7 +12919,7 @@ function OpenTag($tag,$attr)
12920
  if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->tfoot_font_style = 'I'; }
12921
  else { $this->tfoot_font_style = ''; }
12922
  }
12923
- if (isset($properties['FONT-VARIANT'])) {
12924
  if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->tfoot_font_smCaps = 'S'; }
12925
  else { $this->tfoot_font_smCaps = ''; }
12926
  }
@@ -12952,7 +12951,7 @@ function OpenTag($tag,$attr)
12952
  $this->col = -1;
12953
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12954
 
12955
- if (!$this->simpleTables && (!isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate']) || !$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate'])) {
12956
  if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-left'][$this->row] = $properties['BORDER-LEFT']; }
12957
  if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row] = $properties['BORDER-RIGHT']; }
12958
  if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-top'][$this->row] = $properties['BORDER-TOP']; }
@@ -12979,7 +12978,7 @@ function OpenTag($tag,$attr)
12979
 
12980
  case 'TH':
12981
  case 'TD':
12982
- $this->ignorefollowingspaces = true;
12983
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12984
  $this->tbCSSlvl++;
12985
  $this->InlineProperties = array();
@@ -13057,34 +13056,34 @@ function OpenTag($tag,$attr)
13057
  $c['border_details']['L'] = $table['border_details']['L'];
13058
  $c['border_details']['T'] = $table['border_details']['T'];
13059
  $c['border_details']['B'] = $table['border_details']['B'];
13060
- $c['border'] = $table['border'];
13061
- $c['border_details']['L']['dom'] = 1;
13062
- $c['border_details']['R']['dom'] = 1;
13063
- $c['border_details']['T']['dom'] = 1;
13064
- $c['border_details']['B']['dom'] = 1;
13065
  }
13066
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13067
  $table['simple']['border_details']['R'] = $table['border_details']['R'];
13068
  $table['simple']['border_details']['L'] = $table['border_details']['L'];
13069
  $table['simple']['border_details']['T'] = $table['border_details']['T'];
13070
  $table['simple']['border_details']['B'] = $table['border_details']['B'];
13071
- $table['simple']['border'] = $table['border'];
13072
  }
13073
  }
13074
- }
13075
  // INHERITED THEAD CSS Properties
13076
- if ($this->tablethead) {
13077
- if ($this->thead_valign_default) $c['va'] = $align[strtolower($this->thead_valign_default)];
13078
- if ($this->thead_textalign_default) $c['a'] = $align[strtolower($this->thead_textalign_default)];
13079
  if ($this->thead_font_weight == 'B') { $this->SetStyle('B',true); }
13080
  if ($this->thead_font_style == 'I') { $this->SetStyle('I',true); }
13081
  if ($this->thead_font_smCaps == 'S') { $this->SetStyle('S',true); }
13082
  }
13083
 
13084
  // INHERITED TFOOT CSS Properties
13085
- if ($this->tabletfoot) {
13086
- if ($this->tfoot_valign_default) $c['va'] = $align[strtolower($this->tfoot_valign_default)];
13087
- if ($this->tfoot_textalign_default) $c['a'] = $align[strtolower($this->tfoot_textalign_default)];
13088
  if ($this->tfoot_font_weight == 'B') { $this->SetStyle('B',true); }
13089
  if ($this->tfoot_font_style == 'I') { $this->SetStyle('I',true); }
13090
  if ($this->tfoot_font_style == 'S') { $this->SetStyle('S',true); }
@@ -13092,13 +13091,13 @@ function OpenTag($tag,$attr)
13092
 
13093
 
13094
  if ($this->trow_text_rotate){
13095
- $c['R'] = $this->trow_text_rotate;
13096
  }
13097
 
13098
- $this->cell_border_dominance_L = 0;
13099
- $this->cell_border_dominance_R = 0;
13100
- $this->cell_border_dominance_T = 0;
13101
- $this->cell_border_dominance_B = 0;
13102
 
13103
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
13104
  $properties = $this->array_merge_recursive_unique($this->base_table_properties, $properties);
@@ -13110,18 +13109,18 @@ function OpenTag($tag,$attr)
13110
 
13111
  if (isset($properties['LETTER-SPACING']) && ($properties['LETTER-SPACING'] || $properties['LETTER-SPACING']==='0') && strtoupper($properties['LETTER-SPACING']) != 'NORMAL') {
13112
  $this->lSpacingCSS = strtoupper($properties['LETTER-SPACING']);
13113
- $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
13114
  }
13115
- else {
13116
  $this->lSpacingCSS = '';
13117
- $this->fixedlSpacing = false;
13118
  }
13119
- if (isset($properties['WORD-SPACING']) && strtoupper($properties['WORD-SPACING']) != 'NORMAL') {
13120
  $this->wSpacingCSS = strtoupper($properties['WORD-SPACING']);
13121
- $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
13122
  }
13123
- else {
13124
- $this->minwSpacing = 0;
13125
  $this->wSpacingCSS = '';
13126
  }
13127
 
@@ -13133,9 +13132,9 @@ function OpenTag($tag,$attr)
13133
  if (isset($properties['TEXT-ALIGN'])) { $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
13134
 
13135
  if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE']==="0")){
13136
- $c['R'] = $properties['TEXT-ROTATE'];
13137
  }
13138
- if (isset($properties['BORDER'])) {
13139
  $bord = $this->border_details($properties['BORDER']);
13140
  if ($bord['s']) {
13141
  if (!$this->simpleTables){
@@ -13144,10 +13143,10 @@ function OpenTag($tag,$attr)
13144
  $c['border_details']['L'] = $bord;
13145
  $c['border_details']['T'] = $bord;
13146
  $c['border_details']['B'] = $bord;
13147
- $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
13148
- $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
13149
- $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
13150
- $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
13151
  }
13152
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13153
  $table['simple']['border'] = _BORDER_ALL;
@@ -13159,29 +13158,29 @@ function OpenTag($tag,$attr)
13159
  }
13160
  }
13161
  if (!$this->simpleTables){
13162
- if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
13163
  $c['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
13164
- $this->setBorder($c['border'], _BORDER_RIGHT, $c['border_details']['R']['s']);
13165
- $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
13166
  }
13167
- if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
13168
  $c['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
13169
- $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
13170
- $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
13171
  }
13172
- if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
13173
  $c['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
13174
- $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
13175
- $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
13176
  }
13177
- if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
13178
  $c['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
13179
- $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
13180
- $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
13181
  }
13182
  }
13183
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13184
- if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
13185
  $bord = $this->border_details($properties['BORDER-LEFT']);
13186
  if ($bord['s']) { $table['simple']['border'] = _BORDER_ALL; }
13187
  else { $table['simple']['border'] = 0; }
@@ -13194,20 +13193,20 @@ function OpenTag($tag,$attr)
13194
 
13195
  if ($this->simpleTables && $this->row==0 && $this->col==0 && !$table['borders_separate'] && $table['simple']['border'] ){
13196
  $table['border_details'] = $table['simple']['border_details'];
13197
- $table['border'] = $table['simple']['border'];
13198
  }
13199
 
13200
  // Border set on TR (if collapsed only)
13201
  if (!$table['borders_separate'] && !$this->simpleTables && isset($table['trborder-left'][$this->row])) {
13202
- if ($this->col==0) {
13203
  $left = $this->border_details($table['trborder-left'][$this->row]);
13204
  $c['border_details']['L'] = $left;
13205
- $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
13206
  }
13207
  $c['border_details']['B'] = $this->border_details($table['trborder-bottom'][$this->row]);
13208
- $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
13209
  $c['border_details']['T'] = $this->border_details($table['trborder-top'][$this->row]);
13210
- $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
13211
  }
13212
 
13213
  if ($this->packTableData && !$this->simpleTables) {
@@ -13216,23 +13215,23 @@ function OpenTag($tag,$attr)
13216
  unset($c['border_details']);
13217
  }
13218
 
13219
- if (isset($properties['PADDING-LEFT'])) {
13220
  $c['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13221
  }
13222
- if (isset($properties['PADDING-RIGHT'])) {
13223
  $c['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13224
  }
13225
- if (isset($properties['PADDING-BOTTOM'])) {
13226
  $c['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13227
  }
13228
- if (isset($properties['PADDING-TOP'])) {
13229
  $c['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13230
  }
13231
 
13232
  $w = '';
13233
  if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
13234
  if (isset($attr['WIDTH'])) { $w = $attr['WIDTH']; }
13235
- if ($w) {
13236
  if (strpos($w,'%') && !$this->ignore_table_percents ) { $c['wpercent'] = $w + 0; } // makes 80% -> 80
13237
  else if (!strpos($w,'%') && !$this->ignore_table_widths ) { $c['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
13238
  }
@@ -13241,15 +13240,15 @@ function OpenTag($tag,$attr)
13241
 
13242
  if (isset($properties['COLOR'])) {
13243
  $cor = $this->ConvertColor($properties['COLOR']);
13244
- if ($cor) {
13245
  $this->colorarray = $cor;
13246
- $this->SetTColor($cor);
13247
  }
13248
  }
13249
  if (isset($properties['FONT-FAMILY'])) {
13250
  $this->SetFont($properties['FONT-FAMILY'],'',0,false);
13251
  }
13252
- if (isset($properties['FONT-SIZE'])) {
13253
  $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
13254
  if ($mmsize) {
13255
  $this->SetFontSize($mmsize*(_MPDFK),false);
@@ -13297,7 +13296,7 @@ function OpenTag($tag,$attr)
13297
 
13298
  if (isset($attr['BGCOLOR'])) $c['bgcolor'] = $attr['BGCOLOR'];
13299
  if (isset($attr['TEXT-ROTATE'])) {
13300
- $c['R'] = $attr['TEXT-ROTATE'];
13301
  }
13302
  if (isset($attr['NOWRAP']) && $attr['NOWRAP']) $c['nowrap']= 1;
13303
 
@@ -13307,8 +13306,8 @@ function OpenTag($tag,$attr)
13307
 
13308
  $cs = $rs = 1;
13309
  if (isset($attr['COLSPAN']) && $attr['COLSPAN']>1) $cs = $this->cell[$this->row][$this->col]['colspan'] = $attr['COLSPAN'];
13310
- if ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] < $this->col+$cs) {
13311
- $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] = $this->col+$cs;
13312
  } // following code moved outside if...
13313
  for($l=$this->col; $l < $this->col+$cs ;$l++) {
13314
  if ($l-$this->col) $this->cell[$this->row][$l] = 0;
@@ -13337,7 +13336,7 @@ function OpenTag($tag,$attr)
13337
  $this->lastoptionaltag = ''; // Save current HTML specified optional endtag
13338
  $this->listCSSlvl++;
13339
  if((!$this->tableLevel) && ($this->listlvl == 0)) {
13340
- $blockstate = 0;
13341
  //if ($this->lastblocklevelchange == 1) { $blockstate = -1; } // Top margins/padding only
13342
  //else if ($this->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding
13343
  // called from block after new div e.g. <div> ... <ol> ... Outputs block top margin/border and padding
@@ -13383,15 +13382,15 @@ function OpenTag($tag,$attr)
13383
  else {
13384
  $properties = $this->MergeCSS('LIST',$tag,$attr);
13385
  }
13386
- if (!empty($properties)) $this->setCSS($properties,'LIST');
13387
  // List-type
13388
 
13389
  $this->listtype = '';
13390
  if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listtype = $attr['TYPE']; }
13391
- else if (isset($properties['LIST-STYLE-TYPE'])) {
13392
  $this->listtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
13393
  }
13394
- else if (isset($properties['LIST-STYLE'])) {
13395
  $this->listtype = $this->_getListStyle($properties['LIST-STYLE']);
13396
  }
13397
  if (!$this->listtype) {
@@ -13433,16 +13432,16 @@ function OpenTag($tag,$attr)
13433
 
13434
  // TOP LEVEL ONLY
13435
  if ($this->listlvl == 1) {
13436
- if (isset($properties['MARGIN-TOP'])) {
13437
- if ($lastbottommargin) {
13438
  $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13439
  if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
13440
  else { $properties['MARGIN-TOP'] = 0; }
13441
  }
13442
  $this->DivLn($this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false),$this->blklvl,true,1); // collapsible
13443
  }
13444
- if (isset($properties['MARGIN-BOTTOM'])) {
13445
- $this->list_margin_bottom = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13446
  }
13447
 
13448
  if (isset($this->blk[$this->blklvl]['line_height'])) {
@@ -13456,19 +13455,19 @@ function OpenTag($tag,$attr)
13456
  $this->list_indent[$this->listlvl][$occur] = 5; // mm default indent for each level
13457
  if (isset($properties['TEXT-INDENT'])) { $this->list_indent[$this->listlvl][$occur] = $this->ConvertSize($properties['TEXT-INDENT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
13458
 
13459
- if (isset($properties['TEXT-ALIGN'])) {
13460
- $this->list_align[$this->listlvl][$occur] = $align[strtolower($properties['TEXT-ALIGN'])];
13461
  }
13462
 
13463
 
13464
- if (isset($properties['LINE-HEIGHT'])) {
13465
  $this->list_lineheight[$this->listlvl][$occur] = $this->fixLineheight($properties['LINE-HEIGHT']);
13466
  }
13467
- else if ($this->listlvl>1 && isset($this->list_lineheight[($this->listlvl - 1)][1])) {
13468
  $this->list_lineheight[$this->listlvl][$occur] = end($this->list_lineheight[($this->listlvl - 1)]);
13469
  }
13470
- if (!isset($this->list_lineheight[$this->listlvl][$occur]) || !$this->list_lineheight[$this->listlvl][$occur]) {
13471
- $this->list_lineheight[$this->listlvl][$occur] = $this->normalLineheight;
13472
  }
13473
 
13474
  $this->InlineProperties['LIST'][$this->listlvl][$occur] = $this->saveInlineProperties();
@@ -13492,7 +13491,7 @@ function OpenTag($tag,$attr)
13492
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13493
  }
13494
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
13495
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13496
  }
13497
  $this->cell[$this->row][$this->col]['s'] = 0 ;
13498
  }
@@ -13520,19 +13519,19 @@ function OpenTag($tag,$attr)
13520
  $blt = $this->listnum.$this->list_number_suffix;
13521
  break;
13522
  default:
13523
- if ($this->listlvl % 3 == 1 && $this->_charDefined($this->CurrentFont['cw'],8226)) { $blt = "\xe2\x80\xa2"; } // &#8226;
13524
- else if ($this->listlvl % 3 == 2 && $this->_charDefined($this->CurrentFont['cw'],9900)) { $blt = "\xe2\x9a\xac"; } // &#9900;
13525
- else if ($this->listlvl % 3 == 0 && $this->_charDefined($this->CurrentFont['cw'],9642)) { $blt = "\xe2\x96\xaa"; } // &#9642;
13526
  else { $blt = '-'; }
13527
  break;
13528
  }
13529
 
13530
  // change to &nbsp; spaces
13531
- if ($this->usingCoreFont) {
13532
- $ls = str_repeat(chr(160).chr(160),($this->listlvl-1)*2) . $blt . ' ';
13533
  }
13534
  else {
13535
- $ls = str_repeat("\xc2\xa0\xc2\xa0",($this->listlvl-1)*2) . $blt . ' ';
13536
  }
13537
 
13538
  $this->_saveCellTextBuffer($ls, $this->HREF);
@@ -13572,10 +13571,10 @@ function OpenTag($tag,$attr)
13572
 
13573
  // List-type
13574
  if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listitemtype = $attr['TYPE']; }
13575
- else if (isset($properties['LIST-STYLE-TYPE'])) {
13576
  $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
13577
  }
13578
- else if (isset($properties['LIST-STYLE'])) {
13579
  $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE']);
13580
  }
13581
  else $this->listitemtype = '';
@@ -13588,10 +13587,10 @@ function OpenTag($tag,$attr)
13588
  function _getListStyle($ls) {
13589
  if (stristr($ls,'decimal')) { return '1'; }
13590
  /* CSS3 list-styles numeric (selected) + I added tamil
13591
- arabic-indic | bengali | devanagari | gujarati | gurmukhi | kannada | malayalam | oriya | persian | telugu | thai | urdu
13592
  */
13593
- else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu)/i',$ls,$m)) {
13594
- return strtolower(trim($m[1]));
13595
  }
13596
  else if (stristr($ls,'lower-roman')) { return 'i'; }
13597
  else if (stristr($ls,'upper-roman')) { return 'I'; }
@@ -13618,10 +13617,10 @@ function CloseTag($tag)
13618
  }
13619
 
13620
 
13621
- if($tag=='FONT' || $tag=='SPAN' || $tag=='CODE' || $tag=='KBD' || $tag=='SAMP' || $tag=='TT' || $tag=='VAR'
13622
  || $tag=='INS' || $tag=='STRONG' || $tag=='CITE' || $tag=='SUB' || $tag=='SUP' || $tag=='S' || $tag=='STRIKE' || $tag=='DEL'
13623
  || $tag=='Q' || $tag=='EM' || $tag=='B' || $tag=='I' || $tag=='U' | $tag=='SMALL' || $tag=='BIG' || $tag=='ACRONYM'
13624
- || $tag=='MARK' || $tag=='TIME' || $tag=='PROGRESS' || $tag=='METER'
13625
  ) { // mPDF 5.5.09
13626
 
13627
  if ($tag == 'SPAN') {
@@ -13629,7 +13628,7 @@ function CloseTag($tag)
13629
  unset($this->InlineProperties['SPAN'][$this->spanlvl]);
13630
  $this->spanlvl--;
13631
  }
13632
- else {
13633
  if (isset($this->InlineProperties[$tag]) && $this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
13634
  unset($this->InlineProperties[$tag]);
13635
  }
@@ -13642,14 +13641,14 @@ function CloseTag($tag)
13642
 
13643
 
13644
  if($tag=='A') {
13645
- $this->HREF='';
13646
  if (isset($this->InlineProperties['A'])) { $this->restoreInlineProperties($this->InlineProperties['A']); }
13647
  unset($this->InlineProperties['A']);
13648
  }
13649
 
13650
  if($tag=='LEGEND') { // mPDF 5.4.18
13651
- if (count($this->textbuffer) && !$this->tableLevel) {
13652
- $leg = $this->textbuffer[(count($this->textbuffer)-1)];
13653
  unset($this->textbuffer[(count($this->textbuffer)-1)]);
13654
  $this->textbuffer = array_values($this->textbuffer);
13655
  $this->blk[$this->blklvl]['border_legend'] = $leg;
@@ -13667,10 +13666,10 @@ function CloseTag($tag)
13667
 
13668
  // *********** BLOCKS ********************
13669
  // mPDF 5.4.18
13670
- if($tag=='P' || $tag=='DIV' || $tag=='H1' || $tag=='H2' || $tag=='H3' || $tag=='H4' || $tag=='H5' || $tag=='H6' || $tag=='PRE'
13671
- || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DT' || $tag=='DD' || $tag=='DL'
13672
- || $tag=='CAPTION' || $tag=='FIELDSET'
13673
- || $tag=='ARTICLE' || $tag=='ASIDE' || $tag=='FIGURE' || $tag=='FIGCAPTION' || $tag=='FOOTER' || $tag=='HEADER' || $tag=='HGROUP'
13674
  || $tag=='NAV' || $tag=='SECTION' || $tag=='DETAILS' || $tag=='SUMMARY'
13675
  ) { // mPDF 5.5.09 // mPDF 5.5.22
13676
 
@@ -13682,7 +13681,7 @@ function CloseTag($tag)
13682
 
13683
  if($this->tableLevel) {
13684
  if ($this->linebreakjustfinished) { $this->blockjustfinished=false; }
13685
- if (isset($this->InlineProperties['BLOCKINTABLE'])) {
13686
  if ($this->InlineProperties['BLOCKINTABLE']) { $this->restoreInlineProperties($this->InlineProperties['BLOCKINTABLE']); }
13687
  unset($this->InlineProperties['BLOCKINTABLE']);
13688
  }
@@ -13720,14 +13719,14 @@ function CloseTag($tag)
13720
  $this->PaintDivBB('',$blockstate);
13721
  }
13722
  else {
13723
- $this->printbuffer($this->textbuffer,$blockstate);
13724
  }
13725
 
13726
 
13727
  $this->textbuffer=array();
13728
 
13729
  if ($this->blk[$this->blklvl]['keep_block_together']) {
13730
- $this->printdivbuffer();
13731
  }
13732
 
13733
  if ($this->kwt) {
@@ -13753,7 +13752,7 @@ function CloseTag($tag)
13753
  $this->EndLayer();
13754
  }
13755
 
13756
- if ($this->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
13757
  if ($this->blk[$this->blklvl]['tag'] == $tag) {
13758
  unset($this->blk[$this->blklvl]);
13759
  $this->blklvl--;
@@ -13791,7 +13790,7 @@ function CloseTag($tag)
13791
  $this->blk[0]['inner_width'] =& $this->pgwidth;
13792
  $this->blk[0]['blockContext'] = $this->blockContext;
13793
  $properties = $this->MergeCSS('BLOCK','BODY','');
13794
- $this->setCSS($properties,'','BODY');
13795
  $this->blklvl++;
13796
  $currblk =& $this->blk[$this->blklvl];
13797
  $prevblk =& $this->blk[$this->blklvl-1];
@@ -13808,14 +13807,14 @@ function CloseTag($tag)
13808
  // Re-open block tags
13809
  $t = $this->blk[0]['tag'];
13810
  $a = $this->blk[0]['attr'];
13811
- $this->blklvl = 0;
13812
  for ($b=0; $b<=$save_blklvl;$b++) {
13813
  $tc = $t;
13814
  $ac = $a;
13815
  $t = $this->blk[$b+1]['tag'];
13816
  $a = $this->blk[$b+1]['attr'];
13817
  unset($this->blk[$b+1]);
13818
- $this->OpenTag($tc,$ac);
13819
  }
13820
  $this->spanlvl = $save_spanlvl;
13821
  $this->InlineProperties = $save_ilp;
@@ -13838,10 +13837,10 @@ function CloseTag($tag)
13838
  // Added for correct calculation of cell column width - otherwise misses the last line if not end </p> etc.
13839
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
13840
  if (!is_array($this->cell[$this->row][$this->col])) { $this->Error("You may have an error in your HTML code e.g. &lt;/td&gt;&lt;/td&gt;"); }
13841
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13842
  }
13843
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
13844
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13845
  }
13846
 
13847
  // Remove last <br> if at end of cell
@@ -13857,11 +13856,11 @@ function CloseTag($tag)
13857
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['ptr'] += $clen;
13858
  }
13859
 
13860
- if ($this->tablethead) {
13861
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead'][$this->row] = true;
13862
  if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] , ($this->row+1)); }
13863
  }
13864
- if ($this->tabletfoot) {
13865
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true;
13866
  if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] , ($this->row+1 - $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] )); }
13867
  }
@@ -13881,7 +13880,7 @@ function CloseTag($tag)
13881
  }
13882
  else { $cell = $c; }
13883
  $cell['border_details']['R'] = $this->border_details($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row]);
13884
- $this->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
13885
  if ($this->packTableData) {
13886
  $c['borderbin'] = $this->_packCellBorder($cell);
13887
  unset($c['border']);
@@ -13890,7 +13889,7 @@ function CloseTag($tag)
13890
  else { $c = $cell; }
13891
  }
13892
  if ($this->cacheTables) {
13893
- $fh = fopen($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cache'], "r+b");
13894
  $this->_cacheUpdateBorder($c, $fh, $this->cell[$this->row][$this->col]);
13895
  fclose($fh);
13896
  }
@@ -13971,7 +13970,7 @@ function CloseTag($tag)
13971
  foreach($this->table[($this->tableLevel+1)] AS $nid=>$nested) {
13972
  $this->table[($this->tableLevel+1)][$nid]['nestedpos'][0] -= count($temptf);
13973
  }
13974
- }
13975
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = array_merge($temp, $temptf);
13976
 
13977
  // Update other arays set on row number
@@ -14037,7 +14036,7 @@ function CloseTag($tag)
14037
  $this->base_table_properties = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['baseProperties'];
14038
  $this->cell = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'];
14039
  // mPDF 5.4.10
14040
- if (isset($this->cell['PARENTCELL'])) {
14041
  if ($this->cell['PARENTCELL']) { $this->restoreInlineProperties($this->cell['PARENTCELL']); }
14042
  unset($this->cell['PARENTCELL']);
14043
  }
@@ -14054,10 +14053,10 @@ function CloseTag($tag)
14054
  $this->_saveCellTextBuffer($e);
14055
  $this->cell[$this->row][$this->col]['s'] += $tl ;
14056
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
14057
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
14058
  }
14059
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
14060
- $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
14061
  }
14062
  $this->cell[$this->row][$this->col]['s'] = 0;// reset
14063
  if ((isset($this->cell[$this->row][$this->col]['nestedmaw']) && $this->cell[$this->row][$this->col]['nestedmaw'] < $tmaw) || !isset($this->cell[$this->row][$this->col]['nestedmaw'])) { $this->cell[$this->row][$this->col]['nestedmaw'] = $tmaw ; }
@@ -14077,7 +14076,7 @@ function CloseTag($tag)
14077
  $this->cellPaddingB = 0;
14078
 
14079
  if (isset($this->table[1][1]['overflow']) && $this->table[1][1]['overflow']=='visible') {
14080
- if ($this->kwt || $this->table_rotate || $this->table_keep_together || $this->ColActive) {
14081
  $this->kwt = false;
14082
  $this->table_rotate = 0;
14083
  $this->table_keep_together = false;
@@ -14090,16 +14089,16 @@ function CloseTag($tag)
14090
  if (!$this->kwt_saved) { $this->kwt_height = 0; }
14091
 
14092
  list($check,$tablemiw) = $this->_tableColumnWidth($this->table[1][1],true);
14093
- $save_table = $this->table;
14094
  if ($this->cacheTables) { $this->_backupCacheFiles(); }
14095
  $reset_to_minimum_width = false;
14096
  $added_page = false;
14097
 
14098
  if ($check > 1) {
14099
- if ($check > $this->shrink_this_table_to_fit && $this->table_rotate) {
14100
  if ($this->y != $this->tMargin) {
14101
  $this->AddPage($this->CurOrientation);
14102
- $this->kwt_moved = true;
14103
  }
14104
  $added_page = true;
14105
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
@@ -14151,13 +14150,13 @@ function CloseTag($tag)
14151
  if ($this->cacheTables) {
14152
  $c = $this->_uncacheCell($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol], $this->table[($lvl-1)][$parentnid]['cache'], null);
14153
  }
14154
- else
14155
  $c =& $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol];
14156
 
14157
  if (isset($c['colspan']) && $c['colspan']> 1) {
14158
  $parentwidth = 0;
14159
  for($cs=0;$cs<$c['colspan'] ; $cs++) {
14160
- $parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
14161
  }
14162
  }
14163
  else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
@@ -14168,7 +14167,7 @@ function CloseTag($tag)
14168
  if ($this->packTableData) {
14169
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
14170
  }
14171
- else {
14172
  $br = $c['border_details']['R']['w'];
14173
  $bl = $c['border_details']['L']['w'];
14174
  }
@@ -14225,8 +14224,8 @@ function CloseTag($tag)
14225
  $r = 0; $c = 0; $p = 0; $y = 0;
14226
  while (!$finished) {
14227
  list($finished,$r,$c,$p,$y,$y0) = $this->_tableWrite($this->table[1][1],true,$r,$c,$p,$y);
14228
- if (!$finished) {
14229
- $this->AddPage($this->CurOrientation);
14230
  // If printed something on first spread, set same y
14231
  if ($r==0 && $y0 > -1) { $this->y = $y0; }
14232
  }
@@ -14236,20 +14235,20 @@ function CloseTag($tag)
14236
  $recalculate = 1;
14237
  $forcerecalc = false;
14238
  // RESIZING ALGORITHM
14239
- if ($maxrowheight > $fullpage) {
14240
- $recalculate = $this->tbsqrt($maxrowheight / $fullpage, 1);
14241
  $forcerecalc = true;
14242
  }
14243
  else if ($this->table_rotate) { // NB $remainingpage == $fullpage == the width of the page
14244
- if ($tableheight > $remainingpage) {
14245
  // If can fit on remainder of page whilst respecting autsize value..
14246
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
14247
- $recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
14248
  }
14249
  else if (!$added_page) {
14250
  if ($this->y != $this->tMargin) {
14251
  $this->AddPage($this->CurOrientation);
14252
- $this->kwt_moved = true;
14253
  }
14254
  $added_page = true;
14255
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
@@ -14259,45 +14258,45 @@ function CloseTag($tag)
14259
  }
14260
  else { $recalculate = 1; }
14261
  }
14262
- else if ($this->table_keep_together || ($this->table[1][1]['nr']==1 && !$this->writingHTMLfooter)) {
14263
- if ($tableheight > $fullpage) {
14264
  if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, 1)) <= $this->shrink_this_table_to_fit) {
14265
- $recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
14266
  }
14267
  else if ($this->tableMinSizePriority) {
14268
- $this->table_keep_together = false;
14269
- $recalculate = 1.001;
14270
  }
14271
  else {
14272
  if ($this->y != $this->tMargin) { // mPDF 5.1
14273
  $this->AddPage($this->CurOrientation);
14274
- $this->kwt_moved = true;
14275
  }
14276
  $added_page = true;
14277
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14278
- $recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
14279
  }
14280
  }
14281
- else if ($tableheight > $remainingpage) {
14282
  // If can fit on remainder of page whilst respecting autsize value..
14283
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
14284
- $recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
14285
  }
14286
  else {
14287
  if ($this->y != $this->tMargin) {
14288
  $this->AddPage($this->CurOrientation);
14289
  $this->kwt_moved = true;
14290
- }
14291
  $added_page = true;
14292
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14293
- $recalculate = 1.001;
14294
  }
14295
  }
14296
  else { $recalculate = 1; }
14297
  }
14298
  else { $recalculate = 1; }
14299
 
14300
- if ($recalculate > $this->shrink_this_table_to_fit && !$forcerecalc) { $recalculate = $this->shrink_this_table_to_fit; }
14301
 
14302
  $iteration = 1;
14303
 
@@ -14336,13 +14335,13 @@ function CloseTag($tag)
14336
  if ($this->cacheTables) {
14337
  $c = $this->_uncacheCell($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol], $this->table[($lvl-1)][$parentnid]['cache'], null);
14338
  }
14339
- else
14340
  $c =& $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol];
14341
 
14342
  if (isset($c['colspan']) && $c['colspan']> 1) {
14343
  $parentwidth = 0;
14344
  for($cs=0;$cs<$c['colspan'] ; $cs++) {
14345
- $parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
14346
  }
14347
  }
14348
  else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
@@ -14352,7 +14351,7 @@ function CloseTag($tag)
14352
  if ($this->packTableData) {
14353
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
14354
  }
14355
- else {
14356
  $br = $c['border_details']['R']['w'];
14357
  $bl = $c['border_details']['L']['w'];
14358
  }
@@ -14407,16 +14406,16 @@ function CloseTag($tag)
14407
  // RESIZING ALGORITHM
14408
 
14409
  if ($maxrowheight > $fullpage) { $recalculate = $this->tbsqrt($maxrowheight / $fullpage, $iteration); $iteration++; }
14410
- else if ($this->table_rotate && $tableheight > $remainingpage && !$added_page) {
14411
  // If can fit on remainder of page whilst respecting autosize value..
14412
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14413
- $recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
14414
  }
14415
  else {
14416
- if (!$added_page) {
14417
- $this->AddPage($this->CurOrientation);
14418
  $added_page = true;
14419
- $this->kwt_moved = true;
14420
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14421
  }
14422
  // 0.001 to force it to recalculate
@@ -14424,38 +14423,38 @@ function CloseTag($tag)
14424
  }
14425
  }
14426
  else if ($this->table_keep_together || ($this->table[1][1]['nr']==1 && !$this->writingHTMLfooter)) {
14427
- if ($tableheight > $fullpage) {
14428
  if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14429
- $recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14430
  }
14431
  else if ($this->tableMinSizePriority) {
14432
- $this->table_keep_together = false;
14433
- $recalculate = (1 / $this->shrin_k) + 0.001;
14434
  }
14435
  else {
14436
  if (!$added_page && $this->y != $this->tMargin) {
14437
  $this->AddPage($this->CurOrientation);
14438
  $added_page = true;
14439
- $this->kwt_moved = true;
14440
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14441
  }
14442
- $recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14443
  }
14444
  }
14445
- else if ($tableheight > $remainingpage) {
14446
  // If can fit on remainder of page whilst respecting autosize value..
14447
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14448
- $recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
14449
  }
14450
  else {
14451
- if (!$added_page) {
14452
- $this->AddPage($this->CurOrientation);
14453
  $added_page = true;
14454
- $this->kwt_moved = true;
14455
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14456
  }
14457
 
14458
- //$recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14459
  $recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
14460
  }
14461
  }
@@ -14466,7 +14465,7 @@ function CloseTag($tag)
14466
 
14467
 
14468
  if ($maxfirstrowheight > $remainingpage && !$added_page && !$this->table_rotate && !$this->ColActive && !$this->table_keep_together && !$this->writingHTMLheader && !$this->writingHTMLfooter) {
14469
- $this->AddPage($this->CurOrientation);
14470
  $this->kwt_moved = true;
14471
  }
14472
 
@@ -14500,7 +14499,7 @@ function CloseTag($tag)
14500
 
14501
  $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
14502
 
14503
- $this->maxPosR = max($this->maxPosR , ($this->x + $this->table[1][1]['w']));
14504
 
14505
  $this->blockjustfinished=true;
14506
  $this->lastblockbottommargin = $this->table[1][1]['margin']['B'];
@@ -14528,7 +14527,7 @@ function CloseTag($tag)
14528
  $this->shrink_this_table_to_fit = 0;
14529
 
14530
  unset($this->table);
14531
- $this->table=array(); //array
14532
  $this->tableLevel=0;
14533
  $this->tbctr=array();
14534
  $this->innermostTableLevel=0;
@@ -14536,7 +14535,7 @@ function CloseTag($tag)
14536
  $this->tablecascadeCSS = array();
14537
 
14538
  unset($this->cell);
14539
- $this->cell=array(); //array
14540
 
14541
  $this->col=-1; //int
14542
  $this->row=-1; //int
@@ -14581,7 +14580,7 @@ function CloseTag($tag)
14581
  $this->blk[0]['inner_width'] =& $this->pgwidth;
14582
  $this->blk[0]['blockContext'] = $this->blockContext;
14583
  $properties = $this->MergeCSS('BLOCK','BODY','');
14584
- $this->setCSS($properties,'','BODY');
14585
  }
14586
 
14587
  if ($this->restoreBlockPagebreaks) {
@@ -14589,14 +14588,14 @@ function CloseTag($tag)
14589
  // Re-open block tags
14590
  $t = $this->blk[0]['tag'];
14591
  $a = $this->blk[0]['attr'];
14592
- $this->blklvl = 0;
14593
  for ($b=0; $b<=$save_blklvl;$b++) {
14594
  $tc = $t;
14595
  $ac = $a;
14596
  $t = $this->blk[$b+1]['tag'];
14597
  $a = $this->blk[$b+1]['attr'];
14598
  unset($this->blk[$b+1]);
14599
- $this->OpenTag($tc,$ac);
14600
  }
14601
  $this->spanlvl = $save_spanlvl;
14602
  $this->InlineProperties = $save_ilp;
@@ -14608,11 +14607,11 @@ function CloseTag($tag)
14608
 
14609
  // *********** LISTS ********************
14610
 
14611
- if($tag=='LI') {
14612
- $this->lastoptionaltag = '';
14613
  unset($this->listcascadeCSS[$this->listCSSlvl]);
14614
  $this->listCSSlvl--;
14615
- if (isset($this->listoccur[$this->listlvl]) && isset($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]])) { $this->restoreInlineProperties($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]]); }
14616
  }
14617
 
14618
 
@@ -14634,10 +14633,10 @@ function CloseTag($tag)
14634
 
14635
  if ($this->listlvl > 1) { // returning one level
14636
  $this->listjustfinished=true;
14637
- if (!empty($this->textbuffer)) {
14638
  $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
14639
  }
14640
- else {
14641
  $this->listnum--;
14642
  }
14643
 
@@ -14655,11 +14654,11 @@ function CloseTag($tag)
14655
  if (!empty($this->textbuffer)) {
14656
  $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
14657
  }
14658
- else {
14659
  $this->listnum--;
14660
  }
14661
 
14662
- $occur = $this->listoccur[$this->listlvl];
14663
  $this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum;
14664
  $this->textbuffer = array();
14665
  $this->listlvl--;
@@ -14672,7 +14671,7 @@ function CloseTag($tag)
14672
  $this->DivLn($this->list_margin_bottom,$this->blklvl,true,1); // collapsible
14673
  }
14674
  if (isset($this->blk[$this->blklvl]['InlineProperties'])) { $this->restoreInlineProperties($this->blk[$this->blklvl]['InlineProperties']);}
14675
- $this->listjustfinished = true;
14676
  $this->listCSSlvl = 0;
14677
  $this->listcascadeCSS = array();
14678
  $this->blockjustfinished=true;
@@ -14711,7 +14710,7 @@ function printlistbuffer() {
14711
  $currIndentLvl = -1;
14712
  $lastIndent = array();
14713
  $bak_page = $this->page;
14714
- $indent = 0;
14715
  foreach($this->listitem as $item)
14716
  {
14717
  // COLS
@@ -14731,11 +14730,11 @@ function printlistbuffer() {
14731
  $clh = $this->FontSize;
14732
 
14733
  $this->SetLineHeight($this->FontSizePt,$this->list_lineheight[$lvl][$occur]);
14734
- $this->listOcc = $occur;
14735
- $this->listnum = $num;
14736
 
14737
  if (isset($this->list_align[$this->listlvl][$occur])) { $this->divalign = $this->list_align[$this->listlvl][$occur]; }
14738
- else {
14739
  if (isset($this->blk[$this->blklvl]['direction']) && $this->blk[$this->blklvl]['direction']=='rtl') { $this->divalign = 'R'; }
14740
  else { $this->divalign = 'L'; }
14741
  }
@@ -14755,11 +14754,11 @@ function printlistbuffer() {
14755
  $blt_width = $this->GetStringWidth($list_item_marker);
14756
  $typefont = '';
14757
  if (preg_match('/rgb\(.*?\)/',$type,$m)) {
14758
- $list_item_color = $this->ConvertColor($m[0]);
14759
  }
14760
  }
14761
  else {
14762
- $list_item_color = false;
14763
 
14764
  switch($type) //Format type
14765
  {
@@ -14829,40 +14828,40 @@ function printlistbuffer() {
14829
  break;
14830
  case 'disc':
14831
  if ($this->PDFA || $this->PDFX) {
14832
- if ($this->_charDefined($this->CurrentFont['cw'],8226)) { $list_item_marker = "\xe2\x80\xa2"; } // &#8226;
14833
  else { $list_item_marker = '-'; }
14834
  $blt_width = $this->GetCharWidth($list_item_marker);
14835
  break;
14836
  }
14837
  $list_item_marker = chr(108); // bullet disc in Zapfdingbats 'l'
14838
  $typefont = 'czapfdingbats';
14839
- $blt_width = (0.791 * $this->FontSize/2.5);
14840
  break;
14841
  case 'circle':
14842
  if ($this->PDFA || $this->PDFX) {
14843
- if ($this->_charDefined($this->CurrentFont['cw'],9900)) { $list_item_marker = "\xe2\x9a\xac"; } // &#9900;
14844
  else { $list_item_marker = '-'; }
14845
  $blt_width = $this->GetCharWidth($list_item_marker);
14846
  break;
14847
  }
14848
  $list_item_marker = chr(109); // circle in Zapfdingbats 'm'
14849
  $typefont = 'czapfdingbats';
14850
- $blt_width = (0.873 * $this->FontSize/2.5);
14851
  break;
14852
  case 'square':
14853
  if ($this->PDFA || $this->PDFX) {
14854
- if ($this->_charDefined($this->CurrentFont['cw'],9642)) { $list_item_marker = "\xe2\x96\xaa"; } // &#9642;
14855
  else { $list_item_marker = '-'; }
14856
  $blt_width = $this->GetCharWidth($list_item_marker);
14857
  break;
14858
  }
14859
  $list_item_marker = chr(110); //black square in Zapfdingbats font 'n'
14860
  $typefont = 'czapfdingbats';
14861
- $blt_width = (0.761 * $this->FontSize/2.5);
14862
  break;
14863
 
14864
  /* CSS3 list-styles numeric + I added tamil
14865
- arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada | khmer | lao | malayalam | mongolian | myanmar | oriya | persian | telugu | tibetan | thai | urdu
14866
  */
14867
  case 'arabic-indic':
14868
  $cp = 0x0660;
@@ -14880,61 +14879,61 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada
14880
  case 'bengali':
14881
  $cp = 0x09E6;
14882
  $rnum = $this->dec2other($num, $cp);
14883
- $list_item_marker = $rnum . $this->list_number_suffix;
14884
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14885
  break;
14886
  case 'devanagari':
14887
  $cp = 0x0966;
14888
  $rnum = $this->dec2other($num, $cp);
14889
- $list_item_marker = $rnum . $this->list_number_suffix;
14890
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14891
  break;
14892
  case 'gujarati':
14893
  $cp = 0x0AE6;
14894
  $rnum = $this->dec2other($num, $cp);
14895
- $list_item_marker = $rnum . $this->list_number_suffix;
14896
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14897
  break;
14898
  case 'gurmukhi':
14899
  $cp = 0x0A66;
14900
  $rnum = $this->dec2other($num, $cp);
14901
- $list_item_marker = $rnum . $this->list_number_suffix;
14902
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14903
  break;
14904
  case 'kannada':
14905
  $cp = 0x0CE6;
14906
  $rnum = $this->dec2other($num, $cp);
14907
- $list_item_marker = $rnum . $this->list_number_suffix;
14908
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14909
  break;
14910
  case 'malayalam':
14911
  $cp = 0x0D66;
14912
  $rnum = $this->dec2other($num, $cp);
14913
- $list_item_marker = $rnum . $this->list_number_suffix;
14914
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(6, $cp),strlen($maxnum)).$this->list_number_suffix);
14915
  break;
14916
  case 'oriya':
14917
  $cp = 0x0B66;
14918
  $rnum = $this->dec2other($num, $cp);
14919
- $list_item_marker = $rnum . $this->list_number_suffix;
14920
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14921
  break;
14922
  case 'telugu':
14923
  $cp = 0x0C66;
14924
  $rnum = $this->dec2other($num, $cp);
14925
- $list_item_marker = $rnum . $this->list_number_suffix;
14926
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14927
  break;
14928
  case 'tamil':
14929
  $cp = 0x0BE6;
14930
  $rnum = $this->dec2other($num, $cp);
14931
- $list_item_marker = $rnum . $this->list_number_suffix;
14932
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(9, $cp),strlen($maxnum)).$this->list_number_suffix);
14933
  break;
14934
  case 'thai':
14935
  $cp = 0x0E50;
14936
  $rnum = $this->dec2other($num, $cp);
14937
- $list_item_marker = $rnum . $this->list_number_suffix;
14938
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, $cp),strlen($maxnum)).$this->list_number_suffix);
14939
  break;
14940
  default:
@@ -14948,8 +14947,8 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada
14948
  if (isset($item[5]) && $item[5]) { $list_item_marker = ''; }
14949
 
14950
  if ($currIndentLvl < $lvl) {
14951
- if ($lvl > 1 || $this->list_indent_first_level) {
14952
- $indent += $this->list_indent[$lvl][$occur];
14953
  $lastIndent[$lvl] = $this->list_indent[$lvl][$occur];
14954
  }
14955
  }
@@ -14966,7 +14965,7 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada
14966
  if ($this->list_align_style == 'L') { $lalign = 'L'; }
14967
  else { $lalign = 'R'; }
14968
  $this->divwidth = $this->blk[$this->blklvl]['width'] - ($indent + $blt_width + $space_width) ;
14969
- $xb = $this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] - $blt_width - $space_width;
14970
  //Output bullet
14971
  $this->bulletarray = array('w'=>$blt_width,'h'=>$clh,'txt'=>$list_item_marker,'x'=>$xb,'align'=>$lalign,'font'=>$typefont,'level'=>$lvl, 'occur'=>$occur, 'num'=>$num, 'fontsize'=>$bullfs, 'col'=>$list_item_color );
14972
  $this->x = $x + $indent + $blt_width + $space_width;
@@ -14999,7 +14998,7 @@ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada
14999
  }
15000
 
15001
  function _saveTextBuffer($t, $link = '', $intlink = '') {
15002
- $this->textbuffer[] = array($t,$link,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,$intlink,$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle,$this->kerning,$this->lSpacingCSS,$this->wSpacingCSS,$this->spanborddet, $this->textshadow);
15003
  }
15004
 
15005
  function _saveCellTextBuffer($t, $link = '', $intlink = '') {
@@ -15038,8 +15037,8 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15038
  $oldpage = $this->page;
15039
 
15040
  // ADDED for Out of Block now done as Flowing Block
15041
- if ($this->divwidth == 0) {
15042
- $this->divwidth = $this->pgwidth;
15043
  }
15044
 
15045
  if (!$is_table && !$is_list) { $this->SetLineHeight($this->FontSizePt,$this->blk[$this->blklvl]['line_height']); }
@@ -15065,7 +15064,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15065
  $vetor[0] = ltrim($vetor[0]);
15066
  }
15067
 
15068
- // FIXED TO ALLOW IT TO SHOW '0'
15069
  if (empty($vetor[0]) && !($vetor[0]==='0') && empty($vetor[7])) { //Ignore empty text and not carrying an internal link
15070
  //Check if it is the last element. If so then finish printing the block
15071
  if ($i == ($array_size-1)) { $this->finishFlowingBlock(true); } // true = END of flowing block
@@ -15076,10 +15075,10 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15076
  //Activating buffer properties
15077
  if(isset($vetor[11]) and $vetor[11] != '') { // Font Size
15078
  if ($is_table && $this->shrin_k) {
15079
- $this->SetFontSize($vetor[11]/$this->shrin_k,false);
15080
  }
15081
  else {
15082
- $this->SetFontSize($vetor[11],false);
15083
  }
15084
  }
15085
 
@@ -15092,19 +15091,19 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15092
  }
15093
 
15094
  if(isset($vetor[15])) { // Word spacing
15095
- $this->wSpacingCSS = $vetor[15];
15096
- if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
15097
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
15098
  }
15099
  }
15100
  if(isset($vetor[14])) { // Letter spacing
15101
- $this->lSpacingCSS = $vetor[14];
15102
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
15103
- $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
15104
  }
15105
  }
15106
  if(isset($vetor[13])) { // Font Kerning
15107
- $this->kerning = $vetor[13];
15108
  }
15109
 
15110
 
@@ -15126,7 +15125,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15126
  }
15127
  if(isset($vetor[7]) and $vetor[7] != '') // internal link: <a name="anyvalue">
15128
  {
15129
- $ily = $this->y;
15130
  if ($this->keep_block_together) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "kt"=>true ); }
15131
  else if ($this->table_rotate) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "tbrot"=>true ); }
15132
  else if ($this->kwt) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "kwt"=>true ); }
@@ -15139,7 +15138,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15139
  continue;
15140
  }
15141
  }
15142
- if(isset($vetor[6]) and $vetor[6] === true) // Subscript
15143
  {
15144
  $this->SUB = true;
15145
  }
@@ -15148,12 +15147,12 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15148
  $this->SUP = true;
15149
  }
15150
  if(isset($vetor[4]) and $vetor[4] != '') { // Font Family
15151
- $font = $this->SetFont($vetor[4],$this->FontStyle,0,false);
15152
  }
15153
  if (!empty($vetor[3])) //Font Color
15154
  {
15155
  $cor = $vetor[3];
15156
- $this->SetTColor($cor);
15157
  }
15158
  if(isset($vetor[2]) and $vetor[2] != '') //Bold,Italic,Underline styles
15159
  {
@@ -15166,7 +15165,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15166
  if(isset($vetor[1]) and $vetor[1] != '') //LINK
15167
  {
15168
 
15169
- if (strpos($vetor[1],".") === false && strpos($vetor[1],"@") !== 0) //assuming every external link has a dot indicating extension (e.g: .html .txt .zip www.somewhere.com etc.)
15170
  {
15171
  //Repeated reference to same anchor?
15172
  while(array_key_exists($vetor[1],$this->internallink)) $vetor[1]="#".$vetor[1];
@@ -15187,7 +15186,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15187
  if ($objattr['nestedcontent']) {
15188
  $level = $objattr['level'];
15189
  $table = &$this->table[$level][$objattr['table']];
15190
- if ($this->cacheTables) {
15191
  $fh = fopen($table['cache'], "r+b");
15192
  $cell = $this->_uncacheCell($table['cells'][$objattr['row']][$objattr['col']], '', $fh);
15193
  }
@@ -15206,11 +15205,11 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15206
  if ($this->packTableData) {
15207
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($cell['borderbin']);
15208
  }
15209
- else {
15210
  $br = $cell['border_details']['R']['w'];
15211
  $bl = $cell['border_details']['L']['w'];
15212
  }
15213
- if ($table['borders_separate']) {
15214
  $innerw = $w - $bl - $br - $cell['padding']['L'] - $cell['padding']['R'] - $table['border_spacing_H'];
15215
  }
15216
  else {
@@ -15218,19 +15217,19 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15218
  }
15219
  }
15220
  else if ($this->simpleTables){
15221
- if ($table['borders_separate']) {
15222
  $innerw = $w - $table['simple']['border_details']['L']['w'] - $table['simple']['border_details']['R']['w'] - $cell['padding']['L'] - $cell['padding']['R'] - $table['border_spacing_H'];
15223
  }
15224
  else {
15225
  $innerw = $w - $table['simple']['border_details']['L']['w']/2 - $table['simple']['border_details']['R']['w']/2 - $cell['padding']['L'] - $cell['padding']['R'];
15226
  }
15227
  }
15228
- if ($cell['a']=='C' || $this->table[($level+1)][$objattr['nestedcontent']]['a']=='C') {
15229
- $ncx += ($innerw-$ntw)/2;
15230
  }
15231
  elseif ($cell['a']=='R' || $this->table[($level+1)][$objattr['nestedcontent']]['a']=='R') {
15232
- $ncx += $innerw- $ntw;
15233
- }
15234
  $this->x = $ncx ;
15235
  if ($this->cacheTables) { fclose($fh); }
15236
 
@@ -15246,7 +15245,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15246
  $maxWidth = $this->divwidth; // *TABLES*
15247
  } // *TABLES*
15248
  else { // *TABLES*
15249
- $maxWidth = $this->divwidth - ($this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_right'] + $this->blk[$this->blklvl]['border_right']['w']);
15250
  } // *TABLES*
15251
 
15252
 
@@ -15262,13 +15261,13 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15262
  $this->newFlowingBlock( $this->divwidth,$this->divheight,$align,$is_table,$is_list,$blockstate,false,$blockdir);
15263
  }
15264
  $thispage = $this->page;
15265
- if ($this->CurrCol!=$oldcol) { $changedcol = true; }
15266
  else { $changedcol=false; }
15267
 
15268
  // the previous lines can already have triggered page break or column change
15269
  if (!$changedcol && $skipln <0 && $this->AcceptPageBreak() && $thispage==$oldpage) {
15270
 
15271
- $this->AddPage($this->CurOrientation);
15272
 
15273
  // Added to correct Images already set on line before page advanced
15274
  // i.e. if second inline image on line is higher than first and forces new page
@@ -15284,7 +15283,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15284
 
15285
  // Added to correct for OddEven Margins
15286
  if ($this->page != $oldpage) {
15287
- if (($this->page-$oldpage) % 2 == 1) {
15288
  $bak_x += $this->MarginCorrection;
15289
  }
15290
  $oldpage = $this->page;
@@ -15294,7 +15293,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15294
  }
15295
  $this->x = $bak_x;
15296
 
15297
- $this->WriteFlowingBlock($vetor[0]);
15298
  } // *TABLES*
15299
 
15300
  } // END If special content
@@ -15310,7 +15309,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15310
  $this->y+= $this->_computeLineheight($this->table_lineheight);
15311
  }
15312
  else if (!$is_table) {
15313
- $this->DivLn($this->lineheight);
15314
  }
15315
  // Added to correct for OddEven Margins
15316
  if ($this->page != $oldpage) {
@@ -15366,7 +15365,7 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15366
  $this->SetTColor($this->ConvertColor(0));
15367
  $this->SetDColor($this->ConvertColor(0));
15368
  $this->SetFColor($this->ConvertColor(255));
15369
- $this->colorarray = '';
15370
  $this->spanbgcolorarray = '';
15371
  $this->spanbgcolor = false;
15372
  $this->spanborder = false;
@@ -15381,9 +15380,9 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15381
  $this->strike = false;
15382
  $this->textshadow = '';
15383
 
15384
- $this->currentfontfamily = '';
15385
- $this->currentfontsize = '';
15386
- $this->currentfontstyle = '';
15387
  if ($this->tableLevel) {
15388
  $this->SetLineHeight('',$this->table_lineheight); // *TABLES*
15389
  }
@@ -15399,12 +15398,12 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15399
  $this->toupper = false;
15400
  $this->tolower = false;
15401
  $this->capitalize = false;
15402
- $this->kerning = false;
15403
  $this->lSpacingCSS = '';
15404
  $this->wSpacingCSS = '';
15405
  $this->fixedlSpacing = false;
15406
  $this->minwSpacing = 0;
15407
- $this->SetDash();
15408
  $this->dash_on = false;
15409
  $this->dotted_on = false;
15410
 
@@ -15421,12 +15420,12 @@ function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
15421
  else if ($blockstate != 1) {
15422
  $this->PaintDivBB('',$blockstate);
15423
  }
15424
- $this->y = $bottom_y;
15425
  $this->x = $bak_x;
15426
  }
15427
 
15428
  // Reset Font
15429
- $this->SetFontSize($this->default_font_size,false);
15430
 
15431
 
15432
  }
@@ -15460,7 +15459,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15460
  // Borders & backgrounds are done elsewhere for columns - messes up the repositioning in printcolumnbuffer
15461
  $save_y = $this->y;
15462
  if (!$blvl) { $blvl = $this->blklvl; }
15463
- $x0 = $x1 = $y0 = $y1 = 0;
15464
 
15465
  // Added mPDF 3.0 Float DIV
15466
 
@@ -15468,12 +15467,12 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15468
  if (isset($this->blk[$blvl]['y1'])) { $y1 = $this->blk[$blvl]['y1']; } // bottom
15469
 
15470
  // Added mPDF 3.0 Float DIV - ensures backgrounds/borders are drawn to bottom of page
15471
- if ($y1==0) {
15472
  if ($divider=='pagebottom') { $y1 = $this->h-$this->bMargin; }
15473
  else { $y1 = $this->y; }
15474
  }
15475
 
15476
- if (isset($this->blk[$blvl]['startpage']) && $this->blk[$blvl]['startpage'] != $this->page) { $continuingpage = true; } else { $continuingpage = false; }
15477
 
15478
  if (isset($this->blk[$blvl]['y0'])) { $y0 = $this->blk[$blvl]['y0']; }
15479
  $h = $y1 - $y0;
@@ -15488,7 +15487,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15488
  if (!$this->blk[$blvl]['border_top'] || $divider == 'pagetop' || $continuingpage) {
15489
  $border_top = 0;
15490
  }
15491
- if (!$this->blk[$blvl]['border_bottom'] || $blockstate == 1 || $divider == 'pagebottom') {
15492
  $border_bottom = 0;
15493
  }
15494
 
@@ -15501,7 +15500,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15501
  $brBR_H = 0;
15502
  $brBR_V = 0;
15503
 
15504
- $brset = false;
15505
 
15506
  // BORDERS
15507
  if (isset($this->blk[$blvl]['y0']) && $this->blk[$blvl]['y0']) { $y0 = $this->blk[$blvl]['y0']; }
@@ -15515,13 +15514,13 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15515
 
15516
  // mPDF 5.4.18
15517
  $legend = '';
15518
- if (isset($this->blk[$blvl]['border_legend']) && $this->blk[$blvl]['border_legend']) {
15519
  $legend = $this->blk[$blvl]['border_legend']; // Same structure array as textbuffer
15520
  $txt = ltrim($legend[0]);
15521
 
15522
  //Set font, size, style, color
15523
  $this->SetFont($legend[4],$legend[2],$legend[11]);
15524
- if ($legend[3]) {
15525
  $cor = $legend[3];
15526
  $this->SetTColor($cor);
15527
  }
@@ -15541,7 +15540,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15541
  $legbreakR = $this->x + $stringWidth + $gap;
15542
 
15543
  $this->Cell( $stringWidth, $this->FontSize, $txt , '', 0, 'C', $fill, '', 0, 0,0,'M', $fill);
15544
- // Reset
15545
  $this->x = $save_x;
15546
  $this->y = $save_y;
15547
  $this->SetFont($save_currentfontfamily,$save_currentfontstyle,$save_currentfontsize);
@@ -15575,12 +15574,12 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15575
  // Reset Corners and Dash off
15576
  $this->SetLineJoin(2);
15577
  $this->SetLineCap(2);
15578
- $this->SetDash();
15579
  }
15580
  }
15581
- //if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1) {
15582
  // Reinstate line above for dotted line divider when block border crosses a page
15583
- if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1 && $divider != 'pagebottom') {
15584
  $tbd = $this->blk[$blvl]['border_bottom'];
15585
  if (isset($tbd['s']) && $tbd['s']) {
15586
  $this->_setBorderLine($tbd);
@@ -15592,10 +15591,10 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15592
  // Reset Corners and Dash off
15593
  $this->SetLineJoin(2);
15594
  $this->SetLineCap(2);
15595
- $this->SetDash();
15596
  }
15597
  }
15598
- if ($this->blk[$blvl]['border_left']) {
15599
  $tbd = $this->blk[$blvl]['border_left'];
15600
  if (isset($tbd['s']) && $tbd['s']) {
15601
  $this->_setBorderLine($tbd);
@@ -15607,10 +15606,10 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15607
  // Reset Corners and Dash off
15608
  $this->SetLineJoin(2);
15609
  $this->SetLineCap(2);
15610
- $this->SetDash();
15611
  }
15612
  }
15613
- if ($this->blk[$blvl]['border_right']) {
15614
  $tbd = $this->blk[$blvl]['border_right'];
15615
  if (isset($tbd['s']) && $tbd['s']) {
15616
  $this->_setBorderLine($tbd);
@@ -15622,7 +15621,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15622
  // Reset Corners and Dash off
15623
  $this->SetLineJoin(2);
15624
  $this->SetLineCap(2);
15625
- $this->SetDash();
15626
  }
15627
  }
15628
 
@@ -15644,7 +15643,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15644
  }
15645
  }
15646
  }
15647
- if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1 && $divider != 'pagebottom') {
15648
  $tbd = $this->blk[$blvl]['border_bottom'];
15649
  if (isset($tbd['s']) && $tbd['s']) {
15650
  if (!$brset && $tbd['style']=='double') {
@@ -15654,7 +15653,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15654
  }
15655
  }
15656
  }
15657
- if ($this->blk[$blvl]['border_left']) {
15658
  $tbd = $this->blk[$blvl]['border_left'];
15659
  if (isset($tbd['s']) && $tbd['s']) {
15660
  if (!$brset && $tbd['style']=='double') {
@@ -15664,7 +15663,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15664
  }
15665
  }
15666
  }
15667
- if ($this->blk[$blvl]['border_right']) {
15668
  $tbd = $this->blk[$blvl]['border_right'];
15669
  if (isset($tbd['s']) && $tbd['s']) {
15670
  if (!$brset && $tbd['style']=='double') {
@@ -15675,8 +15674,8 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15675
  }
15676
  }
15677
 
15678
- $this->SetDash();
15679
- $this->y = $save_y;
15680
 
15681
 
15682
  // BACKGROUNDS are disabled in columns/kbt/headers - messes up the repositioning in printcolumnbuffer
@@ -15742,12 +15741,12 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15742
  $shadow .= $s; // Use the clipping path with W*
15743
  $shadow .= sprintf('0 %.3F m %.3F %.3F l ', $this->h*_MPDFK, $this->w*_MPDFK, $this->h*_MPDFK);
15744
  $shadow .= sprintf('%.3F 0 l 0 0 l 0 %.3F l ', $this->w*_MPDFK, $this->h*_MPDFK);
15745
- $shadow .= 'W n'."\n";
15746
 
15747
  $sh['blur'] = abs($sh['blur']); // cannot have negative blur value
15748
  // Ensure spread/blur do not make effective shadow width/height < 0
15749
  // Could do more complex things but this just adjusts spread value
15750
- if (-$sh['spread'] + $sh['blur']/2 > min($w/2, $h/2)) {
15751
  $sh['spread'] = $sh['blur']/2 - min($w/2, $h/2) + 0.01;
15752
  }
15753
  // Shadow Offset
@@ -15757,13 +15756,13 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15757
  $shadow .= ' q 0 w ';
15758
  $shadow .= $this->SetFColor($col1, true)."\n";
15759
  if ($col1{0}==5 && ord($col1{4})<100) { // RGBa
15760
- $shadow .= $this->SetAlpha(ord($col1{4})/100, 'Normal', true, 'F')."\n";
15761
  }
15762
  else if ($col1{0}==6 && ord($col1{5})<100) { // CMYKa
15763
- $shadow .= $this->SetAlpha(ord($col1{5})/100, 'Normal', true, 'F')."\n";
15764
  }
15765
  else if ($col1{0}==1 && $col1{2}==1 && ord($col1{3})<100) { // Gray
15766
- $shadow .= $this->SetAlpha(ord($col1{3})/100, 'Normal', true, 'F')."\n";
15767
  }
15768
 
15769
  // Blur edges
@@ -15830,7 +15829,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15830
 
15831
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15832
  $patch_array[1]['f']=2;
15833
- $patch_array[1]['points']=array($p2x,$p2y,
15834
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15835
  $p4c1x,$p4y, $p4x,$p4y, $p4x,$p4y,
15836
  $p1x,$p1y);
@@ -15845,7 +15844,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15845
  $p3x = $x00+$w00-$d1-$brbgBR_H; $p3c1x = $p3x + ($d1+$brbgBR_H)*$mag;
15846
  $p3y = $y00+$h00; $p3c2y = $p3y - $bl/2;
15847
  $p4x = $x00+$w00-$d1-$brbgBR_H; $p4c2x = $p4x + ($d2+$brbgBR_H)*$mag;
15848
- $p4y = $y00+$h00-$bl;
15849
 
15850
  if (-$d2 > min($brbgBR_H, $brbgBR_V) || $flatten) {
15851
  $p1y = $y00+$h00-$bl; $p1c2y = $p1y;
@@ -15870,7 +15869,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15870
  $p2x = $x00+$w00-$d1-$brbgBR_H; // control point only matches p4 preceding
15871
  $p2y = $y00+$h00-$bl;
15872
  $p3x = $x00+$d1+$brbgBL_H;
15873
- $p3y = $y00+$h00-$bl;
15874
  $p4x = $x00+$d1+$brbgBL_H;
15875
  $p4y = $y00+$h00; $p4c1y = $p4y - $bl/2;
15876
 
@@ -15885,7 +15884,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15885
 
15886
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15887
  $patch_array[3]['f']=2;
15888
- $patch_array[3]['points']=array($p2x,$p2y,
15889
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15890
  $p4x,$p4c1y, $p4x,$p4y, $p4x,$p4y,
15891
  $p1x,$p1y);
@@ -15922,21 +15921,21 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15922
  $p2x = $x00+$bl; // control point only matches p4 preceding
15923
  $p2y = $y00+$h00-$d1-$brbgBL_V;
15924
  $p3x = $x00+$bl;
15925
- $p3y = $y00+$d1+$brbgTL_V;
15926
  $p4x = $x00; $p4c1x = $p4x + $bl/2;
15927
- $p4y = $y00+$d1+$brbgTL_V;
15928
  if (-$d2 > min($brbgBL_H, $brbgBL_V) || $flatten) {
15929
  $p1y = $y00+$h00-$bl;
15930
  $p2y = $y00+$h00-$bl;
15931
  }
15932
  if (-$d2 > min($brbgTL_H, $brbgTL_V) || $flatten) {
15933
- $p3y = $y00+$bl;
15934
- $p4y = $y00+$bl;
15935
  }
15936
 
15937
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15938
  $patch_array[5]['f']=2;
15939
- $patch_array[5]['points']=array($p2x,$p2y,
15940
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15941
  $p4c1x,$p4y, $p4x,$p4y, $p4x,$p4y,
15942
  $p1x,$p1y);
@@ -15974,7 +15973,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15974
  $p2x = $x00+$d1+$brbgTL_H; // control point only matches p4 preceding
15975
  $p2y = $y00+$bl;
15976
  $p3x = $x00+$w00-$d1-$brbgTR_H;
15977
- $p3y = $y00+$bl;
15978
  $p4x = $x00+$w00-$d1-$brbgTR_H;
15979
  $p4y = $y00; $p4c1y = $p4y + $bl/2;
15980
  if (-$d2 > min($brbgTL_H, $brbgTL_V) || $flatten) {
@@ -15988,7 +15987,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
15988
 
15989
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15990
  $patch_array[7]['f']=2;
15991
- $patch_array[7]['points']=array($p2x,$p2y,
15992
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15993
  $p4x,$p4c1y, $p4x,$p4y, $p4x,$p4y,
15994
  $p1x,$p1y);
@@ -16025,7 +16024,7 @@ function PaintDivBB($divider='',$blockstate=0,$blvl=0) {
16025
  function PaintDivLnBorder($state=0,$blvl=0,$h) {
16026
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
16027
 
16028
- $this->ColDetails[$this->CurrCol]['bottom_margin'] = $this->y + $h;
16029
 
16030
  $save_y = $this->y;
16031
 
@@ -16046,10 +16045,10 @@ function PaintDivLnBorder($state=0,$blvl=0,$h) {
16046
  // Reset Corners and Dash off
16047
  $this->SetLineJoin(2);
16048
  $this->SetLineCap(2);
16049
- $this->SetDash();
16050
  }
16051
  }
16052
- if ($this->blk[$blvl]['border_left']) {
16053
  $tbd = $this->blk[$blvl]['border_left'];
16054
  if (isset($tbd['s']) && $tbd['s']) {
16055
  $this->_setBorderLine($tbd);
@@ -16060,10 +16059,10 @@ function PaintDivLnBorder($state=0,$blvl=0,$h) {
16060
  // Reset Corners and Dash off
16061
  $this->SetLineJoin(2);
16062
  $this->SetLineCap(2);
16063
- $this->SetDash();
16064
  }
16065
  }
16066
- if ($this->blk[$blvl]['border_right']) {
16067
  $tbd = $this->blk[$blvl]['border_right'];
16068
  if (isset($tbd['s']) && $tbd['s']) {
16069
  $this->_setBorderLine($tbd);
@@ -16074,10 +16073,10 @@ function PaintDivLnBorder($state=0,$blvl=0,$h) {
16074
  // Reset Corners and Dash off
16075
  $this->SetLineJoin(2);
16076
  $this->SetLineCap(2);
16077
- $this->SetDash();
16078
  }
16079
  }
16080
- if ($this->blk[$blvl]['border_bottom'] && $state > 1) {
16081
  $tbd = $this->blk[$blvl]['border_bottom'];
16082
  if (isset($tbd['s']) && $tbd['s']) {
16083
  $this->_setBorderLine($tbd);
@@ -16088,11 +16087,11 @@ function PaintDivLnBorder($state=0,$blvl=0,$h) {
16088
  // Reset Corners and Dash off
16089
  $this->SetLineJoin(2);
16090
  $this->SetLineCap(2);
16091
- $this->SetDash();
16092
  }
16093
  }
16094
- $this->SetDash();
16095
- $this->y = $save_y;
16096
  }
16097
 
16098
 
@@ -16105,7 +16104,7 @@ function PaintImgBorder($objattr,$is_table) {
16105
  $y0 = (isset($objattr['BORDER-Y']) ? $objattr['BORDER-Y'] : 0);
16106
 
16107
  // BORDERS
16108
- if ($objattr['border_top']) {
16109
  $tbd = $objattr['border_top'];
16110
  if (!empty($tbd['s'])) {
16111
  $this->_setBorderLine($tbd,$k);
@@ -16114,10 +16113,10 @@ function PaintImgBorder($objattr,$is_table) {
16114
  // Reset Corners and Dash off
16115
  $this->SetLineJoin(2);
16116
  $this->SetLineCap(2);
16117
- $this->SetDash();
16118
  }
16119
  }
16120
- if ($objattr['border_left']) {
16121
  $tbd = $objattr['border_left'];
16122
  if (!empty($tbd['s'])) {
16123
  $this->_setBorderLine($tbd,$k);
@@ -16126,10 +16125,10 @@ function PaintImgBorder($objattr,$is_table) {
16126
  // Reset Corners and Dash off
16127
  $this->SetLineJoin(2);
16128
  $this->SetLineCap(2);
16129
- $this->SetDash();
16130
  }
16131
  }
16132
- if ($objattr['border_right']) {
16133
  $tbd = $objattr['border_right'];
16134
  if (!empty($tbd['s'])) {
16135
  $this->_setBorderLine($tbd,$k);
@@ -16138,10 +16137,10 @@ function PaintImgBorder($objattr,$is_table) {
16138
  // Reset Corners and Dash off
16139
  $this->SetLineJoin(2);
16140
  $this->SetLineCap(2);
16141
- $this->SetDash();
16142
  }
16143
  }
16144
- if ($objattr['border_bottom']) {
16145
  $tbd = $objattr['border_bottom'];
16146
  if (!empty($tbd['s'])) {
16147
  $this->_setBorderLine($tbd,$k);
@@ -16150,10 +16149,10 @@ function PaintImgBorder($objattr,$is_table) {
16150
  // Reset Corners and Dash off
16151
  $this->SetLineJoin(2);
16152
  $this->SetLineCap(2);
16153
- $this->SetDash();
16154
  }
16155
  }
16156
- $this->SetDash();
16157
  $this->SetAlpha(1);
16158
  }
16159
 
@@ -16166,7 +16165,7 @@ function Reset() {
16166
  $this->SetDColor($this->ConvertColor(0));
16167
  $this->SetFColor($this->ConvertColor(255));
16168
  $this->SetAlpha(1);
16169
- $this->colorarray = '';
16170
 
16171
  $this->spanbgcolorarray = '';
16172
  $this->spanbgcolor = false;
@@ -16188,8 +16187,8 @@ function Reset() {
16188
  $this->SetFont($this->default_font,'',0,false);
16189
  $this->SetFontSize($this->default_font_size,false);
16190
 
16191
- $this->currentfontfamily = '';
16192
- $this->currentfontsize = '';
16193
 
16194
  if ($this->tableLevel) {
16195
  $this->SetLineHeight('',$this->table_lineheight); // *TABLES*
@@ -16206,10 +16205,10 @@ function Reset() {
16206
 
16207
  $this->toupper = false;
16208
  $this->tolower = false;
16209
- $this->kerning = false;
16210
  $this->lSpacingCSS = '';
16211
  $this->wSpacingCSS = '';
16212
- $this->fixedlSpacing = false;
16213
  $this->minwSpacing = 0;
16214
  $this->capitalize = false;
16215
  $this->SetDash(); //restore to no dash
@@ -16231,10 +16230,10 @@ function Reset() {
16231
 
16232
  function ReadMetaTags($html) {
16233
  // changes anykey=anyvalue to anykey="anyvalue" (only do this when this happens inside tags)
16234
- $regexp = '/ (\\w+?)=([^\\s>"]+)/si';
16235
  $html = preg_replace($regexp," \$1=\"\$2\"",$html);
16236
  if (preg_match('/<title>(.*?)<\/title>/si',$html,$m)) {
16237
- $this->SetTitle($m[1]);
16238
  }
16239
  preg_match_all('/<meta [^>]*?(name|content)="([^>]*?)" [^>]*?(name|content)="([^>]*?)".*?>/si',$html,$aux);
16240
  $firstattr = $aux[1];
@@ -16257,7 +16256,7 @@ function ReadCharset($html) {
16257
  if ($this->allow_charset_conversion) {
16258
  if (preg_match('/<head.*charset=([^\'\"\s]*).*<\/head>/si',$html,$m)) {
16259
  if (strtoupper($m[1]) != 'UTF-8') {
16260
- $this->charset_in = strtoupper($m[1]);
16261
  }
16262
  }
16263
  }
@@ -16326,13 +16325,13 @@ function ReadDefaultCSS($CSSstr) {
16326
  function ReadCSS($html) {
16327
  preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
16328
  for($i=0; $i<count($m[0]); $i++) {
16329
- if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16330
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
16331
  }
16332
  }
16333
  preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
16334
  for($i=0; $i<count($m[0]); $i++) {
16335
- if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16336
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
16337
  }
16338
  }
@@ -16344,9 +16343,9 @@ function ReadCSS($html) {
16344
  // case so we can use str_replace later.
16345
  preg_replace('/<\/style>/i', '</style>', $html);
16346
  preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
16347
- if (count($m[1])) {
16348
  for($i=0;$i<count($m[1]);$i++) {
16349
- // Remove comment tags
16350
  $sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
16351
  $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
16352
  $html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
@@ -16360,20 +16359,20 @@ function ReadCSS($html) {
16360
 
16361
  $match = 0; // no match for instance
16362
  $regexp = ''; // This helps debugging: showing what is the REAL string being processed
16363
- $CSSext = array();
16364
 
16365
  //CSS inside external files
16366
  $regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
16367
  $x = preg_match_all($regexp,$html,$cxt);
16368
- if ($x) {
16369
- $match += $x;
16370
  $CSSext = $cxt[1];
16371
  }
16372
 
16373
  $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
16374
  $x = preg_match_all($regexp,$html,$cxt);
16375
- if ($x) {
16376
- $match += $x;
16377
  $CSSext = array_merge($CSSext,$cxt[1]);
16378
  }
16379
 
@@ -16381,8 +16380,8 @@ function ReadCSS($html) {
16381
  //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
16382
  $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
16383
  $x = preg_match_all($regexp,$html,$cxt);
16384
- if ($x) {
16385
- $match += $x;
16386
  $CSSext = array_merge($CSSext,$cxt[1]);
16387
  }
16388
 
@@ -16390,8 +16389,8 @@ function ReadCSS($html) {
16390
  //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
16391
  $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
16392
  $x = preg_match_all($regexp,$html,$cxt);
16393
- if ($x) {
16394
- $match += $x;
16395
  $CSSext = array_merge($CSSext,$cxt[1]);
16396
  }
16397
 
@@ -16402,7 +16401,7 @@ function ReadCSS($html) {
16402
 
16403
  while($match){
16404
  $path = $CSSext[$ind];
16405
- $this->GetFullPath($path);
16406
  $CSSextblock = $this->_get_file($path);
16407
  if ($CSSextblock) {
16408
  // look for embedded @import stylesheets in other stylesheets
@@ -16411,17 +16410,17 @@ function ReadCSS($html) {
16411
  $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
16412
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
16413
  $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
16414
- if ($xem) {
16415
  foreach($cxtem[1] AS $cxtembedded) {
16416
  // path is relative to original stlyesheet!!
16417
  $this->GetFullPath($cxtembedded, $cssBasePath );
16418
- $match++;
16419
  $CSSext[] = $cxtembedded;
16420
  }
16421
  }
16422
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
16423
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
16424
- if ($xem) {
16425
  for ($i=0;$i<count($cxtem[0]);$i++) {
16426
  // path is relative to original stlyesheet!!
16427
  $embedded = $cxtem[2][$i];
@@ -16439,13 +16438,13 @@ function ReadCSS($html) {
16439
 
16440
  $match = 0; // reset value, if needed
16441
  // CSS as <style> in HTML document
16442
- $regexp = '/<style.*?>(.*?)<\/style>/si';
16443
  $match = preg_match_all($regexp,$html,$CSSblock);
16444
  if ($match) {
16445
  $tmpCSSstr = implode(' ',$CSSblock[1]);
16446
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
16447
  $xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
16448
- if ($xem) {
16449
  for ($i=0;$i<count($cxtem[0]);$i++) {
16450
  $embedded = $cxtem[2][$i];
16451
  if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
@@ -16460,10 +16459,10 @@ function ReadCSS($html) {
16460
  $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
16461
  $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
16462
 
16463
- if (preg_match('/@media/',$CSSstr)) {
16464
  preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
16465
  for($i=0; $i<count($m[0]); $i++) {
16466
- if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16467
  $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
16468
  }
16469
  else {
@@ -16475,7 +16474,7 @@ function ReadCSS($html) {
16475
  // mPDF 5.5.13
16476
  // Replace any background: url(data:image... with temporary image file reference
16477
  preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*)\))/si", $CSSstr, $idata);
16478
- if (count($idata[0])) {
16479
  for($i=0;$i<count($idata[0]);$i++) {
16480
  $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
16481
  //Save to local file
@@ -16493,7 +16492,7 @@ function ReadCSS($html) {
16493
  $stylestr= trim($styles[2][$i]);
16494
  $stylearr = explode(';',$stylestr);
16495
  foreach($stylearr AS $sta) {
16496
- if (trim($sta)) {
16497
  // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
16498
  list($property,$value) = explode(':',$sta,2);
16499
  $property = trim($property);
@@ -16501,8 +16500,8 @@ function ReadCSS($html) {
16501
  $value = trim($value);
16502
  if ($property && ($value || $value==='0')) {
16503
  // Ignores -webkit-gradient so doesn't override -moz-
16504
- if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) {
16505
- continue;
16506
  }
16507
  $classproperties[strtoupper($property)] = $value;
16508
  }
@@ -16524,13 +16523,13 @@ function ReadCSS($html) {
16524
  if (isset($tags[2])) { $t3 = trim($tags[2]); }
16525
  $tag = '';
16526
  if ($level==1) { $tag = $t; }
16527
- else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) {
16528
- $tag = $t.'>>PSEUDO>>'.$m[1];
16529
- if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mirrorMargins
16530
  }
16531
  else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
16532
- else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) {
16533
- $tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1];
16534
  if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mirrorMargins
16535
  }
16536
  if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
@@ -16571,9 +16570,9 @@ function ReadCSS($html) {
16571
  }
16572
 
16573
  if ($tag) {
16574
- $x = &$this->cascadeCSS;
16575
  foreach($tmp AS $tp) { $x = &$x[$tp]; }
16576
- $x = $this->array_merge_recursive_unique($x, $classproperties);
16577
  $x['depth'] = $level;
16578
  }
16579
  }
@@ -16585,7 +16584,7 @@ function ReadCSS($html) {
16585
  }
16586
  } // end of if
16587
  //Remove CSS (tags and content), if any
16588
- $regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
16589
  $html = preg_replace($regexp,'',$html);
16590
  //print_r($this->CSS); exit;
16591
  //print_r($this->cascadeCSS); exit;
@@ -16605,8 +16604,8 @@ function readInlineCSS($html) {
16605
  $classproperties = array();
16606
  for($i = 0; $i < count($properties) ; $i++) {
16607
  // Ignores -webkit-gradient so doesn't override -moz-
16608
- if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
16609
- continue;
16610
  }
16611
  $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
16612
  }
@@ -16631,7 +16630,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16631
  }
16632
  else{
16633
  $v = strtoupper($v);
16634
- if (isset($this->fontsizes[$v])) {
16635
  $this->SetFontSize( $this->fontsizes[$v]* $this->default_font_size,false);
16636
  }
16637
  }
@@ -16639,7 +16638,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16639
  }
16640
 
16641
 
16642
- if ($this->useLang && !$this->usingCoreFont) {
16643
  if (isset($arrayaux['LANG']) && $arrayaux['LANG'] && $arrayaux['LANG'] != $this->default_lang && ((strlen($arrayaux['LANG']) == 5 && $arrayaux['LANG'] != 'UTF-8') || strlen($arrayaux['LANG']) == 2)) {
16644
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($arrayaux['LANG'], $this->useAdobeCJK);
16645
  if ($mpdf_pdf_unifonts) { $this->RestrictUnicodeFonts($mpdf_pdf_unifonts); }
@@ -16650,8 +16649,8 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16650
  if ($mpdf_pdf_unifonts) { $this->default_available_fonts = $mpdf_pdf_unifonts; }
16651
  }
16652
  }
16653
- else {
16654
- $this->RestrictUnicodeFonts($this->default_available_fonts );
16655
  }
16656
  }
16657
 
@@ -16667,11 +16666,11 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16667
  $fonttype = preg_replace('/ /','',$fonttype);
16668
  $v = strtolower(trim($fonttype));
16669
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
16670
- if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) ||
16671
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
16672
- ($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
16673
- in_array($v, array('sjis','uhc','big5','gb'))) {
16674
- $fonttype = $v;
16675
  $found = 1;
16676
  break;
16677
  }
@@ -16683,20 +16682,20 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16683
  $fonttype = preg_replace('/ /','',$fonttype);
16684
  $v = strtolower(trim($fonttype));
16685
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
16686
- if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
16687
- $fonttype = $v;
16688
  break;
16689
  }
16690
  }
16691
  }
16692
 
16693
- if ($tag == 'BODY') {
16694
- $this->SetDefaultFont($fonttype);
16695
  }
16696
  $this->SetFont($fonttype,$this->currentfontstyle,0,false);
16697
  }
16698
- else {
16699
- $this->SetFont($this->currentfontfamily,$this->currentfontstyle,0,false);
16700
  }
16701
 
16702
  foreach($arrayaux as $k => $v) {
@@ -16741,7 +16740,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16741
  if ($tmp > $this->blk[$this->blklvl]['lastbottommargin']) {
16742
  $tmp -= $this->blk[$this->blklvl]['lastbottommargin'];
16743
  }
16744
- else {
16745
  $tmp = 0;
16746
  }
16747
  }
@@ -16773,8 +16772,8 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16773
  break;
16774
 
16775
  case 'WIDTH':
16776
- if (strtoupper($v) != 'AUTO') {
16777
- $this->blk[$this->blklvl]['css_set_width'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
16778
  }
16779
  break;
16780
 
@@ -16801,23 +16800,23 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16801
 
16802
  case 'TEXT-ALIGN': //left right center justify
16803
  switch (strtoupper($v)) {
16804
- case 'LEFT':
16805
  $this->blk[$this->blklvl]['align']="L";
16806
  break;
16807
- case 'CENTER':
16808
  $this->blk[$this->blklvl]['align']="C";
16809
  break;
16810
- case 'RIGHT':
16811
  $this->blk[$this->blklvl]['align']="R";
16812
  break;
16813
- case 'JUSTIFY':
16814
  $this->blk[$this->blklvl]['align']="J";
16815
  break;
16816
  }
16817
  break;
16818
 
16819
 
16820
- case 'DIRECTION':
16821
  if ($v) { $this->blk[$this->blklvl]['direction'] = strtolower($v); }
16822
  break;
16823
 
@@ -16830,7 +16829,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16830
  case 'DISPLAY': // Custom tag to collapse margins at top and bottom of page
16831
  if (strtoupper($v) == 'NONE') { $this->inlineDisplayOff = true; }
16832
  break;
16833
- case 'DIRECTION':
16834
  break;
16835
  }//end of switch($k)
16836
  }
@@ -16866,10 +16865,10 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16866
  }
16867
  break;
16868
  // bgcolor only - to stay consistent with original html2fpdf
16869
- case 'BACKGROUND':
16870
- case 'BACKGROUND-COLOR':
16871
  $cor = $this->ConvertColor($v);
16872
- if ($cor) {
16873
  if ($tag == 'BODY') {
16874
  $this->bodyBackgroundColor = $cor;
16875
  }
@@ -16883,7 +16882,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16883
  }
16884
  }
16885
  else if ($type != 'INLINE' && $type != 'LIST') {
16886
- if ($this->ColActive || $this->keep_block_together) {
16887
  $this->blk[$this->blklvl]['bgcolorarray'] = $this->blk[$this->blklvl-1]['bgcolorarray'] ;
16888
  $this->blk[$this->blklvl]['bgcolor'] = $this->blk[$this->blklvl-1]['bgcolor'] ;
16889
  }
@@ -16891,22 +16890,22 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16891
  break;
16892
 
16893
  // auto | normal | none
16894
- case 'FONT-KERNING':
16895
  if ((strtoupper($v) == 'NORMAL' || strtoupper($v) == 'AUTO') && $this->useKerning) { $this->kerning = true; }
16896
  else if (strtoupper($v) == 'NONE') { $this->kerning = false; }
16897
  break;
16898
 
16899
 
16900
  // normal | <length>
16901
- case 'LETTER-SPACING':
16902
  $this->lSpacingCSS = $v;
16903
- if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
16904
  $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
16905
  }
16906
  break;
16907
 
16908
  // normal | <length>
16909
- case 'WORD-SPACING':
16910
  $this->wSpacingCSS = $v;
16911
  if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
16912
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
@@ -16915,11 +16914,11 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16915
 
16916
  case 'FONT-STYLE': // italic normal oblique
16917
  switch (strtoupper($v)) {
16918
- case 'ITALIC':
16919
- case 'OBLIQUE':
16920
  $this->SetStyle('I',true);
16921
  break;
16922
- case 'NORMAL':
16923
  $this->SetStyle('I',false);
16924
  break;
16925
  }
@@ -16927,10 +16926,10 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16927
 
16928
  case 'FONT-WEIGHT': // normal bold //Does not support: bolder, lighter, 100..900(step value=100)
16929
  switch (strtoupper($v)) {
16930
- case 'BOLD':
16931
  $this->SetStyle('B',true);
16932
  break;
16933
- case 'NORMAL':
16934
  $this->SetStyle('B',false);
16935
  break;
16936
  }
@@ -16938,10 +16937,10 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16938
 
16939
  case 'VERTICAL-ALIGN': //super and sub only dealt with here e.g. <SUB> and <SUP>
16940
  switch (strtoupper($v)) {
16941
- case 'SUPER':
16942
  $this->SUP=true;
16943
  break;
16944
- case 'SUB':
16945
  $this->SUB=true;
16946
  break;
16947
  }
@@ -16956,12 +16955,12 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16956
  }
16957
  break;
16958
 
16959
- case 'FONT-VARIANT':
16960
  switch (strtoupper($v)) {
16961
- case 'SMALL-CAPS':
16962
  $this->SetStyle('S',true);
16963
  break;
16964
- case 'NORMAL':
16965
  $this->SetStyle('S',false);
16966
  break;
16967
  }
@@ -16970,7 +16969,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16970
  case 'TEXT-TRANSFORM': // none uppercase lowercase //Does support: capitalize
16971
  switch (strtoupper($v)) { //Not working 100%
16972
  case 'CAPITALIZE':
16973
- $this->capitalize=true;
16974
  break;
16975
  case 'UPPERCASE':
16976
  $this->toupper=true;
@@ -16987,7 +16986,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16987
  if ($ts) { $this->textshadow = $ts; }
16988
  break;
16989
 
16990
- case 'OUTLINE-WIDTH':
16991
  switch(strtoupper($v)) {
16992
  case 'THIN': $v = '0.03em'; break;
16993
  case 'MEDIUM': $v = '0.05em'; break;
@@ -16996,7 +16995,7 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
16996
  $this->outlineparam['WIDTH'] = $this->ConvertSize($v,$this->blk[$this->blklvl]['inner_width'],$this->FontSize);
16997
  break;
16998
 
16999
- case 'OUTLINE-COLOR':
17000
  if (strtoupper($v) == 'INVERT') {
17001
  if ($this->colorarray) {
17002
  $cor = $this->colorarray;
@@ -17006,17 +17005,17 @@ function setCSS($arrayaux,$type='',$tag='') { // type= INLINE | BLOCK | LIST //
17006
  $this->outlineparam['COLOR'] = $this->ConvertColor(255);
17007
  }
17008
  }
17009
- else {
17010
  $cor = $this->ConvertColor($v);
17011
- if ($cor) { $this->outlineparam['COLOR'] = $cor ; }
17012
  }
17013
  break;
17014
 
17015
  case 'COLOR': // font color
17016
  $cor = $this->ConvertColor($v);
17017
- if ($cor) {
17018
  $this->colorarray = $cor;
17019
- $this->SetTColor($cor);
17020
  }
17021
  break;
17022
 
@@ -17099,40 +17098,40 @@ function DisableTags($str='')
17099
  function finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight) {
17100
  $af = 0; // Above font
17101
  $bf = 0; // Below font
17102
- $mta = 0; // Maximum top-aligned
17103
- $mba = 0; // Maximum bottom-aligned
17104
  if ($lhxt['BS']) {
17105
  $af = max($af, ($lhxt['BS'] - ($maxfontsize * (0.5 + $this->baselineC))));
17106
  }
17107
- if ($lhxt['M']) {
17108
  $af = max($af, ($lhxt['M'] - $maxfontsize)/2);
17109
  $bf = max($bf, ($lhxt['M'] - $maxfontsize)/2);
17110
  }
17111
- if ($lhxt['TT']) {
17112
  $bf = max($bf, ($lhxt['TT'] - $maxfontsize));
17113
  }
17114
- if ($lhxt['TB']) {
17115
  $af = max($af, ($lhxt['TB'] - $maxfontsize));
17116
  }
17117
- if ($lhxt['T']) {
17118
  $mta = max($mta, $lhxt['T']);
17119
  }
17120
- if ($lhxt['B']) {
17121
  $mba = max($mba, $lhxt['B']);
17122
  }
17123
  if ((!$lhfixed || !$forceExactLineheight) && ($af > (($maxlineHeight - $maxfontsize)/2) || $bf > (($maxlineHeight - $maxfontsize)/2))) {
17124
  $maxlineHeight = $maxfontsize + $af + $bf;
17125
  }
17126
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
17127
- if ($mta > $maxlineHeight) {
17128
  $bf += ($mta - $maxlineHeight);
17129
  $maxlineHeight = $mta;
17130
  }
17131
- if ($mba > $maxlineHeight) {
17132
  $af += ($mba - $maxlineHeight);
17133
  $maxlineHeight = $mba;
17134
  }
17135
- return $maxlineHeight;
17136
  }
17137
 
17138
  function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsize, $returnarray=false) { // NB ** returnarray used in flowchart
@@ -17153,7 +17152,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17153
  if ((count($textbuffer) == 0) or ((count($textbuffer) == 1) && ($textbuffer[0][0] == ''))) { return 0; }
17154
 
17155
  $text = '';
17156
- $lhfixed = false;
17157
  if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight)) { $lhfixed = true; }
17158
  if ($lhfixed) { $def_lineheight = $this->_computeLineheight($this->table_lineheight, $def_fontsize);}
17159
  else { $def_lineheight = 0; }
@@ -17195,7 +17194,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17195
  list($skipln,$iw,$ih) = $this->inlineObject((isset($specialcontent['type']) ? $specialcontent['type'] : null),0,0, $objattr, $this->lMargin,$width,$maxwidth,$maxlineHeight,false,true);
17196
  if ($objattr['type'] == 'hr') {
17197
  // END OF LINE
17198
- // Finalise & add lineheight
17199
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17200
  // Add HR height
17201
  $ch += $ih;
@@ -17214,7 +17213,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17214
  if ($skipln==1 || $skipln==-2) {
17215
  // Finish last line
17216
  // END OF LINE
17217
- // Finalise & add lineheight
17218
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17219
  // START OF NEW LINE
17220
  // Initialise lineheight variables
@@ -17226,7 +17225,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17226
  $width = 0;
17227
  $text = "";
17228
  }
17229
- $va = (isset($objattr['vertical-align']) ? $objattr['vertical-align'] : null);
17230
  if ($va) {
17231
  $lhxt[$va] = max($lhxt[$va], $ih);
17232
  }
@@ -17238,25 +17237,25 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17238
 
17239
  // SET FONT SIZE/STYLE from $chunk[n]
17240
  // FONTSIZE
17241
- if(isset($chunk[11]) and $chunk[11] != '') {
17242
  if ($this->shrin_k) {
17243
- $this->SetFontSize($chunk[11]/$this->shrin_k,false);
17244
  }
17245
  else {
17246
- $this->SetFontSize($chunk[11],false);
17247
  }
17248
  }
17249
  if ($line == "\n") {
17250
  // END OF LINE
17251
- $maxfontsize = max($maxfontsize,$this->FontSize);
17252
  $fh = $this->_computeLineheight($this->table_lineheight);
17253
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17254
  $fh = $this->FontSize;
17255
- $forceExactLineheight = false;
17256
  }
17257
- $maxlineHeight = max($maxlineHeight,$fh);
17258
 
17259
- // Finalise & add lineheight
17260
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17261
  // START OF NEW LINE
17262
  // Initialise lineheight variables
@@ -17267,7 +17266,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17267
  $ln++;
17268
  $text = "";
17269
  $width = 0;
17270
- if(isset($chunk[11]) and $chunk[11] != '') {
17271
  $this->SetFontSize($this->default_font_size,false);
17272
  }
17273
  continue;
@@ -17280,19 +17279,19 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17280
  if (isset($this->spanborddet['R'])) $rbw = $this->spanborddet['R']['w'];
17281
  }
17282
  if(isset($chunk[15])) { // Word spacing
17283
- $this->wSpacingCSS = $chunk[15];
17284
- if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
17285
- $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
17286
  }
17287
  }
17288
  if(isset($chunk[14])) { // Letter spacing
17289
- $this->lSpacingCSS = $chunk[14];
17290
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
17291
  $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
17292
  }
17293
  }
17294
  if(isset($chunk[13])) { // Font Kerning
17295
- $this->kerning = $chunk[13];
17296
  }
17297
  // FONTFAMILY
17298
  if(isset($chunk[4]) and $chunk[4] != '') { $font = $this->SetFont($chunk[4],$this->FontStyle,0,false); }
@@ -17346,19 +17345,19 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17346
  }
17347
  if (!$oneCJKorphan && (preg_match('/[\.\]),;:!?"'.$curlyquote . $curlylowquote . $raquote.$rsquo.$sbquo.$bdquo.']$/'.$matchsuff,mb_substr($word,0,$i+1,$this->mb_enc )) || (!$this->usingCoreFont && preg_match('/['.$this->CJKoverflow.']$/u',mb_substr($word,0,$i+1,$this->mb_enc ))))) { // mPDF.5.5.01 mPDF.5.5.05 mPDF 5.5.07 // mPDF 5.5.20
17348
  $wordwidth = $maxwidth - 0.0001;
17349
- $oneCJKorphan = true;
17350
  continue;
17351
  }
17352
  if ($text && $firstchunk) {
17353
  // END OF LINE
17354
- // Finalise & add lineheight
17355
- $maxfontsize = max($maxfontsize,$this->FontSize);
17356
  $fh = $this->_computeLineheight($this->table_lineheight);
17357
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17358
  $fh = $this->FontSize;
17359
- $forceExactLineheight = false;
17360
  }
17361
- $maxlineHeight = max($maxlineHeight,$fh);
17362
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17363
  // START OF NEW LINE
17364
  // Initialise lineheight variables
@@ -17369,14 +17368,14 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17369
  $ln++;
17370
  }
17371
  // END OF LINE
17372
- // Finalise & add lineheight
17373
- $maxfontsize = max($maxfontsize,$this->FontSize);
17374
  $fh = $this->_computeLineheight($this->table_lineheight);
17375
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17376
  $fh = $this->FontSize;
17377
- $forceExactLineheight = false;
17378
  }
17379
- $maxlineHeight = max($maxlineHeight,$fh);
17380
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17381
  // START OF NEW LINE
17382
  // Initialise lineheight variables
@@ -17389,7 +17388,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17389
  $text = mb_substr($word,0,$i,$this->mb_enc );
17390
  $word = mb_substr($word,$i,mb_strlen($word, $this->mb_enc )-$i,$this->mb_enc );
17391
  $wordwidth = $this->GetStringWidth($word);
17392
- $width = 0;
17393
  $firstchunk=false;
17394
  break;
17395
  }
@@ -17419,7 +17418,7 @@ function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsiz
17419
  if ($k==(count($words)-1)) { $tmpwidth += $rbw; }
17420
  if ($width + $tmpwidth < $maxwidth + 0.0001) { $alloworphans = true; }
17421
  }
17422
- // If line = SUB/SUP to max of orphansallowed ( $this->SUP || $this->SUB )
17423
  if(( (isset($chunk[5]) and $chunk[5]) || (isset($chunk[6]) and $chunk[6])) && strlen($word) <= $this->orphansAllowed) {
17424
  $alloworphans = true;
17425
  if ($k==1) { echo $word; exit; }
@@ -17434,14 +17433,14 @@ if ($k==1) { echo $word; exit; }
17434
  }
17435
  else {
17436
  // END OF LINE
17437
- // Finalise & add lineheight
17438
- $maxfontsize = max($maxfontsize,$this->FontSize);
17439
  $fh = $this->_computeLineheight($this->table_lineheight);
17440
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17441
  $fh = $this->FontSize;
17442
- $forceExactLineheight = false;
17443
  }
17444
- $maxlineHeight = max($maxlineHeight,$fh);
17445
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17446
  $mxw = $maxwidth;
17447
  // START OF NEW LINE
@@ -17455,13 +17454,13 @@ if ($k==1) { echo $word; exit; }
17455
  $text = $word.' ';
17456
  }
17457
  }
17458
- $maxfontsize = max($maxfontsize,$this->FontSize);
17459
  $fh = $this->_computeLineheight($this->table_lineheight);
17460
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17461
  $fh = $this->FontSize;
17462
- $forceExactLineheight = false;
17463
  }
17464
- $maxlineHeight = max($maxlineHeight,$fh);
17465
  }
17466
 
17467
  // End of textbuffer chunk
@@ -17479,15 +17478,15 @@ if ($k==1) { echo $word; exit; }
17479
  if(isset($chunk[4]) and $chunk[4] != '') {
17480
  $this->SetFont($this->default_font,$this->FontStyle,0,false);
17481
  }
17482
- if(isset($chunk[11]) and $chunk[11] != '') {
17483
  $this->SetFontSize($this->default_font_size,false);
17484
  }
17485
  $this->spanborddet = array();
17486
- $this->kerning = false;
17487
  $this->lSpacingCSS = '';
17488
  $this->wSpacingCSS = '';
17489
  $this->fixedlSpacing = false;
17490
- $this->minwSpacing = 0;
17491
  }
17492
  // Finalise lineheight if something output on line and add
17493
  if ($width) {
@@ -17513,7 +17512,7 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) {
17513
  // IMAGES & FORM ELEMENTS
17514
  if (substr($line,0,3) == "\xbb\xa4\xac") { //inline object - FORM element or IMAGE!
17515
  $objattr = $this->_getObjAttr($line);
17516
- if ($objattr['type']!='hr' && isset($objattr['width']) && ($objattr['width']/$this->shrin_k) > ($maxwidth + 0.0001) ) {
17517
  if (($objattr['width']/$this->shrin_k) > $biggestword) { $biggestword = ($objattr['width']/$this->shrin_k); }
17518
  $toonarrow=true;
17519
  }
@@ -17527,12 +17526,12 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) {
17527
  // SET FONT SIZE/STYLE from $chunk[n]
17528
 
17529
  // FONTSIZE
17530
- if(isset($chunk[11]) and $chunk[11] != '') {
17531
  if ($this->shrin_k) {
17532
- $this->SetFontSize($chunk[11]/$this->shrin_k,false);
17533
  }
17534
  else {
17535
- $this->SetFontSize($chunk[11],false);
17536
  }
17537
  }
17538
  // FONTFAMILY
@@ -17549,19 +17548,19 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) {
17549
  $rbw = $this->spanborddet['R']['w'];
17550
  }
17551
  if(isset($chunk[15])) { // Word spacing
17552
- $this->wSpacingCSS = $chunk[15];
17553
- if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
17554
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
17555
  }
17556
  }
17557
  if(isset($chunk[14])) { // Letter spacing
17558
- $this->lSpacingCSS = $chunk[14];
17559
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
17560
- $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
17561
  }
17562
  }
17563
  if(isset($chunk[13])) { // Font Kerning
17564
- $this->kerning = $chunk[13];
17565
  }
17566
 
17567
  $words = explode(' ', $line);
@@ -17587,7 +17586,7 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) {
17587
  if(isset($chunk[4]) and $chunk[4] != '') {
17588
  $this->SetFont($this->default_font,$this->FontStyle,0,false);
17589
  }
17590
- if(isset($chunk[11]) and $chunk[11] != '') {
17591
  $this->SetFontSize($this->default_font_size,false);
17592
  }
17593
  $this->spanborddet = array();
@@ -17598,10 +17597,10 @@ function TableCheckMinWidth($maxwidth, $forcewrap = 0, $textbuffer) {
17598
  $this->minwSpacing = 0;
17599
  }
17600
 
17601
- //Return -(wordsize) if word is bigger than maxwidth
17602
  // ADDED
17603
  if (($toonarrow) && ($this->table_error_report)) {
17604
- $this->Error("Word is too long to fit in table - ".$this->table_error_report_param);
17605
  }
17606
  if ($toonarrow) return -$biggestword;
17607
  else return 1;
@@ -17654,7 +17653,7 @@ function shrinkTable(&$table,$k) {
17654
  if ($this->cacheTables) {
17655
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
17656
  }
17657
- else
17658
  $c = &$table['cells'][$i][$j];
17659
  if (isset($c) && $c) {
17660
  if (!$this->simpleTables){
@@ -17703,7 +17702,7 @@ function shrinkTable(&$table,$k) {
17703
  if (isset($c['nestedmiw'])) $c['nestedmiw'] /= $k;
17704
  if (isset($c['textbuffer'])) {
17705
  foreach($c['textbuffer'] AS $n=>$tb) {
17706
- if (!empty($tb[16])) {
17707
  $c['textbuffer'][$n][16]['T']['w'] /= $k;
17708
  $c['textbuffer'][$n][16]['B']['w'] /= $k;
17709
  $c['textbuffer'][$n][16]['L']['w'] /= $k;
@@ -17760,7 +17759,7 @@ function _cacheCell($c, $file, $mode="A", $fh=null, $offset=0) { // mode = Appen
17760
  $c['gradient'] /* A128 (128 bytes) [pos 44 + 19*D] */
17761
  );
17762
 
17763
- if ($c['background-image']) {
17764
  $data .= pack("n2d2A6A6n3dA4A128",
17765
  strlen($data), /* offset in main data to start of bgimage data */
17766
  $c['background-image']['image_id'], /* n */
@@ -17782,7 +17781,7 @@ function _cacheCell($c, $file, $mode="A", $fh=null, $offset=0) { // mode = Appen
17782
  $lentb = strlen($stb);
17783
  $data2 = pack("nA".$lentb, $lentb, $stb);
17784
 
17785
- $tempfh = true;
17786
  if ($mode=="W" && $offset) {
17787
  if (!$fh) { $fh = fopen($file, "r+b"); } // Overwrite (but not truncate)
17788
  else $tempfh = false;
@@ -17806,13 +17805,13 @@ function _cacheUpdateTxB($c, $fh, $offset) {
17806
  fseek($fh, ($tb_offset-2), SEEK_CUR);
17807
  $lentb = $this->read_short($fh); // First entry in textbuffer = Length of serialized textbuffer - do not update
17808
  $stb = serialize($c['textbuffer']);
17809
- fwrite($fh, pack("A".$lentb, $stb));
17810
  }
17811
 
17812
  function _cacheUpdateBorder($c, $fh, $offset) {
17813
  $offset += 2;
17814
  fseek($fh, $offset);
17815
- fwrite($fh, $c['borderbin']);
17816
  }
17817
 
17818
  function _cacheUpdateMtx($c, $fh, $offset, $var) {
@@ -17829,7 +17828,7 @@ function _uncacheCell($ptr, $file, $fh) {
17829
  // Requires either $file or $fh (file_handle)
17830
  if ($ptr==0) { return null; }
17831
  if (is_array($ptr)) { $this->Error("Probable cause - missing end tag &lt;/td&gt;. You may be able to change the configurable variable: allow_html_optional_endtags "); }
17832
- $tempfh = true;
17833
  if (!$fh) { $fh = fopen($file, "rb"); }
17834
  else $tempfh = false;
17835
  fseek($fh, $ptr);
@@ -17864,12 +17863,12 @@ function _uncacheCell($ptr, $file, $fh) {
17864
  $c['a'] = trim($data['a']); /* A1 */
17865
  $c['va'] = trim($data['va']); /* A1 */
17866
  if ($data['nowrap']) $c['nowrap'] = $data['nowrap']; /* 1 or blank n */
17867
- else $c['nowrap'] = false;
17868
  if ($data['wpercent']>0) $c['wpercent'] = $data['wpercent']; /* 0 - 100 n */
17869
  if ($data['R']<>0) $c['R'] = $data['R']; /* 90 or -90 s */
17870
  else $c['R'] = false;
17871
  $c['bgcolor'] = trim($data['bgcol']); /* A32 */
17872
- if (trim($data['grad']))
17873
  $c['gradient'] = trim($data['grad']); /* A128 */
17874
  else $c['gradient'] = false;
17875
  if ($data['bgimage']>0) {
@@ -17888,8 +17887,8 @@ function _uncacheCell($ptr, $file, $fh) {
17888
  function read_short(&$fh) {
17889
  $s = fread($fh,2);
17890
  $a = (ord($s[0])<<8) + ord($s[1]);
17891
- if ($a & (1 << 15) ) {
17892
- $a = ($a - (1 << 16));
17893
  }
17894
  return $a;
17895
  }
@@ -18033,7 +18032,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18033
  $nr = $table['nr'];
18034
  $listspan = array();
18035
 
18036
- if ($table['borders_separate']) {
18037
  $tblbw = $table['border_details']['L']['w'] + $table['border_details']['R']['w'] + $table['margin']['L'] + $table['margin']['R'] + $table['padding']['L'] + $table['padding']['R'] + $table['border_spacing_H'];
18038
  }
18039
  else { $tblbw = $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2 + $table['margin']['L'] + $table['margin']['R']; }
@@ -18041,7 +18040,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18041
  if ($this->cacheTables) { $fh = fopen($table['cache'], "r+b"); }
18042
  else { $fh = null; }
18043
 
18044
- // ADDED table['l'][colno]
18045
  // = total length of text approx (using $c['s']) in that column - used to approximately distribute col widths in _tableWidth
18046
  //
18047
  for($j = 0 ; $j < $nc ; $j++ ) { //columns
@@ -18051,7 +18050,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18051
  if ($this->cacheTables) {
18052
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18053
  }
18054
- else
18055
  $c = &$cs[$i][$j];
18056
 
18057
  if ($this->simpleTables){
@@ -18066,7 +18065,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18066
  if ($this->packTableData) {
18067
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18068
  }
18069
- else {
18070
  $br = $c['border_details']['R']['w'];
18071
  $bl = $c['border_details']['L']['w'];
18072
  }
@@ -18092,8 +18091,8 @@ function _tableColumnWidth(&$table,$firstpass=false){
18092
  if ($wc['miw'] < $c['miw']) { $wc['miw'] = $c['miw']; }
18093
  if ($wc['maw'] < $c['maw']) { $wc['maw'] = $c['maw']; }
18094
 
18095
- if ($firstpass) {
18096
- if (isset($table['l'][$j]) ) {
18097
  $table['l'][$j] += $c['miw'] ;
18098
  }
18099
  else {
@@ -18101,7 +18100,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18101
  }
18102
  }
18103
  }
18104
- if ($c['miw'] > $wc['miw']) { $wc['miw'] = $c['miw']; }
18105
  if ($wc['miw'] > $wc['maw']) { $wc['maw'] = $wc['miw']; }
18106
  continue;
18107
  }
@@ -18125,7 +18124,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18125
  else $c['maw'] = $c['s'];
18126
 
18127
  if (isset($table['overflow']) && $table['overflow']=='visible' && $table['level']==1) {
18128
- if (($c['maw'] + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18129
  $c['maw'] = $this->blk[$this->blklvl]['inner_width'] - $tblbw;
18130
  }
18131
  }
@@ -18145,7 +18144,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18145
  }
18146
 
18147
  if (isset($table['overflow']) && $table['overflow']=='visible' && $table['level']==1) {
18148
- if (($c['w'] + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18149
  $c['w'] = $this->blk[$this->blklvl]['inner_width'] - $tblbw;
18150
  }
18151
  }
@@ -18165,7 +18164,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18165
  if ($wc['maw'] < $c['maw']) { $wc['maw'] = $c['maw']; }
18166
  if ((isset($wc['absmiw']) && $wc['absmiw'] < $c['absmiw']) || !isset($wc['absmiw'])) { $wc['absmiw'] = $c['absmiw']; } // Update Col Minimum and maximum widths
18167
 
18168
- if (isset($table['l'][$j]) ) {
18169
  $table['l'][$j] += $c['s'];
18170
  }
18171
  else {
@@ -18173,7 +18172,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18173
  }
18174
 
18175
  }
18176
- else {
18177
  $listspan[] = array($i,$j);
18178
  }
18179
 
@@ -18182,13 +18181,13 @@ function _tableColumnWidth(&$table,$firstpass=false){
18182
  $minwidth = $this->TableCheckMinWidth($wc['miw']- $extrcw ,0,$c['textbuffer']);
18183
  }
18184
  else { $minwidth = 0; }
18185
- if ($minwidth < 0) {
18186
  //increase minimum width
18187
  if (!isset($c['colspan'])) {
18188
- $wc['miw'] = max($wc['miw'],((-$minwidth) + $extrcw) );
18189
  }
18190
  else {
18191
- $c['miw'] = max($c['miw'],((-$minwidth) + $extrcw) );
18192
  }
18193
  }
18194
  if (!isset($c['colspan'])) {
@@ -18210,7 +18209,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18210
  if ($this->cacheTables) {
18211
  $c = $this->_uncacheCell($cs[$i][$j], '', $fh);
18212
  }
18213
- else
18214
  $c = &$cs[$i][$j];
18215
  $lc = $j + $c['colspan'];
18216
  if ($lc > $nc) { $lc = $nc; }
@@ -18218,7 +18217,7 @@ function _tableColumnWidth(&$table,$firstpass=false){
18218
  $was = $wasa = 0;
18219
  $list = array();
18220
  for($k=$j;$k<$lc;$k++) {
18221
- if (isset($table['l'][$k]) ) {
18222
  if ($c['R']) { $table['l'][$k] += $c['miw']/$c['colspan'] ; }
18223
  else { $table['l'][$k] += $c['s']/$c['colspan']; }
18224
  }
@@ -18322,9 +18321,9 @@ function _tableColumnWidth(&$table,$firstpass=false){
18322
  if ($miwleft && $sumnonpc > 0) { $miwnon = $miwleft * 100 / $sumnonpc; }
18323
  if ($mawleft && $sumnonpc > 0) { $mawnon = $mawleft * 100 / $sumnonpc; }
18324
  if (($miwnon > $checkminwidth || $maxcalcmiw > $checkminwidth) && $this->keep_table_proportions) {
18325
- if ($miwnon > $maxcalcmiw) {
18326
- $miwsurplusnonpc = round((($miwnon * $sumnonpc / 100) - $miwleft),3);
18327
- $checkminwidth = $miwnon;
18328
  }
18329
  else { $checkminwidth = $maxcalcmiw; }
18330
  for( $i = 0 ; $i < $nc ; $i++ ) {
@@ -18341,9 +18340,9 @@ function _tableColumnWidth(&$table,$firstpass=false){
18341
  }
18342
  }
18343
  if (($mawnon > $checkmaxwidth || $maxcalcmaw > $checkmaxwidth )) {
18344
- if ($mawnon > $maxcalcmaw) {
18345
- $mawsurplusnonpc = round((($mawnon * $sumnonpc / 100) - $mawleft),3);
18346
- $checkmaxwidth = $mawnon;
18347
  }
18348
  else { $checkmaxwidth = $maxcalcmaw; }
18349
  for( $i = 0 ; $i < $nc ; $i++ ) {
@@ -18387,11 +18386,11 @@ function _tableColumnWidth(&$table,$firstpass=false){
18387
  $mxw = $this->blk[$this->blklvl]['inner_width'];
18388
  }
18389
  if(!isset($table['overflow'])) { $table['overflow'] = null; }
18390
- if ($table['overflow']=='visible') {
18391
- return array(0,0);
18392
  }
18393
  else if ($table['overflow']=='hidden' && !$this->table_rotate && !$this->ColActive && $checkminwidth > $mxw) {
18394
- $table['w'] = $table['miw'];
18395
  return array(0,0);
18396
  }
18397
  else if ($table['overflow']=='wrap') { return array(0,0); }
@@ -18399,14 +18398,14 @@ function _tableColumnWidth(&$table,$firstpass=false){
18399
  if (isset($table['w']) && $table['w'] ) {
18400
  if ($table['w'] >= $checkminwidth && $table['w'] <= $mxw) { $table['maw'] = $mxw = $table['w']; }
18401
  else if ($table['w'] >= $checkminwidth && $table['w'] > $mxw && $this->keep_table_proportions) { $checkminwidth = $table['w']; }
18402
- else {
18403
- unset($table['w']);
18404
  }
18405
  }
18406
  $ratio = $checkminwidth/$mxw;
18407
  if ($checkminwidth > $mxw) { return array(($ratio +0.001),$checkminwidth); } // 0.001 to allow for rounded numbers when resizing
18408
  }
18409
- unset($cs);
18410
  return array(0,0);
18411
  }
18412
 
@@ -18416,17 +18415,17 @@ function _tableWidth(&$table){
18416
  $widthcols = &$table['wc'];
18417
  $numcols = $table['nc'];
18418
  $tablewidth = 0;
18419
- if ($table['borders_separate']) {
18420
  $tblbw = $table['border_details']['L']['w'] + $table['border_details']['R']['w'] + $table['margin']['L'] + $table['margin']['R'] + $table['padding']['L'] + $table['padding']['R'] + $table['border_spacing_H'];
18421
  }
18422
  else { $tblbw = $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2 + $table['margin']['L'] + $table['margin']['R']; }
18423
 
18424
- if ($table['level']>1 && isset($table['w'])) {
18425
- if (isset($table['wpercent']) && $table['wpercent']) {
18426
- $table['w'] = $temppgwidth = (($table['w']-$tblbw) * $table['wpercent'] / 100) + $tblbw ;
18427
  }
18428
- else {
18429
- $temppgwidth = $table['w'] ;
18430
  }
18431
  }
18432
  else if ($this->table_rotate) {
@@ -18437,15 +18436,15 @@ function _tableWidth(&$table){
18437
  if ($enddiv/$temppgwidth <0.05) { $temppgwidth -= $enddiv; }
18438
  }
18439
  else {
18440
- if (isset($table['w']) && $table['w']< $this->blk[$this->blklvl]['inner_width']) {
18441
  $notfullwidth = 1;
18442
- $temppgwidth = $table['w'] ;
18443
  }
18444
  else if ($table['overflow']=='visible' && $table['level'] ==1) {
18445
  $temppgwidth = null;
18446
  }
18447
  else if ($table['overflow']=='hidden' && !$this->ColActive && isset($table['w']) && $table['w'] > $this->blk[$this->blklvl]['inner_width'] && $table['w']==$table['miw']) {
18448
- //$temppgwidth = $this->blk[$this->blklvl]['inner_width'];
18449
  $temppgwidth = $table['w'] ;
18450
  }
18451
  else { $temppgwidth = $this->blk[$this->blklvl]['inner_width']; }
@@ -18454,7 +18453,7 @@ function _tableWidth(&$table){
18454
 
18455
  $totaltextlength = 0; // Added - to sum $table['l'][colno]
18456
  $totalatextlength = 0; // Added - to sum $table['l'][colno] for those columns where width not set
18457
- $percentages_set = 0;
18458
  for ( $i = 0 ; $i < $numcols ; $i++ ) {
18459
  if (isset($widthcols[$i]['wpercent'])) { $tablewidth += $widthcols[$i]['maw']; $percentages_set = 1; }
18460
  else if (isset($widthcols[$i]['w'])) { $tablewidth += $widthcols[$i]['miw']; }
@@ -18464,8 +18463,8 @@ function _tableWidth(&$table){
18464
  if (!$totaltextlength) { $totaltextlength =1; }
18465
  $tablewidth += $tblbw; // Outer half of table borders
18466
 
18467
- if ($tablewidth > $temppgwidth) {
18468
- $table['w'] = $temppgwidth;
18469
  }
18470
  // if any widths set as percentages and max width fits < page width
18471
  else if ($tablewidth < $temppgwidth && !isset($table['w']) && $percentages_set) {
@@ -18480,8 +18479,8 @@ function _tableWidth(&$table){
18480
  $notsetlist = array();
18481
  for( $i = 0 ; $i < $numcols ; $i++ ) {
18482
  $wis += $widthcols[$i]['miw'];
18483
- if (!isset($widthcols[$i]['w']) || ($widthcols[$i]['w'] && $table['w'] > $temppgwidth && !$this->keep_table_proportions && !$notfullwidth )){
18484
- $list[] = $i;
18485
  $wisa += $widthcols[$i]['miw'];
18486
  $totalatextlength += $table['l'][$i];
18487
  }
@@ -18513,10 +18512,10 @@ function _tableWidth(&$table){
18513
  $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']);
18514
  $widthcols[$k]['miw'] = $widthcols[$k]['maw'];
18515
  }
18516
- else {
18517
- $notsetlist[] = $k;
18518
  $ttl += $table['l'][$k];
18519
- $widthcols[$k]['miw'] += ($wi * $spareratio);
18520
  }
18521
 
18522
  }
@@ -18530,15 +18529,15 @@ function _tableWidth(&$table){
18530
  $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']);
18531
  $widthcols[$k]['miw'] = $widthcols[$k]['maw'];
18532
  }
18533
- else {
18534
- $notsetlist[] = $k;
18535
  $ttl += $table['l'][$k];
18536
- $widthcols[$k]['miw'] += ($wi * $spareratio);
18537
  }
18538
  }
18539
  }
18540
  // If surplus still left over apportion it across columns
18541
- if ($surplus) {
18542
  // if some are set only add to remaining - otherwise add to all of them
18543
  if (count($notsetlist) && count($notsetlist) < $numcols) {
18544
  foreach ($notsetlist AS $i) {
@@ -18572,25 +18571,25 @@ function _tableWidth(&$table){
18572
  for ( $i = 0 ; $i < $numcols ; $i++ ) {
18573
  $checktablewidth += $widthcols[$i];
18574
  }
18575
- if ($checktablewidth > ($temppgwidth + 0.001 - $tblbw)) {
18576
  $usedup = 0; $numleft = 0;
18577
  for ($i=0;$i<$numcols;$i++) {
18578
- if ((isset($widthcols[$i]) && $widthcols[$i] > (($temppgwidth - $tblbw) / $numcols)) && (!isset($widthcols[$i]['w']))) {
18579
- $numleft++;
18580
- unset($widthcols[$i]);
18581
  }
18582
  else { $usedup += $widthcols[$i]; }
18583
  }
18584
  for ($i=0;$i<$numcols;$i++) {
18585
- if (!isset($widthcols[$i]) || !$widthcols[$i]) {
18586
- $widthcols[$i] = ((($temppgwidth - $tblbw) - $usedup)/ ($numleft));
18587
  }
18588
  }
18589
  }
18590
 
18591
  }
18592
  else { //table has no width defined
18593
- $table['w'] = $tablewidth;
18594
  for ( $i = 0 ; $i < $numcols ; $i++) {
18595
  if (isset($widthcols[$i]['wpercent']) && $this->keep_table_proportions) { $colwidth = $widthcols[$i]['maw']; }
18596
  else if (isset($widthcols[$i]['w'])) { $colwidth = $widthcols[$i]['miw']; }
@@ -18611,7 +18610,7 @@ function _tableWidth(&$table){
18611
  $cc = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18612
  $colspan = $cc['colspan'];
18613
  }
18614
- else
18615
  $colspan = $table['cells'][$i][$j]['colspan'];
18616
  if ($colspan > 1) {
18617
  $w = 0;
@@ -18636,12 +18635,12 @@ function _tableWidth(&$table){
18636
  $pgNo = 0;
18637
  $currWc = 0;
18638
  for ($i = 0 ; $i < $numcols; $i++) { //columns
18639
- if (isset($table['csp'][$i])) {
18640
- $w = $table['csp'][$i];
18641
  unset($table['csp'][$i]);
18642
  }
18643
  else { $w = $widthcols[$i]; }
18644
- if (($currWc + $w + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18645
  $pgNo++;
18646
  $currWc = $widthcols[$i] ;
18647
  }
@@ -18695,7 +18694,7 @@ function _tableHeight(&$table){
18695
  if ($this->cacheTables) {
18696
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18697
  }
18698
- else
18699
  $c = &$cells[$i][$j];
18700
 
18701
  if ($this->simpleTables){
@@ -18712,7 +18711,7 @@ function _tableHeight(&$table){
18712
  if ($this->packTableData) {
18713
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18714
  }
18715
- else {
18716
  $bt = $c['border_details']['T']['w'];
18717
  $bb = $c['border_details']['B']['w'];
18718
  $br = $c['border_details']['R']['w'];
@@ -18728,12 +18727,12 @@ function _tableHeight(&$table){
18728
  }
18729
  }
18730
 
18731
- if ($table['overflow']=='visible' && $level==1)
18732
  list($x,$cw) = $this->_splitTableGetWidth($table, $i,$j, $fh);
18733
- else
18734
  list($x,$cw) = $this->_tableGetWidth($table, $i,$j, $fh);
18735
 
18736
- // Get CELL HEIGHT
18737
  // ++ extra parameter forces wrap to break word
18738
  if ($c['R'] && isset($c['textbuffer'])) { // mPDF 5.4.01
18739
  $str = '';
@@ -18746,9 +18745,9 @@ function _tableHeight(&$table){
18746
  $tempch = $this->GetStringWidth($str);
18747
  if ($c['R'] >= 45 && $c['R'] < 90) {
18748
  $tempch = ((sin(deg2rad($c['R']))) * $tempch ) + ((sin(deg2rad($c['R']))) * (($c['textbuffer'][0][11]/_MPDFK) / $this->shrin_k));
18749
- }
18750
  $this->SetFont($s_f,$s_st,$s_fs,true,true);
18751
- $ch = ($tempch ) + $extrh ;
18752
  }
18753
  else {
18754
  if (isset($c['textbuffer'])) {
@@ -18772,20 +18771,20 @@ function _tableHeight(&$table){
18772
  elseif ($heightrow < $ch) $heightrow = $ch;
18773
 
18774
  // this is the extra used in _tableWrite to determine whether to trigger a page change
18775
- if ($table['borders_separate']) {
18776
  if ($i == ($numrows-1) || (isset($c['rowspan']) && ($i+$c['rowspan']) == ($numrows)) ) {
18777
- $extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
18778
  }
18779
  else {
18780
- $extra = $table['border_spacing_V']/2;
18781
  }
18782
  }
18783
- else {
18784
  if (!$this->simpleTables){
18785
- $extra = $bb/2;
18786
  }
18787
  else if ($this->simpleTables){
18788
- $extra = $table['simple']['border_details']['B']['w'] /2;
18789
  }
18790
  }
18791
  if (isset($table['is_thead'][$i]) && $table['is_thead'][$i]) {
@@ -18816,7 +18815,7 @@ function _tableHeight(&$table){
18816
  if ($this->cacheTables) {
18817
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18818
  }
18819
- else
18820
  $c = &$cells[$i][$j];
18821
  $lr = $i + $c['rowspan'];
18822
  if ($lr > $numrows) $lr = $numrows;
@@ -18830,26 +18829,26 @@ function _tableHeight(&$table){
18830
  }
18831
  }
18832
 
18833
- if ($table['borders_separate']) {
18834
  if ($i == ($numrows-1) || ($i+$c['rowspan']) == ($numrows) ) {
18835
- $extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
18836
  }
18837
  else {
18838
- $extra = $table['border_spacing_V']/2;
18839
  }
18840
  }
18841
- else {
18842
  if (!$this->simpleTables){
18843
  if ($this->packTableData) {
18844
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18845
  }
18846
- else {
18847
  $bb = $c['border_details']['B']['w'];
18848
  }
18849
- $extra = $bb/2;
18850
  }
18851
  else if ($this->simpleTables){
18852
- $extra = $table['simple']['border_details']['B']['w'] /2;
18853
  }
18854
  }
18855
  if (!empty($table['is_thead'][$i])) {
@@ -18892,7 +18891,7 @@ function _tableHeight(&$table){
18892
  if ($this->cacheTables) {
18893
  $c = $this->_uncacheCell($table['cells'][$cki][$ckj], '', $fh);
18894
  }
18895
- else
18896
  $c = &$cells[$cki][$ckj];
18897
  if (isset($c['rowspan']) && $c['rowspan']>1) {
18898
  if (($cki + $c['rowspan']-1) >= $i) { $top = min($top, $cki); }
@@ -18908,7 +18907,7 @@ function _tableHeight(&$table){
18908
  // ???? take account of colspan as well???
18909
  for( $m = 0 ; $m < $numcols ; $m++ ) { //columns
18910
  if (!isset($cells[$k][$m]) || $cells[$k][$m]==0) {
18911
- break(2);
18912
  }
18913
  }
18914
  }
@@ -18918,10 +18917,10 @@ function _tableHeight(&$table){
18918
  if ($this->cacheTables) {
18919
  $c = $this->_uncacheCell($table['cells'][$k][$m], '', $fh);
18920
  }
18921
- else
18922
  $c = &$cells[$k][$m];
18923
  if (isset($c['rowspan']) && $c['rowspan']>1) {
18924
- break(2);
18925
  }
18926
  }
18927
  }
@@ -18933,20 +18932,20 @@ function _tableHeight(&$table){
18933
  $newhr = array();
18934
  for( $m = 0 ; $m < $numcols ; $m++ ) { //columns
18935
  for ($k=$top; $k<=$bottom; $k++) {
18936
- if (isset($cells[$k][$m]) && $cells[$k][$m]!=0) {
18937
  if ($this->cacheTables) {
18938
  $c = $this->_uncacheCell($table['cells'][$k][$m], '', $fh);
18939
  }
18940
- else
18941
  $c = &$cells[$k][$m];
18942
- if (isset($c['h']) && $c['h']) {
18943
  $useh = $c['h'];
18944
  }
18945
  // ???? take account of colspan as well???
18946
- else {
18947
- $useh = $c['mih'];
18948
  }
18949
- $colH[$m] += $useh;
18950
  if (!isset($c['rowspan']) || $c['rowspan']<2) { $newhr[$k] = max($newhr[$k], $useh); }
18951
  }
18952
  }
@@ -18965,10 +18964,10 @@ function _tableHeight(&$table){
18965
 
18966
  if ($this->cacheTables) { fclose($fh); }
18967
 
18968
- if ($table['borders_separate']) {
18969
  $table['h'] += $table['margin']['T'] + $table['margin']['B'] + $table['border_details']['T']['w'] + $table['border_details']['B']['w'] + $table['border_spacing_V'] + $table['padding']['T'] + $table['padding']['B'];
18970
  }
18971
- else {
18972
  $table['h'] += $table['margin']['T'] + $table['margin']['B'] + $table['max_cell_border_width']['T']/2 + $table['max_cell_border_width']['B']/2;
18973
  }
18974
 
@@ -18981,7 +18980,7 @@ function _tableGetWidth(&$table, $i,$j, $fh){
18981
  if ($this->cacheTables) {
18982
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18983
  }
18984
- else
18985
  $cell = &$table['cells'][$i][$j];
18986
  if ($cell) {
18987
  if (isset($cell['x0'])) { return array($cell['x0'], $cell['w0']); }
@@ -19006,7 +19005,7 @@ function _splitTableGetWidth(&$table, $i,$j, $fh){
19006
  if ($this->cacheTables) {
19007
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19008
  }
19009
- else
19010
  $cell = &$table['cells'][$i][$j];
19011
  if ($cell) {
19012
  if (isset($cell['x0'])) return array($cell['x0'], $cell['w0']);
@@ -19035,7 +19034,7 @@ function _tableGetHeight(&$table, $i,$j, $fh){
19035
  if ($this->cacheTables) {
19036
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19037
  }
19038
- else
19039
  $cell = &$table['cells'][$i][$j];
19040
  if ($cell){
19041
  if (isset($cell['y0'])) return array($cell['y0'], $cell['h0']);
@@ -19067,13 +19066,13 @@ function _tableGetMaxRowHeight($table, $row, $fh) {
19067
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19068
  if ($cell) {
19069
  if (isset($cell['colspan'])) { $cellsset += $cell['colspan']; }
19070
- else $cellsset += 1;
19071
  }
19072
  }
19073
  else {
19074
- if ($table['cells'][$i][$j]) {
19075
  if (isset($table['cells'][$i][$j]['colspan'])) { $cellsset += $table['cells'][$i][$j]['colspan']; }
19076
- else $cellsset += 1;
19077
  }
19078
  }
19079
  }
@@ -19092,12 +19091,12 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19092
  if ($bord==-1) { $this->Rect($x, $y, $w, $h); }
19093
  else if ($this->simpleTables && ($cort=='cell')) {
19094
  $this->SetLineWidth($details['L']['w']);
19095
- if ($details['L']['c']) {
19096
  $this->SetDColor($details['L']['c']);
19097
  }
19098
  else { $this->SetDColor($this->ConvertColor(0)); }
19099
  $this->SetLineJoin(0);
19100
- $this->Rect($x, $y, $w, $h);
19101
  }
19102
  else if ($bord){
19103
  if (!$bSeparate && $buffer) {
@@ -19113,14 +19112,14 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19113
 
19114
  // Precedence to darker colours at joins
19115
  $coldom = 0;
19116
- if (isset($details[$side]['c']) && is_array($details[$side]['c'])) {
19117
  if ($details[$side]['c']{0}==3) { // RGB
19118
- $coldom = 10-(((ord($details[$side]['c']{1})*1.00)+(ord($details[$side]['c']{2})*1.00)+(ord($details[$side]['c']{3})*1.00))/76.5);
19119
  }
19120
  } // 10 black - 0 white
19121
  if ($coldom) { $dom += $coldom; }
19122
  // Lastly precedence to RIGHT and BOTTOM cells at joins
19123
- if (isset($details['cellposdom'])) { $dom += $details['cellposdom']; }
19124
 
19125
  $save = false;
19126
  if ($side == 'T' && $this->issetBorder($bord, _BORDER_TOP)) { $cbord = _BORDER_TOP; $save = true; }
@@ -19136,7 +19135,7 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19136
  $details[$side]['s'],
19137
  $details[$side]['w'],
19138
  $details[$side]['c'],
19139
- $details[$side]['style'],
19140
  $x, $y, $w, $h,
19141
  $details['mbw']['BL'],
19142
  $details['mbw']['BR'],
@@ -19158,7 +19157,7 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19158
  $details[$side]['s'],
19159
  $details[$side]['w'],
19160
  $details[$side]['c'],
19161
- $details[$side]['style'],
19162
  $x, $y, $w, $h,
19163
  $details['mbw']['BL'],
19164
  $details['mbw']['BR'],
@@ -19179,10 +19178,10 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19179
 
19180
  if (isset($details['p']) && strlen($details['p'])>1) { $priority = $details['p']; }
19181
  else { $priority='LTRB'; }
19182
- $Tw = 0;
19183
- $Rw = 0;
19184
- $Bw = 0;
19185
- $Lw = 0;
19186
  if (isset($details['T']['w'])) { $Tw = $details['T']['w']; }
19187
  if (isset($details['R']['w'])) { $Rw = $details['R']['w']; }
19188
  if (isset($details['B']['w'])) { $Bw = $details['B']['w']; }
@@ -19309,14 +19308,14 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19309
  $this->SetLineCap(1);
19310
  $this->SetDash(0.001,($this->LineWidth*2));
19311
  }
19312
- if ($details[$side]['c']) {
19313
  $this->SetDColor($details[$side]['c']);
19314
  }
19315
  else { $this->SetDColor($this->ConvertColor(0)); }
19316
  $this->Line($lx1 + $xadj, $ly1 + $yadj, $lx2 - $xadj2, $ly2 - $yadj2);
19317
 
19318
  // Reset Corners
19319
- $this->SetDash();
19320
  //BUTT style line cap
19321
  $this->SetLineCap(2);
19322
  }
@@ -19325,7 +19324,7 @@ function _tableRect($x, $y, $w, $h, $bord=-1, $details=array(), $buffer=false, $
19325
  if ($bSeparate && count($cellBorderOverlay)) {
19326
  foreach($cellBorderOverlay AS $cbo) {
19327
  $this->SetLineWidth($cbo['lw']);
19328
- $this->SetDColor($cbo['col']);
19329
  $this->Line($cbo['x'], $cbo['y'], $cbo['x2'], $cbo['y2']);
19330
  }
19331
  }
@@ -19355,12 +19354,12 @@ function issetBorder($var, $flag) {
19355
  function _table2cellBorder(&$tableb, &$cbdb, &$cellb, $bval) {
19356
  if ($tableb && $tableb['w'] > $cbdb['w']) {
19357
  $cbdb = $tableb;
19358
- $this->setBorder($cellb, $bval);
19359
  }
19360
- else if ($tableb && $tableb['w'] == $cbdb['w']
19361
  && array_search($tableb['style'],$this->borderstyles) > array_search($cbdb['style'],$this->borderstyles)) {
19362
  $cbdb = $tableb;
19363
- $this->setBorder($cellb, $bval);
19364
  }
19365
  }
19366
 
@@ -19370,16 +19369,16 @@ function _fixTableBorders(&$table){
19370
  else { $fh = null; }
19371
 
19372
  if (!$table['borders_separate'] && $table['border_details']['L']['w']) {
19373
- $table['max_cell_border_width']['L'] = $table['border_details']['L']['w'];
19374
  }
19375
  if (!$table['borders_separate'] && $table['border_details']['R']['w']) {
19376
- $table['max_cell_border_width']['R'] = $table['border_details']['R']['w'];
19377
  }
19378
  if (!$table['borders_separate'] && $table['border_details']['T']['w']) {
19379
- $table['max_cell_border_width']['T'] = $table['border_details']['T']['w'];
19380
  }
19381
  if (!$table['borders_separate'] && $table['border_details']['B']['w']) {
19382
- $table['max_cell_border_width']['B'] = $table['border_details']['B']['w'];
19383
  }
19384
  if ($this->simpleTables) { return; }
19385
  $cells = &$table['cells'];
@@ -19392,7 +19391,7 @@ function _fixTableBorders(&$table){
19392
  if ($this->cacheTables) {
19393
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19394
  }
19395
- else
19396
  $cell = &$cells[$i][$j];
19397
  if ($this->packTableData) { // includes $this->cacheTables
19398
  $cbord = $this->_unpackCellBorder($cell['borderbin']);
@@ -19457,7 +19456,7 @@ function _reverseTableDir(&$table) {
19457
  if ($this->cacheTables) {
19458
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19459
  }
19460
- else
19461
  $cell = &$cells[$i][$j];
19462
  $col = $numcols - $j - 1;
19463
  if (isset($cell['colspan']) && $cell['colspan'] > 1) { $col -= ($cell['colspan']-1); }
@@ -19478,7 +19477,7 @@ function _reverseTableDir(&$table) {
19478
  unset($cell);
19479
  }
19480
  }
19481
- for($f=0; $f < $numcols; $f++) {
19482
  if (!isset($row[$f])) { $row[$f] = 0; }
19483
  }
19484
  $table['cells'][$i] = $row;
@@ -19507,14 +19506,14 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19507
  }
19508
  }
19509
  // Advance down page by half width of top border
19510
- if ($table['borders_separate']) {
19511
  if ($startrow>0 && (!isset($table['is_thead']) || count($table['is_thead'])==0))
19512
- $adv = $table['border_spacing_V']/2;
19513
- else
19514
- $adv = $table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2;
19515
  }
19516
- else {
19517
- $adv = $table['max_cell_border_width']['T']/2;
19518
  }
19519
  if (!$this->table_rotate && $level==1) { $this->DivLn($adv); }
19520
  else { $this->y += $adv; }
@@ -19522,7 +19521,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19522
 
19523
  if ($level==1) {
19524
  $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'];
19525
- $x0 = $this->x;
19526
  $y0 = $this->y;
19527
  $right = $x0 + $this->blk[$this->blklvl]['inner_width'];
19528
  $outerfilled = $this->y; // Keep track of how far down the outer DIV bgcolor is painted (NB rowspans)
@@ -19530,7 +19529,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19530
  $this->colsums = array();
19531
  }
19532
  else {
19533
- $x0 = $this->x;
19534
  $y0 = $this->y;
19535
  $right = $x0 + $table['w'];
19536
  }
@@ -19576,16 +19575,16 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19576
  $lastCol = 0;
19577
  $tableheader = array();
19578
  $tablefooter = array();
19579
- $tableheaderrowheight = 0;
19580
  $tablefooterrowheight = 0;
19581
  $footery = 0;
19582
 
19583
  // mPD 3.0 Set the Page & Column where table starts
19584
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
19585
- $tablestartpage = 'EVEN';
19586
  }
19587
  else if (($this->mirrorMargins) && (($this->page)%2==1)) { // ODD
19588
- $tablestartpage = 'ODD';
19589
  }
19590
  else { $tablestartpage = ''; }
19591
  if ($this->ColActive) { $tablestartcolumn = $this->CurrCol; }
@@ -19596,8 +19595,8 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19596
 
19597
  $y = $h = 0;
19598
  for( $i = 0; $i < $numrows ; $i++ ) { //Rows
19599
- if (isset($table['is_tfoot'][$i]) && $table['is_tfoot'][$i] && $level==1) {
19600
- $tablefooterrowheight += $table['hr'][$i];
19601
  $tablefooter[$i][0]['trbackground-images'] = $table['trbackground-images'][$i];
19602
  $tablefooter[$i][0]['trgradients'] = $table['trgradients'][$i];
19603
  $tablefooter[$i][0]['trbgcolor'] = $table['bgcolor'][$i];
@@ -19606,19 +19605,19 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19606
  if ($this->cacheTables) {
19607
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19608
  }
19609
- else
19610
  $cell = &$cells[$i][$j];
19611
- if ($split) {
19612
  if ($table['colPg'][$j] != $splitpg) { continue; }
19613
- list($x,$w) = $this->_splitTableGetWidth($table, $i, $j, $fh);
19614
  $js = $j - $startcol;
19615
  }
19616
- else {
19617
- list($x,$w) = $this->_tableGetWidth($table, $i, $j, $fh);
19618
  $js = $j;
19619
  }
19620
 
19621
- list($y,$h) = $this->_tableGetHeight($table, $i, $j, $fh);
19622
  $x += $x0;
19623
  $y += $y0;
19624
  //Get info of tfoot ==>> table footer
@@ -19665,7 +19664,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19665
 
19666
  //Draw Table Contents and Borders
19667
  for( $i = 0; $i < $numrows ; $i++ ) { //Rows
19668
- if ($split && $startrow > 0) {
19669
  $thnr = (isset($table['is_thead']) ? count($table['is_thead']) : 0);
19670
  if ($i >= $thnr && $i < $startrow) { continue; }
19671
  if ($i == $startrow){ $returny = $rety - $tableheaderrowheight; }
@@ -19677,19 +19676,19 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19677
  $skippage = false;
19678
  $newpagestarted = false;
19679
  for( $j = $startcol ; $j < $numcols ; $j++ ) { //Columns
19680
- if ($split) {
19681
  if ($table['colPg'][$j] > $splitpg) { break; }
19682
- $lastCol = $j;
19683
  }
19684
  if (isset($cells[$i][$j]) && $cells[$i][$j]) {
19685
  if ($this->cacheTables) {
19686
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19687
  }
19688
- else
19689
  $cell = &$cells[$i][$j];
19690
- if ($split) {
19691
- $lastCol = $j + (isset($cell['colspan']) ? ($cell['colspan']-1) : 0) ;
19692
- list($x,$w) = $this->_splitTableGetWidth($table, $i, $j, $fh);
19693
  }
19694
  else { list($x,$w) = $this->_tableGetWidth($table, $i, $j, $fh); }
19695
 
@@ -19698,13 +19697,13 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19698
  $y += $y0;
19699
  $y -= $returny;
19700
 
19701
- if ($table['borders_separate']) {
19702
  if (!empty($tablefooter) || $i == ($numrows-1) || (isset($cell['rowspan']) && ($i+$cell['rowspan']) == $numrows) || (!isset($cell['rowspan']) && ($i+1) == $numrows) ) {
19703
- $extra = $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
19704
- //$extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
19705
  }
19706
  else {
19707
- $extra = $table['border_spacing_V']/2;
19708
  }
19709
  }
19710
  else { $extra = $table['max_cell_border_width']['B']/2; }
@@ -19713,7 +19712,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19713
 
19714
  if (!$skippage) {
19715
  $finalSpread = true;
19716
- $firstSpread = true;
19717
  if ($split) {
19718
  for($t=$startcol; $t<$numcols; $t++) {
19719
  // Are there more columns to print on a next page?
@@ -19725,7 +19724,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19725
  if ($startcol>0) { $firstSpread = false; }
19726
  }
19727
 
19728
- if (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && $i > 0 ) {
19729
  $this->y = $y;
19730
  $ya = $this->y;
19731
  $this->TableHeaderFooter($tablefooter,$tablestartpage,$tablestartcolumn,'F',$level, $firstSpread, $finalSpread);
@@ -19742,23 +19741,23 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19742
  $newpagestarted = true;
19743
  $this->y = $y + $y0;
19744
 
19745
- // Move down to account for border-spacing or
19746
  // extra half border width in case page breaks in middle
19747
  if($i>0 && !$this->table_rotate && $level==1 && !$this->ColActive) {
19748
- if ($table['borders_separate']) {
19749
- $adv = $table['border_spacing_V']/2;
19750
  // If table footer
19751
- if (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && $i > 0 ) {
19752
- $adv += ($table['padding']['B'] + $table['border_details']['B']['w']);
19753
  }
19754
  }
19755
- else {
19756
  $maxbwtop = 0;
19757
  $maxbwbottom = 0;
19758
  if (!$this->simpleTables){
19759
  if (!empty($tablefooter)) { $maxbwbottom = $table['max_cell_border_width']['B']; }
19760
- else {
19761
- $brow = $i-1;
19762
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19763
  if (isset($cells[$brow][$ctj]) && $cells[$brow][$ctj]) {
19764
  if ($this->cacheTables) {
@@ -19771,13 +19770,13 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19771
  else {
19772
  $bb = $cells[$brow][$ctj]['border_details']['B']['w'];
19773
  }
19774
- $maxbwbottom = max($maxbwbottom , $bb);
19775
  }
19776
  }
19777
  }
19778
  if (!empty($tableheader)) { $maxbwtop = $table['max_cell_border_width']['T']; }
19779
- else {
19780
- $trow = $i-1;
19781
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19782
  if (isset($cells[$trow][$ctj]) && $cells[$trow][$ctj]) {
19783
  if ($this->cacheTables) {
@@ -19797,7 +19796,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19797
  }
19798
  else if ($this->simpleTables){
19799
  $maxbwtop = $table['simple']['border_details']['T']['w'];
19800
- $maxbwbottom = $table['simple']['border_details']['B']['w'];
19801
  }
19802
  $adv = $maxbwbottom /2;
19803
  }
@@ -19814,38 +19813,38 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19814
  $bx = $x0;
19815
  $by = $y0;
19816
 
19817
- if ($table['borders_separate']) {
19818
- $bx -= ($table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H']/2);
19819
  if ($tablestartpageno != $this->page) { // IF already broken across a previous pagebreak
19820
- $by += $table['max_cell_border_width']['T']/2;
19821
  if (empty($tableheader)) { $by -= ($table['border_spacing_V']/2); }
19822
  }
19823
- else {
19824
- $by -= ($table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2);
19825
  }
19826
  }
19827
 
19828
- else if ($tablestartpageno != $this->page && !empty($tableheader)) { $by += $maxbwtop /2; }
19829
 
19830
  $by -= $tableheaderadj;
19831
  $bh = $this->y - $by + $tablefooteradj;
19832
  if (!$table['borders_separate']) { $bh -= $adv ; }
19833
- if ($split) {
19834
  $bw = 0;
19835
  for($t=$startcol; $t<$numcols; $t++) {
19836
  if ($table['colPg'][$t] == $splitpg) { $bw += $table['wc'][$t]; }
19837
  if ($table['colPg'][$t] > $splitpg) { break; }
19838
  }
19839
- if ($table['borders_separate']) {
19840
- if ($firstSpread) {
19841
- $bw += $table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H'];
19842
  }
19843
  else {
19844
- $bx += ($table['padding']['L'] + $table['border_details']['L']['w']);
19845
- $bw += $table['border_spacing_H'];
19846
  }
19847
- if ($finalSpread) {
19848
- $bw += $table['padding']['R'] + $table['border_details']['R']['w']/2 + $table['border_spacing_H'];
19849
  }
19850
  }
19851
  }
@@ -19858,12 +19857,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19858
  $prevDrawColor = $this->DrawColor;
19859
  $lw = $this->LineWidth;
19860
  $this->SetLineWidth($this->splitTableBorderWidth);
19861
- $this->SetDColor($table['border_details']['B']['c']);
19862
  $this->SetLineJoin(0);
19863
  $this->SetLineCap(0);
19864
  $blx = $bx;
19865
  $blw = $bw;
19866
- if (!$table['borders_separate']) {
19867
  $blx -= ($table['max_cell_border_width']['L']/2);
19868
  $blw += ($table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2);
19869
  }
@@ -19873,10 +19872,10 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19873
  $this->SetLineWidth($lw);
19874
  $this->SetLineJoin(2);
19875
  $this->SetLineCap(2);
19876
- }
19877
 
19878
  if (!$this->ColActive && ($i > 0 || $j > 0)) {
19879
- if (isset($table['bgcolor'][-1])) {
19880
  $color = $this->ConvertColor($table['bgcolor'][-1]);
19881
  if ($color) {
19882
  if (!$table['borders_separate']) { $bh -= $table['max_cell_border_width']['B']/2; }
@@ -19902,7 +19901,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19902
 
19903
  if ($split) {
19904
  if ($i == 0 && $j == 0) { $y0 = -1; }
19905
- else if ($finalSpread) {
19906
  $splitpg = 0;
19907
  $startcol = 0;
19908
  $startrow = $i;
@@ -19931,7 +19930,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19931
  $prevDrawColor = $this->DrawColor;
19932
  $lw = $this->LineWidth;
19933
  $this->SetLineWidth($this->splitTableBorderWidth);
19934
- $this->SetDColor($table['border_details']['T']['c']);
19935
  $this->SetLineJoin(0);
19936
  $this->SetLineCap(0);
19937
  $blx += $this->MarginCorrection;
@@ -19941,13 +19940,13 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19941
  $this->SetLineWidth($lw);
19942
  $this->SetLineJoin(2);
19943
  $this->SetLineCap(2);
19944
- }
19945
 
19946
- // Move down to account for half of top border-spacing or
19947
  // extra half border width in case page was broken in middle
19948
  if($i>0 && !$this->table_rotate && $level==1 && $table['headernrows']==0) {
19949
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2; }
19950
- else {
19951
  $maxbwtop = 0;
19952
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19953
  if (isset($cells[$i][$ctj]) && $cells[$i][$ctj]) {
@@ -19962,10 +19961,10 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
19962
  else {
19963
  $bt = $cells[$i][$ctj]['border_details']['T']['w'];
19964
  }
19965
- $maxbwtop = max($maxbwtop, $bt);
19966
  }
19967
  else if ($this->simpleTables){
19968
- $maxbwtop = max($maxbwtop, $table['simple']['border_details']['T']['w']);
19969
  }
19970
  }
19971
  }
@@ -20005,12 +20004,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20005
  // Advance down page
20006
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; }
20007
  else { $adv = $table['max_cell_border_width']['T'] /2 ; }
20008
- if ($adv) {
20009
  if ($this->table_rotate) {
20010
  $this->y += ($adv);
20011
  }
20012
  else {
20013
- $this->DivLn($adv,$this->blklvl,true);
20014
  }
20015
  }
20016
  }
@@ -20023,12 +20022,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20023
  $skippage = true;
20024
  }
20025
 
20026
- $this->x = $x;
20027
  $this->y = $y;
20028
 
20029
  if ($this->kwt_saved && $level==1) {
20030
  $this->printkwtbuffer();
20031
- $x0 = $x = $this->x;
20032
  $y0 = $y = $this->y;
20033
  $this->kwt_moved = false;
20034
  $this->kwt_saved = false;
@@ -20038,10 +20037,10 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20038
  // Set the Page & Column where table actually starts
20039
  if ($i==0 && $j==0 && $level==1) {
20040
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
20041
- $tablestartpage = 'EVEN';
20042
  }
20043
  else if (($this->mirrorMargins) && (($this->page)%2==1)) { // ODD
20044
- $tablestartpage = 'ODD';
20045
  }
20046
  else { $tablestartpage = ''; }
20047
  $tablestartpageno = $this->page;
@@ -20054,10 +20053,10 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20054
 
20055
 
20056
  if ($table['empty_cells']!='hide' || !empty($cell['textbuffer']) || (isset($cell['nestedcontent']) && $cell['nestedcontent']) || !$table['borders_separate'] ) { $paintcell = true; }
20057
- else { $paintcell = false; }
20058
 
20059
  //Set Borders
20060
- $bord = 0;
20061
  $bord_det = array();
20062
 
20063
  if (!$this->simpleTables){
@@ -20082,7 +20081,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20082
 
20083
  //TABLE ROW OR CELL FILL BGCOLOR
20084
  $fill = 0;
20085
- if (isset($cell['bgcolor']) && $cell['bgcolor'] && $cell['bgcolor']!='transparent') {
20086
  $fill = $cell['bgcolor'];
20087
  $leveladj = 6;
20088
  }
@@ -20093,7 +20092,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20093
  if ($fill && $paintcell) {
20094
  $color = $this->ConvertColor($fill);
20095
  if ($color) {
20096
- if ($table['borders_separate']) {
20097
  if ($this->ColActive) {
20098
  $this->SetFColor($color);
20099
  $this->Rect($x+ ($table['border_spacing_H']/2), $y+ ($table['border_spacing_V']/2), $w- $table['border_spacing_H'], $h- $table['border_spacing_V'], 'F');
@@ -20102,7 +20101,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20102
  $this->tableBackgrounds[$level*9+$leveladj][] = array('gradient'=>false, 'x'=>($x + ($table['border_spacing_H']/2)), 'y'=>($y + ($table['border_spacing_V']/2)), 'w'=>($w - $table['border_spacing_H']), 'h'=>($h - $table['border_spacing_V']), 'col'=>$color);
20103
  }
20104
  }
20105
- else {
20106
  if ($this->ColActive) {
20107
  $this->SetFColor($color);
20108
  $this->Rect($x, $y, $w, $h, 'F');
@@ -20126,12 +20125,12 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20126
  if (isset($table['topntail']) && $table['topntail']) {
20127
  $bord_det['T'] = $this->border_details($table['topntail']);
20128
  $bord_det['T']['w'] /= $this->shrin_k;
20129
- $this->setBorder($bord, _BORDER_TOP);
20130
  }
20131
  if (isset($table['thead-underline']) && $table['thead-underline']) {
20132
  $bord_det['T'] = $this->border_details($table['thead-underline']);
20133
  $bord_det['T']['w'] /= $this->shrin_k;
20134
- $this->setBorder($bord, _BORDER_TOP);
20135
  }
20136
  }
20137
 
@@ -20139,7 +20138,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20139
  //Get info of first row ==>> table header
20140
  //Use > 1 row if THEAD
20141
  if (isset($table['is_thead'][$i]) && $table['is_thead'][$i] && $level==1) {
20142
- if ($j==0) $tableheaderrowheight += $table['hr'][$i];
20143
  $tableheader[$i][0]['trbackground-images'] = (isset($table['trbackground-images'][$i]) ? $table['trbackground-images'][$i] : null);
20144
  $tableheader[$i][0]['trgradients'] = (isset($table['trgradients'][$i]) ? $table['trgradients'][$i] : null);
20145
  $tableheader[$i][0]['trbgcolor'] = (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] : null);
@@ -20170,11 +20169,11 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20170
  }
20171
 
20172
  // CELL BORDER
20173
- if ($bord || $bord_det) {
20174
  if ($table['borders_separate'] && $paintcell) {
20175
  $this->_tableRect($x + ($table['border_spacing_H']/2)+($bord_det['L']['w'] /2), $y+ ($table['border_spacing_V']/2)+($bord_det['T']['w'] /2), $w-$table['border_spacing_H']-($bord_det['L']['w'] /2)-($bord_det['R']['w'] /2), $h- $table['border_spacing_V']-($bord_det['T']['w'] /2)-($bord_det['B']['w']/2), $bord, $bord_det, false, $table['borders_separate']);
20176
  }
20177
- else if (!$table['borders_separate']) {
20178
  $this->_tableRect($x, $y, $w, $h, $bord, $bord_det, true, $table['borders_separate']); // true causes buffer
20179
  }
20180
 
@@ -20185,7 +20184,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20185
  if (!isset($cell['va']) || $cell['va']=='M') $this->y += ($h-$cell['mih'])/2;
20186
  elseif (isset($cell['va']) && $cell['va']=='B') $this->y += $h-$cell['mih'];
20187
 
20188
- // NESTED CONTENT
20189
 
20190
  // TEXT (and nested tables)
20191
  $this->divalign=$align;
@@ -20226,29 +20225,29 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20226
  else if ($angle > 0 && $angle <45) { $angle = 45; }
20227
  else if ($angle < 0) { $angle = -90; }
20228
  $offset = ((sin(deg2rad($angle))) * 0.37 * $cellFontHeight);
20229
- if (isset($cell['a']) && $cell['a']=='R') {
20230
- $this->x += ($w) + ($offset) - ($cellFontHeight/3) - ($cell['padding']['R'] + ($table['border_spacing_H']/2));
20231
  }
20232
- else if (!isset($cell['a']) || $cell['a']=='C') {
20233
- $this->x += ($w/2) + ($offset);
20234
  }
20235
- else {
20236
- $this->x += ($offset) + ($cellFontHeight/3)+($cell['padding']['L'] +($table['border_spacing_H']/2));
20237
  }
20238
  $str = '';
20239
  foreach($cell['textbuffer'] AS $t) { $str .= $t[0].' '; }
20240
  $str = trim($str);
20241
- if (!isset($cell['va']) || $cell['va']=='M') {
20242
  $this->y -= ($h-$cell['mih'])/2; //Undo what was added earlier VERTICAL ALIGN
20243
  if ($angle > 0) { $this->y += (($h-$cell['mih'])/2) + $cell['padding']['T'] + ($cell['mih']-($cell['padding']['T'] + $cell['padding']['B'])); }
20244
  else if ($angle < 0) { $this->y += (($h-$cell['mih'])/2)+ ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20245
  }
20246
- elseif (isset($cell['va']) && $cell['va']=='B') {
20247
  $this->y -= $h-$cell['mih']; //Undo what was added earlier VERTICAL ALIGN
20248
  if ($angle > 0) { $this->y += $h-($cell['padding']['B'] + ($table['border_spacing_V']/2)); }
20249
  else if ($angle < 0) { $this->y += $h-$cell['mih'] + ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20250
  }
20251
- elseif (isset($cell['va']) && $cell['va']=='T') {
20252
  if ($angle > 0) { $this->y += $cell['mih']-($cell['padding']['B'] + ($table['border_spacing_V']/2)); }
20253
  else if ($angle < 0) { $this->y += ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20254
  }
@@ -20258,7 +20257,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20258
  $s_st = $this->FontStyle;
20259
  if (!empty($cell['textbuffer'][0][3])) { //Font Color
20260
  $cor = $cell['textbuffer'][0][3];
20261
- $this->SetTColor($cor);
20262
  }
20263
  $s_str = $this->strike;
20264
  $this->strike = $cell['textbuffer'][0][8]; //Strikethrough
@@ -20273,15 +20272,15 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20273
  else {
20274
 
20275
  if (!$this->simpleTables){
20276
- if ($bord_det) {
20277
- $btlw = $bord_det['L']['w'];
20278
- $btrw = $bord_det['R']['w'];
20279
- $bttw = $bord_det['T']['w'];
20280
  }
20281
- else {
20282
- $btlw = 0;
20283
- $btrw = 0;
20284
- $bttw = 0;
20285
  }
20286
  if ($table['borders_separate']) {
20287
  $xadj = $btlw + $cell['padding']['L'] +($table['border_spacing_H']/2);
@@ -20318,7 +20317,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20318
 
20319
 
20320
  // TABLE BORDER - if separate
20321
- if (($table['borders_separate'] || ($this->simpleTables && !$table['simple']['border'])) && $table['border']) {
20322
  $halfspaceL = $table['padding']['L'] + ($table['border_spacing_H']/2);
20323
  $halfspaceR = $table['padding']['R'] + ($table['border_spacing_H']/2);
20324
  $halfspaceT = $table['padding']['T'] + ($table['border_spacing_V']/2);
@@ -20333,23 +20332,23 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20333
  if ($i == 0) { // Top
20334
  $tby -= $halfspaceT + ($table['border_details']['T']['w']/2);
20335
  $tbh += $halfspaceT + ($table['border_details']['T']['w']/2);
20336
- $this->setBorder($tab_bord , _BORDER_TOP);
20337
  $corner .= 'T';
20338
  }
20339
  if ($i == ($numrows-1) || (isset($cell['rowspan']) && ($i+$cell['rowspan']) == $numrows)) { // Bottom
20340
  $tbh += $halfspaceB + ($table['border_details']['B']['w']/2);
20341
- $this->setBorder($tab_bord , _BORDER_BOTTOM);
20342
  $corner .= 'B';
20343
  }
20344
  if ($j == 0) { // Left
20345
  $tbx -= $halfspaceL + ($table['border_details']['L']['w']/2);
20346
  $tbw += $halfspaceL + ($table['border_details']['L']['w']/2);
20347
- $this->setBorder($tab_bord , _BORDER_LEFT);
20348
  $corner .= 'L';
20349
  }
20350
  if ($j == ($numcols-1) || (isset($cell['colspan']) && ($j+$cell['colspan']) == $numcols)) { // Right
20351
  $tbw += $halfspaceR + ($table['border_details']['R']['w']/2);
20352
- $this->setBorder($tab_bord , _BORDER_RIGHT);
20353
  $corner .= 'R';
20354
  }
20355
  $this->_tableRect($tbx, $tby, $tbw, $tbh, $tab_bord , $table['border_details'], false, $table['borders_separate'], 'table', $corner, $table['border_spacing_V'], $table['border_spacing_H'] );
@@ -20392,20 +20391,20 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20392
 
20393
  $bx = $x0;
20394
  $by = $y0;
20395
- if ($table['borders_separate']) {
20396
- $bx -= ($table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H']/2);
20397
  if ($tablestartpageno != $this->page) { // IF broken across page
20398
  $by += $table['max_cell_border_width']['T']/2;
20399
  if (empty($tableheader)) { $by -= ($table['border_spacing_V']/2); }
20400
  }
20401
- else if ($split && $startrow > 0 && empty($tableheader)) {
20402
- $by -= ($table['border_spacing_V']/2);
20403
  }
20404
  else {
20405
- $by -= ($table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2);
20406
  }
20407
  }
20408
- else if ($tablestartpageno != $this->page && !empty($tableheader)) { $by += $maxbwtop /2; }
20409
  $by -= $tableheaderadj;
20410
  $bh = $this->y - $by;
20411
  if (!$table['borders_separate']) { $bh -= $table['max_cell_border_width']['B']/2; }
@@ -20420,15 +20419,15 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20420
  if ($startcol==0) { $firstSpread = true; }
20421
  else { $firstSpread = false; }
20422
  if ($table['borders_separate']) {
20423
- $bw += $table['border_spacing_H'];
20424
- if ($firstSpread) {
20425
- $bw += $table['padding']['L'] + $table['border_details']['L']['w'];
20426
  }
20427
  else {
20428
- $bx += ($table['padding']['L'] + $table['border_details']['L']['w']);
20429
  }
20430
- if ($finalSpread) {
20431
- $bw += $table['padding']['R'] + $table['border_details']['R']['w'];
20432
  }
20433
  }
20434
  }
@@ -20437,7 +20436,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20437
  }
20438
 
20439
  if (!$this->ColActive) {
20440
- if (isset($table['bgcolor'][-1])) {
20441
  $color = $this->ConvertColor($table['bgcolor'][-1]);
20442
  if ($color) {
20443
  $this->tableBackgrounds[$level*9][] = array('gradient'=>false, 'x'=>$bx, 'y'=>$by, 'w'=>$bw, 'h'=>$bh, 'col'=>$color);
@@ -20477,7 +20476,7 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20477
 
20478
  if ($this->cacheTables) { fclose($fh); }
20479
 
20480
- if ($split) {
20481
  // Are there more columns to print on a next page?
20482
  if ($lastCol < $numcols-1) {
20483
  $splitpg++;
@@ -20485,16 +20484,16 @@ function _tableWrite(&$table, $split=false, $startrow=0, $startcol=0, $splitpg=0
20485
  return array(false, $startrow, $startcol, $splitpg, $returny, $y0);
20486
  }
20487
  else {
20488
- if ($this->cacheTables) {
20489
- unlink($table['cache']);
20490
- @unlink($table['cache'].'.bak');
20491
  }
20492
  return array(true,0,0,0);
20493
  }
20494
  }
20495
- if ($this->cacheTables) {
20496
- unlink($table['cache']);
20497
- @unlink($table['cache'].'.bak');
20498
  }
20499
 
20500
  }//END OF FUNCTION _tableWrite()
@@ -20550,29 +20549,29 @@ function _putocg() {
20550
  function _putpatterns() {
20551
  for ($i = 1; $i <= count($this->patterns); $i++) {
20552
  $x = $this->patterns[$i]['x'];
20553
- $y = $this->patterns[$i]['y'];
20554
  $w = $this->patterns[$i]['w'];
20555
- $h = $this->patterns[$i]['h'];
20556
- $pgh = $this->patterns[$i]['pgh'];
20557
  $orig_w = $this->patterns[$i]['orig_w'];
20558
- $orig_h = $this->patterns[$i]['orig_h'];
20559
  $image_id = $this->patterns[$i]['image_id'];
20560
  $itype = $this->patterns[$i]['itype'];
20561
 
20562
- if ($this->patterns[$i]['x_repeat']) { $x_repeat = true; }
20563
  else { $x_repeat = false; }
20564
  if ($this->patterns[$i]['y_repeat']) { $y_repeat = true; }
20565
  else { $y_repeat = false; }
20566
  $x_pos = $this->patterns[$i]['x_pos'];
20567
- if (stristr($x_pos ,'%') ) {
20568
- $x_pos += 0;
20569
- $x_pos /= 100;
20570
  $x_pos = ($w * $x_pos) - ($orig_w/_MPDFK * $x_pos);
20571
  }
20572
  $y_pos = $this->patterns[$i]['y_pos'];
20573
- if (stristr($y_pos ,'%') ) {
20574
- $y_pos += 0;
20575
- $y_pos /= 100;
20576
  $y_pos = ($h * $y_pos) - ($orig_h/_MPDFK * $y_pos);
20577
  }
20578
  $adj_x = ($x_pos + $x) *_MPDFK;
@@ -20580,13 +20579,13 @@ function _putpatterns() {
20580
  $img_obj = false;
20581
  if ($itype == 'svg' || $itype == 'wmf') {
20582
  foreach($this->formobjects AS $fo) {
20583
- if ($fo['i'] == $image_id) {
20584
- $img_obj = $fo['n'];
20585
  $fo_w = $fo['w'];
20586
  $fo_h = -$fo['h'];
20587
  $wmf_x = $fo['x'];
20588
- $wmf_y = $fo['y'];
20589
- break;
20590
  }
20591
  }
20592
  }
@@ -20623,7 +20622,7 @@ function _putpatterns() {
20623
  $this->_out('/F'.$font['subsetfontids'][$k].' '.$font['n'][$k].' 0 R');
20624
  }
20625
  }
20626
- else {
20627
  $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
20628
  }
20629
  }
@@ -20706,7 +20705,7 @@ function _putresources() {
20706
  $this->_out('/F'.$font['subsetfontids'][$k].' '.$font['n'][$k].' 0 R');
20707
  }
20708
  }
20709
- else {
20710
  $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
20711
  }
20712
  }
@@ -20739,9 +20738,9 @@ function _putresources() {
20739
 
20740
 
20741
  // mPDF 5.6.01
20742
- if ($this->hasOC || count($this->layers)) {
20743
  $this->_out('/Properties <<');
20744
- if ($this->hasOC) {
20745
  $this->_out('/OC1 '.$this->n_ocg_print.' 0 R /OC2 '.$this->n_ocg_view.' 0 R /OC3 '.$this->n_ocg_hidden.' 0 R ');
20746
  }
20747
  if (count($this->layers)) {
@@ -20818,31 +20817,31 @@ function MovePages($target_page, $start_page, $end_page=-1) {
20818
  foreach($this->PageNumSubstitutions AS $k=>$v) {
20819
  if ($this->PageNumSubstitutions[$k]['from']==$target_page) {
20820
  $tp_present = true;
20821
- if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20822
  $this->PageNumSubstitutions[$k]['suppress']='off';
20823
  }
20824
  }
20825
  if ($this->PageNumSubstitutions[$k]['from']==$start_page) {
20826
  $sp_present = true;
20827
- if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20828
  $this->PageNumSubstitutions[$k]['suppress']='off';
20829
  }
20830
  }
20831
  if ($this->PageNumSubstitutions[$k]['from']==($end_page+1)) {
20832
  $ep_present = true;
20833
- if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20834
  $this->PageNumSubstitutions[$k]['suppress']='off';
20835
  }
20836
  }
20837
  }
20838
 
20839
- if (!$tp_present) {
20840
  list($tp_type, $tp_suppress, $tp_reset) = $this->docPageSettings($target_page);
20841
  }
20842
- if (!$sp_present) {
20843
  list($sp_type, $sp_suppress, $sp_reset) = $this->docPageSettings($start_page);
20844
  }
20845
- if (!$ep_present) {
20846
  list($ep_type, $ep_suppress, $ep_reset) = $this->docPageSettings($start_page-1);
20847
  }
20848
 
@@ -20977,27 +20976,27 @@ function MovePages($target_page, $start_page, $end_page=-1) {
20977
  if (count($this->PageNumSubstitutions)) {
20978
  $newarr = array();
20979
  foreach($this->PageNumSubstitutions AS $k=>$v) {
20980
- if($this->PageNumSubstitutions[$k]['from']>=$start_page && $this->PageNumSubstitutions[$k]['from']<=$end_page) {
20981
- $this->PageNumSubstitutions[$k]['from'] += ($target_page - $start_page);
20982
- $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20983
  }
20984
  else if($this->PageNumSubstitutions[$k]['from']>=$target_page && $this->PageNumSubstitutions[$k]['from']<$start_page) {
20985
  $this->PageNumSubstitutions[$k]['from'] += $n_toc;
20986
- $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20987
  }
20988
  else {
20989
- $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20990
  }
20991
  }
20992
 
20993
  if (!$sp_present) {
20994
- $newarr[$target_page] = array('from'=>$target_page, 'suppress'=>$sp_suppress, 'reset'=>$sp_reset, 'type'=>$sp_type);
20995
  }
20996
  if (!$tp_present) {
20997
- $newarr[($target_page + $n_toc)] = array('from'=>($target_page+$n_toc), 'suppress'=>$tp_suppress, 'reset'=>$tp_reset, 'type'=>$tp_type);
20998
  }
20999
  if (!$ep_present && $end_page>count($this->pages)) {
21000
- $newarr[($end_page+1)] = array('from'=>($end_page+1), 'suppress'=>$ep_suppress, 'reset'=>$ep_reset, 'type'=>$ep_type);
21001
  }
21002
  ksort($newarr);
21003
  $this->PageNumSubstitutions = array();
@@ -21165,7 +21164,7 @@ function printcellbuffer() {
21165
  //==================================================================
21166
  function printtablebuffer() {
21167
 
21168
- if (!$this->table_rotate) {
21169
  $this->pages[$this->page] .= $this->tablebuffer;
21170
  foreach($this->tbrot_Links AS $p => $l) {
21171
  foreach($l AS $v) {
@@ -21177,7 +21176,7 @@ function printtablebuffer() {
21177
 
21178
 
21179
 
21180
- return;
21181
  }
21182
  // else if rotated
21183
  $lm = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_left'];
@@ -21215,7 +21214,7 @@ function printtablebuffer() {
21215
  $this->pages[$this->page] .= $this->transformRotate($this->table_rotate, $this->tbrot_x0 , $this->tbrot_y0 , true)."\n";
21216
 
21217
  // Now output the adjusted values
21218
- $this->pages[$this->page] .= $this->tablebuffer;
21219
 
21220
 
21221
  foreach($this->tbrot_Links AS $p => $l) {
@@ -21272,7 +21271,7 @@ function printtablebuffer() {
21272
  //==================================================================
21273
  // Keep-with-table This buffers contents of h1-6 to keep on page with table
21274
  function printkwtbuffer() {
21275
- if (!$this->kwt_moved) {
21276
  foreach($this->kwt_buffer AS $s) { $this->pages[$this->page] .= $s['s']."\n"; }
21277
  foreach($this->kwt_Links AS $p => $l) {
21278
  foreach($l AS $v) {
@@ -21284,7 +21283,7 @@ function printkwtbuffer() {
21284
 
21285
 
21286
 
21287
- return;
21288
  }
21289
 
21290
  //Start Transformation
@@ -21358,7 +21357,7 @@ function printdivbuffer() {
21358
  $top[$p1] = $this->kt_y00;
21359
 
21360
  $top2 = $this->h;
21361
- foreach($this->divbuffer AS $key=>$s) {
21362
  if ($s['page'] == $p2) {
21363
  $top2 = MIN($s['y'], $top2);
21364
  }
@@ -21372,7 +21371,7 @@ function printdivbuffer() {
21372
  $yadj[$p2] = $height[$p1];
21373
 
21374
  // Output without any transformation
21375
- if ($this->ColActive || !$this->keep_block_together || $this->blk[$this->blklvl]['startpage'] == $this->page || ($this->page - $this->blk[$this->blklvl]['startpage']) > 1 || ($height[$p1]+$height[$p2]) > $this->h) {
21376
  foreach($this->divbuffer AS $s) { $this->pages[$s['page']] .= $s['s']."\n"; }
21377
  foreach($this->ktLinks AS $p => $l) {
21378
  foreach($l AS $v) {
@@ -21394,26 +21393,26 @@ function printdivbuffer() {
21394
  $this->ktBMoutlines = array();
21395
  $this->_kttoc = array();
21396
  $this->keep_block_together = 0;
21397
- return;
21398
  }
21399
  else {
21400
  $np = '';
21401
  $pre = '';
21402
  $ispre = true;
21403
- foreach($this->divbuffer AS $key=>$s) {
21404
  // callback function
21405
  $t = $s['s'];
21406
  $p = $s['page'];
21407
  if (preg_match('/(___PAGE___START'.date('jY').')/', $t)) { $ispre = false; }
21408
- else if (preg_match('/(___HEADER___MARKER'.date('jY').')/', $t)) {
21409
  $np .= $t."\n".$pre;
21410
- continue;
21411
  }
21412
  else {
21413
  $t = preg_replace('/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/e',"\$this->blockAdjust('Td',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21414
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/e',"\$this->blockAdjust('re',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4')",$t);
21415
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) l/e',"\$this->blockAdjust('l',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21416
- $t = preg_replace('/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/e',"\$this->blockAdjust('img',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4','\\5')",$t);
21417
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) m/e',"\$this->blockAdjust('draw',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21418
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/e',"\$this->blockAdjust('bezier',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4','\\5','\\6')",$t);
21419
  }
@@ -21480,8 +21479,8 @@ function Ellipse($x,$y,$rx,$ry,$style='S') {
21480
  $ly=4/3*(M_SQRT2-1)*$ry;
21481
  $h=$this->h;
21482
  $this->_out(sprintf('%.3F %.3F m %.3F %.3F %.3F %.3F %.3F %.3F c', ($x+$rx)*_MPDFK,($h-$y)*_MPDFK, ($x+$rx)*_MPDFK,($h-($y-$ly))*_MPDFK, ($x+$lx)*_MPDFK,($h-($y-$ry))*_MPDFK, $x*_MPDFK,($h-($y-$ry))*_MPDFK));
21483
- $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c', ($x-$lx)*_MPDFK,($h-($y-$ry))*_MPDFK, ($x-$rx)*_MPDFK,($h-($y-$ly))*_MPDFK, ($x-$rx)*_MPDFK,($h-$y)*_MPDFK));
21484
- $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c', ($x-$rx)*_MPDFK,($h-($y+$ly))*_MPDFK, ($x-$lx)*_MPDFK,($h-($y+$ry))*_MPDFK, $x*_MPDFK,($h-($y+$ry))*_MPDFK));
21485
  $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c %s', ($x+$lx)*_MPDFK,($h-($y+$ry))*_MPDFK, ($x+$rx)*_MPDFK,($h-($y+$ly))*_MPDFK, ($x+$rx)*_MPDFK,($h-$y)*_MPDFK, $op));
21486
  }
21487
 
@@ -21493,7 +21492,7 @@ function Ellipse($x,$y,$rx,$ry,$style='S') {
21493
  // ====================================================
21494
  // ====================================================
21495
 
21496
- //
21497
  // ****************************
21498
  // ****************************
21499
 
@@ -21525,9 +21524,9 @@ function SubstituteChars($html) {
21525
 
21526
 
21527
  function SubstituteCharsSIP(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21528
- if (preg_match("/^(.*?)([\x{20000}-\x{2FFFF}]+)(.*)/u", $writehtml_e, $m)) {
21529
  if (isset($this->CurrentFont['sipext']) && $this->CurrentFont['sipext']) {
21530
- $font = $this->CurrentFont['sipext'];
21531
  if (!in_array($font, $this->available_unifonts)) { return 0; }
21532
  $writehtml_a[$writehtml_i] = $writehtml_e = $m[1];
21533
  array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
@@ -21535,7 +21534,7 @@ function SubstituteCharsSIP(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21535
  return 4;
21536
  }
21537
  }
21538
- return 0;
21539
  }
21540
 
21541
  // If core font is selected in document which is not onlyCoreFonts - substitute with non-core font
@@ -21550,16 +21549,16 @@ function SubstituteCharsNonCore(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21550
  $flag = 0;
21551
  $ftype = '';
21552
  $u = array();
21553
- if (!$this->subArrMB) {
21554
- include(_MPDF_PATH.'includes/subs_core.php');
21555
  $this->subArrMB['a'] = $aarr;
21556
  $this->subArrMB['s'] = $sarr;
21557
  $this->subArrMB['z'] = $zarr;
21558
  }
21559
  foreach($unicode AS $c => $char) {
21560
- if (($char> 127 || ($flag==1 && $char==32)) && $char != 173 && (!isset($this->subArrMB['a'][$char]) || ($flag==1 && $char==32)) && ($char<1536 || ($char>1791 && $char < 2304) || $char>3455)) {
21561
  if ($flag==0) { $start=$c; }
21562
- $flag=1;
21563
  $u[] = $char;
21564
  }
21565
  else if ($flag>0) { $end=$c-1; break; }
@@ -21570,7 +21569,7 @@ function SubstituteCharsNonCore(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21570
  if (!is_array($this->backupSubsFont)) { $this->backupSubsFont = array("$this->backupSubsFont"); }
21571
  foreach($this->backupSubsFont AS $bsfctr=>$bsf) {
21572
  if ($this->fonttrans[$bsf] == 'chelvetica' || $this->fonttrans[$bsf] == 'ctimes' || $this->fonttrans[$bsf] == 'ccourier') { continue; }
21573
- $font = $bsf;
21574
  unset($cw);
21575
  $cw = '';
21576
  if (isset($this->fonts[$font])) { $cw = &$this->fonts[$font]['cw']; }
@@ -21612,7 +21611,7 @@ function SubstituteCharsNonCore(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21612
  }
21613
  }
21614
 
21615
- unset($cw);
21616
  return 0;
21617
  }
21618
 
@@ -21629,13 +21628,13 @@ function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21629
  if (($flag == 0 || $flag==2) && (!$this->_charDefined($cw,$char) || ($flag==2 && $char==32)) && $this->checkSIP && $char > 131071) { // Unicode Plane 2 (SIP)
21630
  if (in_array($this->FontFamily ,$this->available_CJK_fonts)) { return 0; }
21631
  if ($flag==0) { $start=$c; }
21632
- $flag=2;
21633
  $u[] = $char;
21634
  }
21635
- //else if (($flag == 0 || $flag==1) && $char != 173 && !$this->_charDefined($cw,$char) && ($char<1423 || ($char>3583 && $char < 11263))) {
21636
- else if (($flag == 0 || $flag==1) && $char != 173 && (!$this->_charDefined($cw,$char) || ($flag==1 && $char==32)) && ($char<1536 || ($char>1791 && $char < 2304) || $char>3455)) {
21637
  if ($flag==0) { $start=$c; }
21638
- $flag=1;
21639
  $u[] = $char;
21640
  }
21641
  else if ($flag>0) { $end=$c-1; break; }
@@ -21645,7 +21644,7 @@ function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21645
  if ($flag == 2) { // SIP
21646
  // Check if current CJK font has a ext-B related font
21647
  if (isset($this->CurrentFont['sipext']) && $this->CurrentFont['sipext']) {
21648
- $font = $this->CurrentFont['sipext'];
21649
  unset($cw);
21650
  $cw = '';
21651
  if (isset($this->fonts[$font])) { $cw = &$this->fonts[$font]['cw']; }
@@ -21710,35 +21709,35 @@ function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21710
  }
21711
  }
21712
  }
21713
- return 0;
21714
  }
21715
 
21716
 
21717
  // FIRST TRY CORE FONTS
21718
- if (!$this->PDFA && !$this->PDFX) {
21719
  $repl = array();
21720
- if (!$this->subArrMB) {
21721
- include(_MPDF_PATH.'includes/subs_core.php');
21722
  $this->subArrMB['a'] = $aarr;
21723
  $this->subArrMB['s'] = $sarr;
21724
  $this->subArrMB['z'] = $zarr;
21725
  }
21726
- if (isset($this->subArrMB['a'][$u[0]])) {
21727
- $font = 'tta'; $ftype = 'C';
21728
  foreach($u AS $char) {
21729
  if ($this->subArrMB['a'][$char]) { $repl[] = $this->subArrMB['a'][$char]; }
21730
  else { break; }
21731
  }
21732
  }
21733
- else if (isset($this->subArrMB['z'][$u[0]])) {
21734
- $font = 'ttz'; $ftype = 'C';
21735
  foreach($u AS $char) {
21736
  if ($this->subArrMB['z'][$char]) { $repl[] = $this->subArrMB['z'][$char]; }
21737
  else { break; }
21738
  }
21739
  }
21740
- else if (isset($this->subArrMB['s'][$u[0]])) {
21741
- $font = 'tts'; $ftype = 'C';
21742
  foreach($u AS $char) {
21743
  if ($this->subArrMB['s'][$char]) { $repl[] = $this->subArrMB['s'][$char]; }
21744
  else { break; }
@@ -21778,7 +21777,7 @@ function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21778
  if (!$cw) { continue; }
21779
  $l = 0;
21780
  foreach($u AS $char) {
21781
- if ($char == 173 || $this->_charDefined($cw,$char) || ($char>1536 && $char<1791) || ($char>2304 && $char<3455 )) { // Arabic and Indic
21782
  $l++;
21783
  }
21784
  else {
@@ -21803,7 +21802,7 @@ function SubstituteCharsMB(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21803
  }
21804
  }
21805
 
21806
- unset($cw);
21807
  return 0;
21808
  }
21809
 
@@ -21866,7 +21865,7 @@ function SubstituteHiEntities($html) {
21866
  function is_utf8(&$string) {
21867
  if ($string === mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32")) {
21868
  return true;
21869
- }
21870
  else {
21871
  if ($this->ignore_invalid_utf8) {
21872
  $string = mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") ;
@@ -21876,7 +21875,7 @@ function is_utf8(&$string) {
21876
  return false;
21877
  }
21878
  }
21879
- }
21880
 
21881
 
21882
  function purify_utf8($html,$lo=true) {
@@ -21885,8 +21884,8 @@ function purify_utf8($html,$lo=true) {
21885
  // converts html_entities > ASCII 127 to UTF-8
21886
  // Only exception - leaves low ASCII entities e.g. &lt; &amp; etc.
21887
  // Leaves in particular &lt; to distinguish from tag marker
21888
- if (!$this->is_utf8($html)) {
21889
- echo "<p><b>HTML contains invalid UTF-8 character(s)</b></p>";
21890
  while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") != $html) {
21891
  $a = iconv('UTF-8', 'UTF-8', $html);
21892
  echo ($a);
@@ -21900,11 +21899,11 @@ function purify_utf8($html,$lo=true) {
21900
  $html = substr($html, $pos);
21901
  }
21902
  echo $html;
21903
- $this->Error("");
21904
  }
21905
  $html = preg_replace("/\r/", "", $html );
21906
 
21907
- // converts html_entities > ASCII 127 to UTF-8
21908
  // Leaves in particular &lt; to distinguish from tag marker
21909
  $html = $this->SubstituteHiEntities($html);
21910
 
@@ -21917,10 +21916,10 @@ function purify_utf8($html,$lo=true) {
21917
  function purify_utf8_text($txt) {
21918
  // For TEXT
21919
  // Make sure UTF-8 string of characters
21920
- if(!mb_strlen($txt))
21921
  {
21922
  $txt = ' ';
21923
- }
21924
 
21925
  if (!$this->is_utf8($txt)) { $this->Error("Text contains invalid UTF-8 character(s)"); }
21926
 
@@ -21929,7 +21928,7 @@ function purify_utf8_text($txt) {
21929
  return ($txt);
21930
  }
21931
  function all_entities_to_utf8($txt) {
21932
- // converts txt_entities > ASCII 127 to UTF-8
21933
  // Leaves in particular &lt; to distinguish from tag marker
21934
  $txt = $this->SubstituteHiEntities($txt);
21935
 
@@ -22062,7 +22061,7 @@ function AutoFont($html) {
22062
  $a[$i] = $e;
22063
  }
22064
  else {
22065
- $a[$i] = '<'.$e.'>';
22066
  }
22067
  }
22068
  $n = implode('',$a);
@@ -22096,27 +22095,27 @@ function blockAdjust($type,$k,$xadj,$yadj,$a,$b,$c=0,$d=0,$e=0,$f=0) {
22096
  if ($type == 'Td') { // xpos,ypos
22097
  $a += ($xadj * $k);
22098
  $b -= ($yadj * $k);
22099
- return 'BT '.sprintf('%.3F %.3F',$a,$b).' Td';
22100
  }
22101
  else if ($type == 're') { // xpos,ypos,width,height
22102
  $a += ($xadj * $k);
22103
  $b -= ($yadj * $k);
22104
- return sprintf('%.3F %.3F %.3F %.3F',$a,$b,$c,$d).' re';
22105
  }
22106
  else if ($type == 'l') { // xpos,ypos,x2pos,y2pos
22107
  $a += ($xadj * $k);
22108
  $b -= ($yadj * $k);
22109
- return sprintf('%.3F %.3F l',$a,$b);
22110
  }
22111
  else if ($type == 'img') { // width,height,xpos,ypos
22112
  $c += ($xadj * $k);
22113
  $d -= ($yadj * $k);
22114
- return sprintf('q %.3F 0 0 %.3F %.3F %.3F',$a,$b,$c,$d).' cm /'.$e;
22115
  }
22116
  else if ($type == 'draw') { // xpos,ypos
22117
  $a += ($xadj * $k);
22118
  $b -= ($yadj * $k);
22119
- return sprintf('%.3F %.3F m',$a,$b);
22120
  }
22121
  else if ($type == 'bezier') { // xpos,ypos,x2pos,y2pos,x3pos,y3pos
22122
  $a += ($xadj * $k);
@@ -22125,7 +22124,7 @@ function blockAdjust($type,$k,$xadj,$yadj,$a,$b,$c=0,$d=0,$e=0,$f=0) {
22125
  $d -= ($yadj * $k);
22126
  $e += ($xadj * $k);
22127
  $f -= ($yadj * $k);
22128
- return sprintf('%.3F %.3F %.3F %.3F %.3F %.3F',$a,$b,$c,$d,$e,$f).' c';
22129
  }
22130
  }
22131
 
@@ -22143,7 +22142,7 @@ function ConvertColor($color="#000000"){
22143
  $cor = preg_replace('/\s+.*/','',$color); // in case of Background: #CCC url() x-repeat etc.
22144
  if (strlen($cor) == 4) { // Turn #RGB into #RRGGBB
22145
  $cor = "#" . $cor[1] . $cor[1] . $cor[2] . $cor[2] . $cor[3] . $cor[3];
22146
- }
22147
  $r = hexdec(substr($cor, 1, 2));
22148
  $g = hexdec(substr($cor, 3, 2));
22149
  $b = hexdec(substr($cor, 5, 2));
@@ -22153,37 +22152,37 @@ function ConvertColor($color="#000000"){
22153
  $type= $m[1];
22154
  $cores = explode(",", $m[2]);
22155
  $ncores = count($cores);
22156
- if (stristr($cores[0],'%') ) {
22157
- $cores[0] += 0;
22158
  if ($type=='rgb' || $type=='rgba') { $cores[0] = intval($cores[0]*255/100); }
22159
  }
22160
- if ($ncores>1 && stristr($cores[1],'%') ) {
22161
- $cores[1] += 0;
22162
  if ($type=='rgb' || $type=='rgba') { $cores[1] = intval($cores[1]*255/100); }
22163
  if ($type=='hsl' || $type=='hsla') { $cores[1] = $cores[1]/100; }
22164
  }
22165
- if ($ncores>2 && stristr($cores[2],'%') ) {
22166
- $cores[2] += 0;
22167
  if ($type=='rgb' || $type=='rgba') { $cores[2] = intval($cores[2]*255/100); }
22168
  if ($type=='hsl' || $type=='hsla') { $cores[2] = $cores[2]/100; }
22169
  }
22170
- if ($ncores>3 && stristr($cores[3],'%') ) {
22171
- $cores[3] += 0;
22172
  }
22173
 
22174
  if ($type=='rgb') { $c = array(3,$cores[0],$cores[1],$cores[2]); }
22175
  else if ($type=='rgba') { $c = array(5,$cores[0],$cores[1],$cores[2],$cores[3]*100); }
22176
  else if ($type=='cmyk') { $c = array(4,$cores[0],$cores[1],$cores[2],$cores[3]); }
22177
  else if ($type=='cmyka') { $c = array(6,$cores[0],$cores[1],$cores[2],$cores[3],$cores[4]*100); }
22178
- else if ($type=='hsl' || $type=='hsla') {
22179
  $conv = $this->hsl2rgb($cores[0]/360,$cores[1],$cores[2]);
22180
  if ($type=='hsl') { $c = array(3,$conv[0],$conv[1],$conv[2]); }
22181
  else if ($type=='hsla') { $c = array(5,$conv[0],$conv[1],$conv[2],$cores[3]*100); }
22182
  }
22183
- else if ($type=='spot') {
22184
  $name = strtoupper(trim($cores[0]));
22185
  if(!isset($this->spotColors[$name])) $this->Error('Undefined spot color: '.$name);
22186
- $c = array(2,$this->spotColors[$name]['i'],$cores[1]);
22187
  }
22188
  }
22189
 
@@ -22197,57 +22196,57 @@ function ConvertColor($color="#000000"){
22197
  }
22198
  else if ($c[0]==2) { // SPOT COLOR
22199
  if (!isset($this->spotColorIDs[$c[1]])) { die('Error: Spot colour has not been defined - '.$this->spotColorIDs[$c[1]]); }
22200
- if ($this->PDFA) {
22201
  if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "Spot color specified '".$this->spotColorIDs[$c[1]]."' (converted to process color)"; }
22202
- if ($this->restrictColorSpace!=3) {
22203
- $sp = $this->spotColors[$this->spotColorIDs[$c[1]]];
22204
- $c = $this->cmyk2rgb(array(4,$sp['c'],$sp['m'],$sp['y'],$sp['k']));
22205
  }
22206
  }
22207
- else if ($this->restrictColorSpace==1) {
22208
- $sp = $this->spotColors[$this->spotColorIDs[$c[1]]];
22209
- $c = $this->cmyk2gray(array(4,$sp['c'],$sp['m'],$sp['y'],$sp['k']));
22210
  }
22211
  }
22212
  else if ($c[0]==3) { // RGB
22213
- if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22214
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "RGB color specified '".$color."' (converted to CMYK)"; }
22215
- $c = $this->rgb2cmyk($c);
22216
  }
22217
  else if ($this->restrictColorSpace==1) { $c = $this->rgb2gray($c); }
22218
  else if ($this->restrictColorSpace==3) { $c = $this->rgb2cmyk($c); }
22219
  }
22220
  else if ($c[0]==4) { // CMYK
22221
- if ($this->PDFA && $this->restrictColorSpace!=3) {
22222
  if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "CMYK color specified '".$color."' (converted to RGB)"; }
22223
- $c = $this->cmyk2rgb($c);
22224
  }
22225
  else if ($this->restrictColorSpace==1) { $c = $this->cmyk2gray($c); }
22226
  else if ($this->restrictColorSpace==2) { $c = $this->cmyk2rgb($c); }
22227
  }
22228
  else if ($c[0]==5) { // RGBa
22229
- if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22230
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "RGB color with transparency specified '".$color."' (converted to CMYK without transparency)"; }
22231
- $c = $this->rgb2cmyk($c);
22232
  $c = array(4, $c[1], $c[2], $c[3], $c[4]);
22233
  }
22234
- else if ($this->PDFA && $this->restrictColorSpace!=3) {
22235
  if (!$this->PDFAauto) { $this->PDFAXwarnings[] = "RGB color with transparency specified '".$color."' (converted to RGB without transparency)"; }
22236
- $c = $this->rgb2cmyk($c);
22237
  $c = array(4, $c[1], $c[2], $c[3], $c[4]);
22238
  }
22239
  else if ($this->restrictColorSpace==1) { $c = $this->rgb2gray($c); }
22240
  else if ($this->restrictColorSpace==3) { $c = $this->rgb2cmyk($c); }
22241
  }
22242
  else if ($c[0]==6) { // CMYKa
22243
- if ($this->PDFA && $this->restrictColorSpace!=3) {
22244
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "CMYK color with transparency specified '".$color."' (converted to RGB without transparency)"; }
22245
- $c = $this->cmyk2rgb($c);
22246
  $c = array(3, $c[1], $c[2], $c[3]);
22247
  }
22248
- else if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22249
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "CMYK color with transparency specified '".$color."' (converted to CMYK without transparency)"; }
22250
- $c = $this->cmyk2rgb($c);
22251
  $c = array(3, $c[1], $c[2], $c[3]);
22252
  }
22253
  else if ($this->restrictColorSpace==1) { $c = $this->cmyk2gray($c); }
@@ -22256,7 +22255,7 @@ function ConvertColor($color="#000000"){
22256
  }
22257
  if (is_array($c)) {
22258
  $c = array_pad($c, 6, 0);
22259
- $cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF) );
22260
  }
22261
  return $cstr;
22262
  }
@@ -22365,7 +22364,7 @@ function _invertColor($cor) {
22365
  }
22366
  else if ($cor[0]==1) { // Grayscale
22367
  return array(1, (255-$cor[1]));
22368
- }
22369
  // Cannot cope with non-RGB colors at present
22370
  die('Error in _invertColor - trying to invert non-RGB color');
22371
  }
@@ -22395,19 +22394,19 @@ function ConvertSize($size=5,$maxsize=0,$fontsize=false,$usefontsize=true){
22395
  elseif ( stristr($size,'mm') ) $size += 0; //millimeters
22396
  elseif ( stristr($size,'pt') ) $size *= 25.4/72; //72 pts/inch
22397
  elseif ( stristr($size,'em') ) {
22398
- $size += 0; //make "0.83em" become simply "0.83"
22399
  if ($fontsize) { $size *= $fontsize; }
22400
  else { $size *= $maxsize; }
22401
  }
22402
  elseif ( stristr($size,'%') ) {
22403
- $size += 0; //make "90%" become simply "90"
22404
  if ($fontsize && $usefontsize) { $size *= $fontsize/100; }
22405
  else { $size *= $maxsize/100; }
22406
  }
22407
- elseif ( stristr($size,'in') ) $size *= 25.4; //inches
22408
- elseif ( stristr($size,'pc') ) $size *= 38.1/9; //PostScript picas
22409
  elseif ( stristr($size,'ex') ) { // Approximates "ex" as half of font height
22410
- $size += 0; //make "3.5ex" become simply "3.5"
22411
  if ($fontsize) { $size *= $fontsize/2; }
22412
  else { $size *= $maxsize/2; }
22413
  }
@@ -22470,7 +22469,7 @@ function AdjustHTML($html, $tabSpaces=8) {
22470
 
22471
 
22472
  preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
22473
- if (count($svgi[0])) {
22474
  for($i=0;$i<count($svgi[0]);$i++) {
22475
  $file = _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.$i.'.svg';
22476
  //Save to local file
@@ -22569,8 +22568,8 @@ function AdjustHTML($html, $tabSpaces=8) {
22569
  $html = str_replace("</erp>","</pre>",$html);
22570
  $html = str_replace("<aeratxet","<textarea",$html);
22571
  $html = str_replace("</aeratxet>","</textarea>",$html);
22572
- $html = str_replace("</innerpre","</pre",$html);
22573
- $html = str_replace("<innerpre","<pre",$html);
22574
 
22575
  $html = preg_replace('/<textarea([^>]*)><\/textarea>/si','<textarea\\1> </textarea>',$html);
22576
  $html = preg_replace('/(<table[^>]*>)\s*(<caption)(.*?<\/caption>)(.*?<\/table>)/si','\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3',$html); // *TABLES*
@@ -22582,7 +22581,7 @@ function AdjustHTML($html, $tabSpaces=8) {
22582
  function dec2other($num, $cp) {
22583
  $nstr = (string) $num;
22584
  $rnum = '';
22585
- for ($i=0;$i<strlen($nstr);$i++) {
22586
  if ($this->_charDefined($this->CurrentFont['cw'],$cp+intval($nstr[$i]))) { // contains arabic-indic numbers
22587
  $rnum .= code2utf($cp+intval($nstr[$i]));
22588
  }
@@ -22714,7 +22713,3 @@ function SetJS($script) {
22714
 
22715
  }//end of Class
22716
 
22717
-
22718
-
22719
-
22720
- ?>
36
  require_once(_MPDF_PATH.'includes/functions.php');
37
  require_once(_MPDF_PATH.'config_cp.php');
38
 
39
+ if (!defined('_JPGRAPH_PATH')) define("_JPGRAPH_PATH", _MPDF_PATH.'jpgraph/');
40
 
41
  if (!defined('_MPDF_TEMP_PATH')) define("_MPDF_TEMP_PATH", _MPDF_PATH.'tmp/');
42
 
195
  var $table_error_report;
196
  var $table_error_report_param;
197
  var $biDirectional;
198
+ var $text_input_as_HTML;
199
  var $anchor2Bookmark;
200
  var $list_indent_first_level;
201
  var $shrink_tables_to_fit;
312
 
313
  var $watermarkImgAlpha;
314
  var $PDFAXwarnings;
315
+ var $MetadataRoot;
316
  var $OutputIntentRoot;
317
+ var $InfoRoot;
318
  var $current_filename;
319
  var $parsers;
320
  var $current_parser;
335
  var $ReqFontStyle;
336
  var $tableClipPath ;
337
  var $forceExactLineheight;
338
+ var $listOcc;
339
 
340
  var $fullImageHeight;
341
  var $inFixedPosBlock; // Internal flag for position:fixed block
530
  var $HTMLFooter;
531
  var $HTMLHeaderE;
532
  var $HTMLFooterE;
533
+ var $bufferoutput;
534
 
535
  var $showdefaultpagenos; // DEPRACATED -left for backward compatability
536
 
565
  var $ColL;
566
  var $ColWidth;
567
  var $ColGap;
568
+ // COLUMNS
569
  var $ColR;
570
  var $ChangeColumn;
571
  var $columnbuffer;
592
  var $ws; // Word spacing
593
  var $HREF;
594
  var $pgwidth;
595
+ var $fontlist;
596
  var $oldx;
597
  var $oldy;
598
  var $B;
696
  var $margin_bottom_collapse;
697
  var $list_indent;
698
  var $list_align;
699
+ var $list_margin_bottom;
700
  var $default_font_size; // in pts
701
  var $original_default_font_size; // used to save default sizes when using table default
702
  var $original_default_font;
739
  var $charspacing;
740
 
741
  //Private properties FROM FPDF
742
+ var $DisplayPreferences;
743
  var $outlines;
744
  var $flowingBlockAttr;
745
  var $page; //current page number
826
  // **********************************
827
  // **********************************
828
 
829
+ function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
830
 
831
 
832
  $this->time0 = microtime(true);
907
  'palevioletred'=>'#D87093','peachpuff'=>'#FFDAB9','pink'=>'#FFC0CB','powderblue'=>'#B0E0E6','purple'=>'#800080',
908
  'red'=>'#FF0000','royalblue'=>'#4169E1','salmon'=>'#FA8072','seagreen'=>'#2E8B57','sienna'=>'#A0522D','silver'=>'#C0C0C0','skyblue'=>'#87CEEB',
909
  'slategray'=>'#708090','springgreen'=>'#00FF7F','steelblue'=>'#4682B4','tan'=>'#D2B48C','teal'=>'#008080','thistle'=>'#D8BFD8','turquoise'=>'#40E0D0',
910
+ 'violetred'=>'#D02090','white'=>'#FFFFFF','yellow'=>'#FFFF00',
911
+ 'aliceblue'=>'#f0f8ff', 'azure'=>'#f0ffff', 'bisque'=>'#ffe4c4', 'blanchedalmond'=>'#ffebcd', 'blueviolet'=>'#8a2be2', 'burlywood'=>'#deb887',
912
+ 'chartreuse'=>'#7fff00', 'coral'=>'#ff7f50', 'cornsilk'=>'#fff8dc', 'cyan'=>'#00ffff', 'darkcyan'=>'#008b8b', 'darkgray'=>'#a9a9a9',
913
+ 'darkgrey'=>'#a9a9a9', 'darkkhaki'=>'#bdb76b', 'darkolivegreen'=>'#556b2f', 'darkorchid'=>'#9932cc', 'darksalmon'=>'#e9967a',
914
+ 'darkslateblue'=>'#483d8b', 'darkslategrey'=>'#2f4f4f', 'darkturquoise'=>'#00ced1', 'deeppink'=>'#ff1493', 'dimgray'=>'#696969',
915
+ 'dimgrey'=>'#696969', 'floralwhite'=>'#fffaf0', 'ghostwhite'=>'#f8f8ff', 'goldenrod'=>'#daa520', 'grey'=>'#808080', 'honeydew'=>'#f0fff0',
916
+ 'indianred'=>'#cd5c5c', 'ivory'=>'#fffff0', 'lavender'=>'#e6e6fa', 'lawngreen'=>'#7cfc00', 'lightblue'=>'#add8e6', 'lightcyan'=>'#e0ffff',
917
+ 'lightgray'=>'#d3d3d3', 'lightgrey'=>'#d3d3d3', 'lightpink'=>'#ffb6c1', 'lightseagreen'=>'#20b2aa', 'lightslategrey'=>'#778899',
918
+ 'lightsteelblue'=>'#b0c4de', 'linen'=>'#faf0e6', 'mediumblue'=>'#0000cd', 'mediumpurple'=>'#9370db', 'mediumslateblue'=>'#7b68ee',
919
+ 'mediumturquoise'=>'#48d1cc', 'mistyrose'=>'#ffe4e1', 'navajowhite'=>'#ffdead', 'oldlace'=>'#fdf5e6', 'olivedrab'=>'#6b8e23', 'orangered'=>'#ff4500',
920
+ 'palegoldenrod'=>'#eee8aa', 'paleturquoise'=>'#afeeee', 'papayawhip'=>'#ffefd5', 'peru'=>'#cd853f', 'plum'=>'#dda0dd', 'rosybrown'=>'#bc8f8f',
921
+ 'saddlebrown'=>'#8b4513', 'sandybrown'=>'#f4a460', 'seashell'=>'#fff5ee', 'slateblue'=>'#6a5acd', 'slategrey'=>'#708090', 'snow'=>'#fffafa',
922
  'tomato'=>'#ff6347', 'violet'=>'#ee82ee', 'wheat'=>'#f5deb3', 'whitesmoke'=>'#f5f5f5', 'yellowgreen'=>'#9acd32');
923
 
924
  $this->ColorFlag=false;
938
  $this->SHYdictionaryWords = array();
939
  $this->blockContext = 1;
940
  $this->floatDivs = array();
941
+ $this->DisplayPreferences='';
942
 
943
  $this->tablecascadeCSS = array();
944
  $this->listcascadeCSS = array();
978
  $this->forceExactLineheight = false;
979
  $this->listOcc = 0;
980
  $this->normalLineheight = 1.3;
981
+ // These are intended as configuration variables, and should be set in config.php - which will override these values;
982
  // set here as failsafe as will cause an error if not defined
983
  $this->incrementFPR1 = 10;
984
  $this->incrementFPR2 = 10;
1030
  $this->uniqid = '';
1031
 
1032
  $this->cascadeCSS = array();
1033
+ $this->bufferoutput = false;
1034
  $this->encrypted=false; //whether document is protected
1035
  $this->BMoutlines=array();
1036
  $this->ColActive=0; //Flag indicating that columns are on (the index is being processed)
1126
  //Compression
1127
  $this->SetCompression(true);
1128
  //Set default display preferences
1129
+ $this->SetDisplayPreferences('');
1130
 
1131
  // Font data
1132
  require(_MPDF_PATH.'config_fonts.php');
1154
  else if ($mode=='c') { $onlyCoreFonts = true; $mode = ''; }
1155
  }
1156
  else if (substr($mode,-2)=='-s') {
1157
+ $this->percentSubset = 100;
1158
  $mode = substr($mode,0,strlen($mode)-2);
1159
  }
1160
  else if (substr($mode,-2)=='-c') {
1170
  if ((strlen($mode) == 5 && $mode != 'UTF-8') || strlen($mode) == 2) {
1171
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($mode, $this->useAdobeCJK);
1172
  if ($coreSuitable && $optcore) { $onlyCoreFonts = true; }
1173
+ if ($mpdf_pdf_unifonts) {
1174
+ $this->RestrictUnicodeFonts($mpdf_pdf_unifonts);
1175
  $this->default_available_fonts = $mpdf_pdf_unifonts;
1176
  }
1177
  $this->currentLang = $mode;
1213
  if (file_exists(_MPDF_PATH.'mpdf.css')) {
1214
  $css = file_get_contents(_MPDF_PATH.'mpdf.css');
1215
  $css2 = $this->ReadDefaultCSS($css);
1216
+ $this->defaultCSS = $this->array_merge_recursive_unique($this->defaultCSS,$css2);
1217
  }
1218
 
1219
+ if ($default_font=='') {
1220
+ if ($this->onlyCoreFonts) {
1221
  if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->mono_fonts)) { $default_font = 'ccourier'; }
1222
  else if (in_array(strtolower($this->defaultCSS['BODY']['FONT-FAMILY']),$this->sans_fonts)) { $default_font = 'chelvetica'; }
1223
  else { $default_font = 'ctimes'; }
1224
  }
1225
  else { $default_font = $this->defaultCSS['BODY']['FONT-FAMILY']; }
1226
  }
1227
+ if (!$default_font_size) {
1228
  $mmsize = $this->ConvertSize($this->defaultCSS['BODY']['FONT-SIZE']);
1229
  $default_font_size = $mmsize*(_MPDFK);
1230
  }
1243
  $this->I=0;
1244
 
1245
  $this->listlvl=0;
1246
+ $this->listnum=0;
1247
  $this->listtype='';
1248
  $this->listoccur=array();
1249
  $this->listlist=array();
1250
  $this->listitem=array();
1251
 
1252
+ $this->tdbegin=false;
1253
+ $this->table=array();
1254
+ $this->cell=array();
1255
+ $this->col=-1;
1256
+ $this->row=-1;
1257
  $this->cellBorderBuffer = array();
1258
 
1259
  $this->divbegin=false;
1260
  $this->divalign='';
1261
+ $this->divwidth=0;
1262
+ $this->divheight=0;
1263
  $this->spanbgcolor=false;
1264
  $this->divrevert=false;
1265
  $this->spanborder=false;
1307
  if ($format=='') { $format = 'A4'; }
1308
  $pfo = 'P';
1309
  if(preg_match('/([0-9a-zA-Z]*)-L/i',$format,$m)) { // e.g. A4-L = A4 landscape
1310
+ $format=$m[1];
1311
+ $pfo='L';
1312
  }
1313
  $format = $this->_getPageFormat($format);
1314
  if (!$format) { $this->Error('Unknown page format: '.$format); }
1403
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1404
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1405
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
 
1406
  }
1407
  return $format;
1408
  }
1423
 
1424
 
1425
  function setMBencoding($enc) {
1426
+ if ($this->mb_enc != $enc) {
1427
+ $this->mb_enc = $enc;
1428
+ mb_internal_encoding($this->mb_enc);
1429
  }
1430
  }
1431
 
1556
  // HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity
1557
  // set alpha for stroking (CA) and non-stroking (ca) operations
1558
  // mode determines F (fill) S (stroke) B (both)
1559
+ if (($this->PDFA || $this->PDFX) && $alpha!=1) {
1560
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Image opacity must be 100% (Opacity changed to 100%)"; }
1561
+ $alpha = 1;
1562
  }
1563
  $a = array('BM'=>'/'.$bm);
1564
  if ($mode=='F' || $mode='B') $a['ca'] = $alpha;
1700
  }
1701
 
1702
  if($pb['visibility']!='visible') {
1703
+ if($pb['visibility']=='printonly')
1704
  $s .= '/OC /OC1 BDC'."\n";
1705
  else if($pb['visibility']=='screenonly')
1706
  $s .= '/OC /OC2 BDC'."\n";
1712
  if (isset($pb['clippath']) && $pb['clippath']) { $s .= $pb['clippath']."\n"; }
1713
  $s .= 'q '.$this->SetFColor($pb['col'], true)."\n";
1714
  if ($pb['col']{0}==5) { // RGBa
1715
+ $s .= $this->SetAlpha(ord($pb['col']{4})/100, 'Normal', true, 'F')."\n";
1716
  }
1717
  else if ($pb['col']{0}==6) { // CMYKa
1718
  $s .= $this->SetAlpha(ord($pb['col']{5})/100, 'Normal', true, 'F')."\n";
1742
  function BeginLayer($id) {
1743
  if($this->current_layer>0) $this->EndLayer();
1744
  if ($id < 1) { return false; }
1745
+ if (!isset($this->layers[$id])) {
1746
  $this->layers[$id] = array('name'=>'Layer '.($id) );
1747
  if (($this->PDFA || $this->PDFX)) { $this->PDFAXwarnings[] = "Cannot use layers when using PDFA or PDFX"; return ''; }
1748
  else if (!$this->PDFA && !$this->PDFX) { $this->pdf_version='1.5'; }
1765
  // Depracated - can use AddPage for all
1766
  function AddPages($orientation='',$condition='', $resetpagenum='', $pagenumstyle='', $suppress='',$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='',$ohname='',$ehname='',$ofname='',$efname='',$ohvalue=0,$ehvalue=0,$ofvalue=0,$efvalue=0,$pagesel='',$newformat='')
1767
  {
1768
+ $this->AddPage($orientation,$condition,$resetpagenum, $pagenumstyle, $suppress,$mgl,$mgr,$mgt,$mgb,$mgh,$mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue,$pagesel,$newformat);
1769
  }
1770
 
1771
 
1807
  if($this->state==0) $this->Open();
1808
 
1809
  $bak_cml = $this->cMarginL;
1810
+ $bak_cmr = $this->cMarginR;
1811
  $bak_dw = $this->divwidth;
1812
 
1813
 
1819
 
1820
  if ($condition == 'NEXT-EVEN') { // always adds at least one new page to create an Even page
1821
  if (!$this->mirrorMargins) { $condition = ''; }
1822
+ else {
1823
+ $this->AddPage($this->CurOrientation,'O');
1824
+ $condition = '';
1825
  }
1826
  }
1827
  if ($condition == 'NEXT-ODD') { // always adds at least one new page to create an Odd page
1828
  if (!$this->mirrorMargins) { $condition = ''; }
1829
+ else {
1830
+ $this->AddPage($this->CurOrientation,'E');
1831
+ $condition = '';
1832
  }
1833
  }
1834
 
1861
  // Paint Div Border if necessary
1862
  //PAINTS BACKGROUND COLOUR OR BORDERS for DIV - DISABLED FOR COLUMNS (cf. AcceptPageBreak) AT PRESENT in ->PaintDivBB
1863
  if (!$this->ColActive && $this->blklvl > 0) {
1864
+ if (isset($this->blk[$this->blklvl]['y0']) && $this->y == $this->blk[$this->blklvl]['y0']) {
1865
  if (isset($this->blk[$this->blklvl]['startpage'])) { $this->blk[$this->blklvl]['startpage']++; }
1866
  else { $this->blk[$this->blklvl]['startpage'] = 1; }
1867
  }
1933
  if ($this->docTemplate) {
1934
  $pagecount = $this->SetSourceFile($this->docTemplate);
1935
  if (($this->page - $this->docTemplateStart) > $pagecount) {
1936
+ if ($this->docTemplateContinue) {
1937
  $tplIdx = $this->ImportPage($pagecount);
1938
  $this->UseTemplate($tplIdx);
1939
  }
2010
  if (isset($this->blk[$bl]['x0'])) { $this->blk[$bl]['x0'] += $this->MarginCorrection; }
2011
  else { $this->blk[$bl]['x0'] = $this->MarginCorrection; }
2012
  // Added mPDF 3.0 Float DIV
2013
+ $this->blk[$bl]['marginCorrected'][$this->page] = true;
2014
  }
2015
  }
2016
 
2070
  }
2071
  if ($type=='Draw') { $out = strtoupper($out); } // e.g. rg => RG
2072
  else if ($type=='CodeOnly') { $out = preg_replace('/\s(rg|g|k)/','',$out); }
2073
+ return $out;
2074
  }
2075
 
2076
 
2099
  if ($out=='') { return ''; }
2100
  $this->TextColor = $out;
2101
  $this->ColorFlag = ($this->FillColor != $out);
2102
+ }
2103
 
2104
 
2105
  function SetDrawColor($r,$g=-1,$b=-1,$col4=-1, $return=false) {
2153
  $c = (string)$c;
2154
  $w = 0;
2155
  // Soft Hyphens chr(173)
2156
+ if ($c == chr(173) && $this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
2157
  return 0;
2158
  }
2159
+ else if ($this->S && isset($this->upperCase[ord($c)])) {
2160
  $charw = $this->CurrentFont['cw'][chr($this->upperCase[ord($c)])];
2161
+ if ($charw!==false) {
2162
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2163
+ $w+=$charw;
2164
  }
2165
  }
2166
+ else if (isset($this->CurrentFont['cw'][$c])) {
2167
+ $w += $this->CurrentFont['cw'][$c];
2168
+ }
2169
+ else if (isset($this->CurrentFont['cw'][ord($c)])) {
2170
+ $w += $this->CurrentFont['cw'][ord($c)];
2171
  }
2172
  $w *= ($this->FontSize/ 1000);
2173
  if ($this->minwSpacing || $this->fixedlSpacing) {
2187
  if ($char == 173) { return 0; } // Soft Hyphens
2188
  else if ($this->S && isset($this->upperCase[$char])) {
2189
  $charw = $this->_getCharWidth($this->CurrentFont['cw'],$this->upperCase[$char]);
2190
+ if ($charw!==false) {
2191
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2192
+ $w+=$charw;
2193
  }
2194
  elseif(isset($this->CurrentFont['desc']['MissingWidth'])) { $w += $this->CurrentFont['desc']['MissingWidth']; }
2195
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
2215
  function GetCharWidth($c, $addSubset=true) {
2216
  if (!$this->usingCoreFont) {
2217
  return $this->GetCharWidthNonCore($c, $addSubset);
2218
+ }
2219
  else {
2220
  return $this->GetCharWidthCore($c);
2221
  }
2234
  if ($this->iterationCounter) $s = preg_replace('/{iteration ([a-zA-Z0-9_]+)}/', '\\1', $s);
2235
 
2236
  if (!$this->usingCoreFont) {
2237
+ $s = str_replace("\xc2\xad",'',$s );
2238
  $unicode = $this->UTF8StringToArray($s, $addSubset);
2239
  if ($this->minwSpacing || $this->fixedlSpacing) {
2240
+ $nb_carac = count($unicode);
2241
+ $nb_spaces = mb_substr_count($s,' ', $this->mb_enc);
2242
  }
2243
  foreach($unicode as $char) {
2244
  if ($this->S && isset($this->upperCase[$char])) {
2245
  $charw = $this->_getCharWidth($cw,$this->upperCase[$char]);
2246
+ if ($charw!==false) {
2247
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2248
+ $w+=$charw;
2249
  }
2250
  elseif(isset($this->CurrentFont['desc']['MissingWidth'])) { $w += $this->CurrentFont['desc']['MissingWidth']; }
2251
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
2258
  elseif(isset($this->CurrentFont['MissingWidth'])) { $w += $this->CurrentFont['MissingWidth']; }
2259
  else { $w += 500; }
2260
  if ($this->kerning && $this->useKerning && $lastchar) {
2261
+ if (isset($this->CurrentFont['kerninfo'][$lastchar][$char])) {
2262
+ $kerning += $this->CurrentFont['kerninfo'][$lastchar][$char];
2263
  }
2264
  }
2265
  $lastchar = $char;
2266
  }
2267
  }
2268
 
2269
+ }
2270
  else {
2271
+ if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
2272
+ $s = str_replace(chr(173),'',$s );
2273
  }
2274
  $nb_carac = $l = strlen($s);
2275
  if ($this->minwSpacing || $this->fixedlSpacing) {
2276
+ $nb_spaces = substr_count($s,' ');
2277
  }
2278
  for($i=0; $i<$l; $i++) {
2279
+ if ($this->S && isset($this->upperCase[ord($s[$i])])) {
2280
  $charw = $cw[chr($this->upperCase[ord($s[$i])])];
2281
+ if ($charw!==false) {
2282
  $charw = $charw*$this->smCapsScale * $this->smCapsStretch/100;
2283
+ $w+=$charw;
2284
  }
2285
  }
2286
+ else if (isset($cw[$s[$i]])) {
2287
+ $w += $cw[$s[$i]];
2288
+ }
2289
+ else if (isset($cw[ord($s[$i])])) {
2290
+ $w += $cw[ord($s[$i])];
2291
  }
2292
  if ($this->kerning && $this->useKerning && $i>0) {
2293
+ if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$s[$i]])) {
2294
+ $kerning += $this->CurrentFont['kerninfo'][$s[($i-1)]][$s[$i]];
2295
  }
2296
  }
2297
  }
2308
  $this->LineWidth=$width;
2309
  $lwout = (sprintf('%.3F w',$width*_MPDFK));
2310
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['LineWidth']) && $this->pageoutput[$this->page]['LineWidth'] != $lwout) || !isset($this->pageoutput[$this->page]['LineWidth']) || $this->keep_block_together)) {
2311
+ $this->_out($lwout);
2312
  }
2313
  $this->pageoutput[$this->page]['LineWidth'] = $lwout;
2314
  }
2319
  }
2320
 
2321
  function Arrow($x1,$y1,$x2,$y2,$headsize=3,$fill='B',$angle=25) {
2322
+ //F == fill //S == stroke //B == stroke and fill
2323
  // angle = splay of arrowhead - 1 - 89 degrees
2324
  if($fill=='F') $fill='f';
2325
  elseif($fill=='FD' or $fill=='DF' or $fill=='B') $fill='B';
2392
  }
2393
  if (!$ttffile) {
2394
  $ttffile = _MPDF_TTFONTPATH.$this->fontdata[$family][$stylekey];
2395
+ if (!file_exists($ttffile)) {
2396
  /*
2397
  * Try load in the font file from the PDF_TEMPLATE
2398
  */
2399
  global $gfpdfe_data;
2400
+ $ttffile = $gfpdfe_data->template_site_location . 'fonts/' . $this->fontdata[$family][$stylekey];
2401
  if(!file_exists($ttffile))
2402
  {
2403
+ die("mPDF Error - cannot find TTF TrueType font file - ".$ttffile);
2404
  }
2405
  }
2406
  }
2417
  else if (!$BMPonly && $BMPselected) { $regenerate = true; }
2418
  if ($this->useKerning && !$haskerninfo) { $regenerate = true; }
2419
  // mPDF 5.4.05
2420
+ if (isset($this->fontdata[$family]['unAGlyphs']) && $this->fontdata[$family]['unAGlyphs'] && !$unAGlyphs) {
2421
+ $regenerate = true;
2422
  $unAGlyphs = true;
2423
  }
2424
+ else if ((!isset($this->fontdata[$family]['unAGlyphs']) || !$this->fontdata[$family]['unAGlyphs']) && $unAGlyphs) {
2425
+ $regenerate = true;
2426
  $unAGlyphs = false;
2427
  }
2428
  if (!isset($name) || $originalsize != $ttfstat['size'] || $regenerate) {
2473
  else $s.='$BMPselected=false;'."\n";
2474
  $s.='$fontkey=\''.$fontkey."';\n";
2475
  $s.='$panose=\''.$panose."';\n";
2476
+ if ($this->useKerning) {
2477
+ $s.='$kerninfo='.var_export($kerninfo,true).";\n";
2478
  $s.='$haskerninfo=true;'."\n";
2479
  }
2480
  else $s.='$haskerninfo=false;'."\n";
2481
  // mPDF 5.4.05
2482
+ if ($this->fontdata[$family]['unAGlyphs']) {
2483
  $s.='$unAGlyphs=true;'."\n";
2484
  }
2485
  else $s.='$unAGlyphs=false;'."\n";
2500
  unset($ttf);
2501
  }
2502
  else {
2503
+ $cw = @file_get_contents(_MPDF_TTFONTDATAPATH.$fontkey.'.cw.dat');
2504
  }
2505
 
2506
  if (isset($this->fontdata[$family]['indic']) && $this->fontdata[$family]['indic']) { $indic = true; }
2533
  if ($family == 'mono' || $family == 'monospace') { $family = $this->mono_fonts[0]; }
2534
  }
2535
  if (isset($this->fonttrans[$family]) && $this->fonttrans[$family]) { $family = $this->fonttrans[$family]; }
2536
+ if($family=='') {
2537
  if ($this->FontFamily) { $family=$this->FontFamily; }
2538
  else if ($this->default_font) { $family=$this->default_font; }
2539
  else { $this->Error("No font or default font set!"); }
2540
  }
2541
  $this->ReqFontStyle = $style; // required or requested style - used later for artificial bold/italic
2542
 
2543
+ if (($family == 'csymbol') || ($family == 'czapfdingbats') || ($family == 'ctimes') || ($family == 'ccourier') || ($family == 'chelvetica')) {
2544
  if ($this->PDFA || $this->PDFX) {
2545
+ if ($family == 'csymbol' || $family == 'czapfdingbats') {
2546
  $this->Error("Symbol and Zapfdingbats cannot be embedded in mPDF (required for PDFA1-b or PDFX/1-a).");
2547
  }
2548
+ if ($family == 'ctimes' || $family == 'ccourier' || $family == 'chelvetica') {
2549
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Core Adobe font ".ucfirst($family)." cannot be embedded in mPDF, which is required for PDFA1-b or PDFX/1-a. (Embedded font will be substituted.)"; }
2550
  if ($family == 'chelvetica') { $family = 'sans'; }
2551
  if ($family == 'ctimes') { $family = 'serif'; }
2569
  if(strpos($style,'S')!==false) {
2570
  $this->S=true;
2571
  // Small Caps
2572
+ if (empty($this->upperCase)) { @include(_MPDF_PATH.'includes/upperCase.php'); }
2573
  $style=str_replace('S','',$style);
2574
  }
2575
  if ($style=='IB') $style='BI';
2598
  else {
2599
  $found = 0;
2600
  // else substitute font of similar type
2601
+ if (in_array($family,$this->sans_fonts)) {
2602
  $i = array_intersect($this->sans_fonts,$this->available_unifonts);
2603
  if (count($i)) {
2604
  $i = array_values($i);
2606
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2607
  $style = '';
2608
  }
2609
+ $family = $i[0];
2610
  $found = 1;
2611
  }
2612
  }
2613
+ else if (in_array($family,$this->serif_fonts)) {
2614
  $i = array_intersect($this->serif_fonts,$this->available_unifonts);
2615
  if (count($i)) {
2616
  $i = array_values($i);
2618
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2619
  $style = '';
2620
  }
2621
+ $family = $i[0];
2622
  $found = 1;
2623
  }
2624
  }
2630
  if (!in_array(($i[0].$style),$this->available_unifonts)) {
2631
  $style = '';
2632
  }
2633
+ $family = $i[0];
2634
  $found = 1;
2635
  }
2636
  }
2650
  $style = '';
2651
  }
2652
  else {
2653
+ // or with the style specified
2654
  $family = $fas[1];
2655
  $style = $fas[2];
2656
  }
2657
  }
2658
  }
2659
+ $fontkey = $family.$style;
2660
  }
2661
  }
2662
  // try to add font (if not already added)
2667
  return $family;
2668
  }
2669
 
2670
+ $fontkey = $family.$style;
2671
 
2672
  //Select it
2673
  $this->FontFamily = $family;
2675
  $this->FontSizePt = $size;
2676
  $this->FontSize = $size / _MPDFK;
2677
  $this->CurrentFont = &$this->fonts[$fontkey];
2678
+ if ($write) {
2679
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2680
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
2681
  $this->pageoutput[$this->page]['Font'] = $fontout;
2708
  else if (in_array($family,$this->mono_fonts)) { $family = 'ccourier'; }
2709
  else { $family = 'chelvetica'; }
2710
  $this->usingCoreFont = true;
2711
+ $fontkey = $family.$style;
2712
  }
2713
 
2714
  if(!isset($this->fonts[$fontkey])) {
2738
  $this->FontSizePt=$size;
2739
  $this->FontSize=$size/_MPDFK;
2740
  $this->CurrentFont=&$this->fonts[$fontkey];
2741
+ if ($write) {
2742
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2743
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
2744
  $this->pageoutput[$this->page]['Font'] = $fontout;
2759
  $this->FontSizePt=$size;
2760
  $this->FontSize=$size/_MPDFK;
2761
  $this->currentfontsize=$size;
2762
+ if ($write) {
2763
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
2764
  // Edited mPDF 3.0
2765
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
2820
  if($this->FillColor!=$tc) { $s .= $tc.' '; } // stroke (outline) = same colour as text(fill)
2821
  }
2822
  if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) {
2823
+ $aix = '1 0 0.261799 1 %.3F %.3F Tm';
2824
  }
2825
  else { $aix = '%.3F %.3F Td'; }
2826
 
2833
  $s.=sprintf('BT '.$aix.' %s Tj ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$txt2);
2834
  }
2835
  else if (!$this->usingCoreFont) {
2836
+ $txt2 = str_replace(chr(194).chr(160),chr(32),$txt);
2837
  $this->UTF8StringToArray($txt2); // this is just to add chars to subset list
2838
  if ($this->kerning && $this->useKerning) { $s .= $this->_kern($txt2, '', $aix, $x, $y); }
2839
  else {
2906
 
2907
  // WORD SPACING
2908
  function GetJspacing($nc,$ns,$w,$inclCursive) {
2909
+ $ws = 0;
2910
  $charspacing = 0;
2911
  $ww = $this->jSWord;
2912
  $ncx = $nc-1;
2914
  else if ($nc==1) { $charspacing = $w; }
2915
  // Only word spacing allowed / possible
2916
  else if ($this->fixedlSpacing !== false || $inclCursive) {
2917
+ if ($ns) { $ws = $w / $ns; }
2918
  }
2919
  else if (!$ns) {
2920
  $charspacing = $w / ($ncx );
2921
+ if (($this->jSmaxChar > 0) && ($charspacing > $this->jSmaxChar)) {
2922
  $charspacing = $this->jSmaxChar;
2923
  }
2924
  }
2932
  $cs = $this->jSmaxChar;
2933
  $ww = 1 - (($cs * ($ncx ))/$w);
2934
  }
2935
+ $charspacing = $cs;
2936
  $ws = ($w * ($ww) ) / $ns;
2937
  }
2938
  else {
2941
  $cs = $this->jSmaxChar;
2942
  $ww = 1 - (($cs * ($ncx -$ns))/$w);
2943
  }
2944
+ $charspacing = $cs;
2945
  $ws = (($w * ($ww) ) / $ns) - $charspacing;
2946
  }
2947
  }
2948
+ return array($charspacing,$ws);
2949
  }
2950
 
2951
  function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='', $currentx=0, $lcpaddingL=0, $lcpaddingR=0, $valign='M', $spanfill=0, $abovefont=0, $belowfont=0, $exactWidth=false) {
2963
  // Automatic page break
2964
  // Allows PAGE-BREAK-AFTER = avoid to work
2965
 
2966
+ if (!$this->tableLevel && (($this->y+$this->divheight>$this->PageBreakTrigger) || ($this->y+$h>$this->PageBreakTrigger) ||
2967
  ($this->y+($h*2)>$this->PageBreakTrigger && $this->blk[$this->blklvl]['page_break_after_avoid'])) and !$this->InFooter and $this->AcceptPageBreak()) {
2968
  $x=$this->x;//Current X position
2969
 
2976
  $this->AddPage($this->CurOrientation);
2977
  // Added to correct for OddEven Margins
2978
  $x += $this->MarginCorrection;
2979
+ if ($currentx) {
2980
  $currentx += $this->MarginCorrection;
2981
+ }
2982
  $this->x=$x;
2983
  // WORD SPACING
2984
  $this->SetSpacing($charspacing,$ws);
2995
 
2996
  if($w==0) $w = $this->w-$this->rMargin-$this->x;
2997
  $s='';
2998
+ if($fill==1 && $this->FillColor) {
2999
  if((isset($this->pageoutput[$this->page]['FillColor']) && $this->pageoutput[$this->page]['FillColor'] != $this->FillColor) || !isset($this->pageoutput[$this->page]['FillColor']) || $this->keep_block_together) { $s .= $this->FillColor.' '; }
3000
  $this->pageoutput[$this->page]['FillColor'] = $this->FillColor;
3001
  }
3020
  if ($abovefont || $belowfont) { // from flowing block - valign always M
3021
  $va = $abovefont + (0.5*$bfs);
3022
  }
3023
+ else if ($this->lineheight_correction) {
3024
  if ($valign == 'T') { $va = (0.5 * $bfs * $this->lineheight_correction); }
3025
  else if ($valign == 'B') { $va = $h-(0.5 * $bfs * $this->lineheight_correction); }
3026
  else { $va = 0.5*$h; } // Middle
3027
  }
3028
+ else {
3029
  if ($valign == 'T') { $va = (0.5 * $bfs * $this->default_lineheight_correction); }
3030
  else if ($valign == 'B') { $va = $h-(0.5 * $bfs * $this->default_lineheight_correction); }
3031
  else { $va = 0.5*$h; } // Middle
3042
  }
3043
 
3044
  $bbw = $tbw = $lbw = $rbw = 0; // Border widths
3045
+ if (!empty($this->spanborddet)) {
3046
  if (!isset($this->spanborddet['B'])) { $this->spanborddet['B'] = array('s' => 0, 'style' => '', 'w' => 0); }
3047
  if (!isset($this->spanborddet['T'])) { $this->spanborddet['T'] = array('s' => 0, 'style' => '', 'w' => 0); }
3048
  if (!isset($this->spanborddet['L'])) { $this->spanborddet['L'] = array('s' => 0, 'style' => '', 'w' => 0); }
3053
  $rbw = $this->spanborddet['R']['w'];
3054
  }
3055
  if($fill==1 || $border==1 || !empty($this->spanborddet)) {
3056
+ if (!empty($this->spanborddet)) {
3057
  if ($fill==1) {
3058
  $s.=sprintf('%.3F %.3F %.3F %.3F re f ',($this->x-$lbw)*_MPDFK,($this->h-$boxtop+$tbw)*_MPDFK,($w+$lbw+$rbw)*_MPDFK,(-$boxheight-$tbw-$bbw)*_MPDFK);
3059
  }
3076
  $c = $this->SetDColor($this->spanborddet['T']['c'],true);
3077
  if ($this->spanborddet['T']['style'] == 'double') {
3078
  $s.=sprintf(' %s %.3F w ',$c,$tbw/3*_MPDFK);
3079
+ $xadj = $xadj2 = 0;
3080
  if ($this->spanborddet['L']['style'] == 'double') { $xadj = $this->spanborddet['L']['w']*2/3; }
3081
  if ($this->spanborddet['R']['style'] == 'double') { $xadj2 = $this->spanborddet['R']['w']*2/3; }
3082
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw)*_MPDFK,($this->h-$boxtop+$tbw*5/6)*_MPDFK,($this->x+$w+$rbw-$short)*_MPDFK,($this->h-$boxtop+$tbw*5/6)*_MPDFK);
3102
  $c = $this->SetDColor($this->spanborddet['B']['c'],true);
3103
  if ($this->spanborddet['B']['style'] == 'double') {
3104
  $s.=sprintf(' %s %.3F w ',$c,$bbw/3*_MPDFK);
3105
+ $xadj = $xadj2 = 0;
3106
  if ($this->spanborddet['L']['style'] == 'double') { $xadj = $this->spanborddet['L']['w']*2/3; }
3107
  if ($this->spanborddet['R']['style'] == 'double') { $xadj2 = $this->spanborddet['R']['w']*2/3; }
3108
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw+$xadj)*_MPDFK,($this->h-$boxbottom-$bbw/6)*_MPDFK,($this->x+$w+$rbw-$short-$xadj2)*_MPDFK,($this->h-$boxbottom-$bbw/6)*_MPDFK);
3128
  $c = $this->SetDColor($this->spanborddet['L']['c'],true);
3129
  if ($this->spanborddet['L']['style'] == 'double') {
3130
  $s.=sprintf(' %s %.3F w ',$c,$lbw/3*_MPDFK);
3131
+ $yadj = $yadj2 = 0;
3132
  if ($this->spanborddet['T']['style'] == 'double') { $yadj = $this->spanborddet['T']['w']*2/3; }
3133
  if ($this->spanborddet['B']['style'] == 'double') { $yadj2 = $this->spanborddet['B']['w']*2/3; }
3134
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x-$lbw/6)*_MPDFK,($this->h-$boxtop+$tbw-$yadj)*_MPDFK,($this->x-$lbw/6)*_MPDFK,($this->h-$boxbottom-$bbw+$short+$yadj2)*_MPDFK);
3154
  $c = $this->SetDColor($this->spanborddet['R']['c'],true);
3155
  if ($this->spanborddet['R']['style'] == 'double') {
3156
  $s.=sprintf(' %s %.3F w ',$c,$rbw/3*_MPDFK);
3157
+ $yadj = $yadj2 = 0;
3158
  if ($this->spanborddet['T']['style'] == 'double') { $yadj = $this->spanborddet['T']['w']*2/3; }
3159
  if ($this->spanborddet['B']['style'] == 'double') { $yadj2 = $this->spanborddet['B']['w']*2/3; }
3160
  $s.=sprintf('%.3F %.3F m %.3F %.3F l S ',($this->x+$w+$rbw/6)*_MPDFK,($this->h-$boxtop+$tbw-$yadj)*_MPDFK,($this->x+$w+$rbw/6)*_MPDFK,($this->h-$boxbottom-$bbw+$short+$yadj2)*_MPDFK);
3189
 
3190
  if($txt!='') {
3191
  if ($exactWidth)
3192
+ $stringWidth = $w;
3193
+ else
3194
  $stringWidth = $this->GetStringWidth($txt) + ( $this->charspacing * mb_strlen( $txt, $this->mb_enc ) / _MPDFK )
3195
  + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ) / _MPDFK );
3196
 
3220
  }
3221
 
3222
  if (strpos($this->ReqFontStyle,"I") !== false && strpos($this->FontStyle,"I") === false) { // Artificial italic
3223
+ $aix = '1 0 0.261799 1 %.3F %.3F Tm ';
3224
  }
3225
  else { $aix = '%.3F %.3F Td '; }
3226
 
3231
  // WORD SPACING
3232
  // IF multibyte - Tw has no effect - need to use alternative method - do word spacing using an adjustment before each space
3233
  if ($this->ws && !$this->usingCoreFont && !$this->CurrentFont['sip'] && !$this->CurrentFont['smp'] && !$this->S) {
3234
+ $sub .= ' BT 0 Tw ET ';
3235
  if ($this->kerning && $this->useKerning) { $sub .= $this->_kern($txt, 'MBTw', $aix, ($this->x+$dx), ($this->y+$baseline+$va)); }
3236
  else {
3237
  $space = " ";
3238
  //Convert string to UTF-16BE without BOM
3239
  $space= $this->UTF8ToUTF16BE($space , false);
3240
+ $space=$this->_escape($space );
3241
  $sub .=sprintf('BT '.$aix,($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK);
3242
  $t = explode(' ',$txt);
3243
  $sub .=sprintf(' %.3F Tc [',$this->charspacing);
3244
  $numt = count($t);
3245
  for($i=0;$i<$numt;$i++) {
3246
+ $tx = $t[$i];
3247
  //Convert string to UTF-16BE without BOM
3248
  $tx = $this->UTF8ToUTF16BE($tx , false);
3249
+ $tx = $this->_escape($tx);
3250
  $sub .=sprintf('(%s) ',$tx);
3251
  if (($i+1)<$numt) {
3252
  $adj = -($this->ws)*1000/$this->FontSizePt;
3260
  else {
3261
  $txt2= $txt;
3262
  if ($this->CurrentFont['type']=='TTF' && ($this->CurrentFont['sip'] || $this->CurrentFont['smp'])) {
3263
+ if ($this->S) { $sub .= $this->_smallCaps($txt2, 'SIPSMP', $aix, $dx, _MPDFK, $baseline, $va); }
3264
  else {
3265
  $txt2 = $this->UTF8toSubset($txt2);
3266
  $sub .=sprintf('BT '.$aix.' %s Tj ET',($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK,$txt2);
3267
  }
3268
  }
3269
  else {
3270
+ if ($this->S) { $sub .= $this->_smallCaps($txt2, '', $aix, $dx, _MPDFK, $baseline, $va); }
3271
+ else if ($this->kerning && $this->useKerning) { $sub .= $this->_kern($txt2, '', $aix, ($this->x+$dx), ($this->y+$baseline+$va)); }
3272
  else {
3273
  if (!$this->usingCoreFont) {
3274
  $txt2 = $this->UTF8ToUTF16BE($txt2, false);
3275
  }
3276
+ $txt2=$this->_escape($txt2);
3277
  $sub .=sprintf('BT '.$aix.' (%s) Tj ET',($this->x+$dx)*_MPDFK,($this->h-($this->y+$baseline+$va))*_MPDFK,$txt2);
3278
  }
3279
  }
3317
  $s .= ' q ';
3318
  $s .= $this->SetTColor($ts['col'], true)."\n";
3319
  if ($ts['col']{0}==5 && ord($ts['col']{4})<100) { // RGBa
3320
+ $s .= $this->SetAlpha(ord($ts['col']{4})/100, 'Normal', true, 'F')."\n";
3321
  }
3322
  else if ($ts['col']{0}==6 && ord($ts['col']{5})<100) { // CMYKa
3323
+ $s .= $this->SetAlpha(ord($ts['col']{5})/100, 'Normal', true, 'F')."\n";
3324
  }
3325
  else if ($ts['col']{0}==1 && $ts['col']{2}==1 && ord($ts['col']{3})<100) { // Gray
3326
+ $s .= $this->SetAlpha(ord($ts['col']{3})/100, 'Normal', true, 'F')."\n";
3327
  }
3328
  $s .= sprintf(' 1 0 0 1 %.4F %.4F cm', $ts['x']*_MPDFK, -$ts['y']*_MPDFK)."\n";
3329
  $s .= $sub;
3345
 
3346
  // WORD SPACING
3347
  if ($this->ws && !$this->usingCoreFont) {
3348
+ $this->_out(sprintf('BT %.3F Tc ET',$this->charspacing));
3349
  }
3350
  $this->lasth=$h;
3351
  if( strpos($txt,"\n") !== false) $ln=1; // cell recognizes \n from <BR> tag
3370
  $space = ' ';
3371
  //Convert string to UTF-16BE without BOM
3372
  $space= $this->UTF8ToUTF16BE($space , false);
3373
+ $space=$this->_escape($space );
3374
  $s = sprintf(' BT '.$aix,$x*_MPDFK,($this->h-$y)*_MPDFK);
3375
  $t = explode(' ',$txt);
3376
  for($i=0;$i<count($t);$i++) {
3377
+ $tx = $t[$i];
3378
 
3379
  $tj = '(';
3380
  $unicode = $this->UTF8StringToArray($tx);
3385
  }
3386
  $tc = code2utf($unicode[$ti]);
3387
  $tc = $this->UTF8ToUTF16BE($tc, false);
3388
+ $tj .= $this->_escape($tc);
3389
  }
3390
  $tj .= ')';
3391
  $s.=sprintf(' %.3F Tc [%s] TJ',$this->charspacing,$tj);
3408
  }
3409
  $tx = code2utf($unicode[$i]);
3410
  $tx = $this->UTF8ToUTF16BE($tx, false);
3411
+ $tj .= $this->_escape($tx);
3412
  }
3413
  $tj .= ')';
3414
  $s.=sprintf(' BT '.$aix.' [%s] TJ ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$tj);
3422
  $kern = -$this->CurrentFont['kerninfo'][$txt[($i-1)]][$txt[$i]];
3423
  $tj .= sprintf(')%d(',$kern);
3424
  }
3425
+ $tj .= $this->_escape($txt[$i]);
3426
  }
3427
  $tj .= ')';
3428
  $s.=sprintf(' BT '.$aix.' [%s] TJ ET ',$x*_MPDFK,($this->h-$y)*_MPDFK,$tj);
3436
  $upp = false;
3437
  $str = array();
3438
  $bits = array();
3439
+ if (!$this->usingCoreFont) {
3440
  $unicode = $this->UTF8StringToArray($txt);
3441
  foreach($unicode as $char) {
3442
  if ($this->ws && $char == 32) { // space
3443
  if (count($str)) { $bits[] = array($upp, $str, false); }
3444
+ $bits[] = array(false, array(32), true);
3445
+ $str = array();
3446
  $upp = false;
3447
  }
3448
+ else if (isset($this->upperCase[$char])) {
3449
+ if (!$upp) {
3450
  if (count($str)) { $bits[] = array($upp, $str, false); }
3451
+ $str = array();
3452
  }
3453
+ $str[] = $this->upperCase[$char];
3454
+ if ((!isset($this->CurrentFont['sip']) || !$this->CurrentFont['sip']) && (!isset($this->CurrentFont['smp']) || !$this->CurrentFont['smp'])) {
3455
  $this->CurrentFont['subset'][$this->upperCase[$char]] = $this->upperCase[$char];
3456
  }
3457
  $upp = true;
3458
  }
3459
+ else {
3460
+ if ($upp) {
3461
  if (count($str)) { $bits[] = array($upp, $str, false); }
3462
+ $str = array();
3463
  }
3464
  $str[] = $char;
3465
  $upp = false;
3468
  }
3469
  else {
3470
  for($i=0;$i<strlen($txt);$i++) {
3471
+ if (isset($this->upperCase[ord($txt[$i])]) && $this->upperCase[ord($txt[$i])] < 256) {
3472
+ if (!$upp) {
3473
  if (count($str)) { $bits[] = array($upp, $str, false); }
3474
+ $str = array();
3475
  }
3476
+ $str[] = $this->upperCase[ord($txt[$i])];
3477
  $upp = true;
3478
  }
3479
+ else {
3480
+ if ($upp) {
3481
  if (count($str)) { $bits[] = array($upp, $str, false); }
3482
+ $str = array();
3483
  }
3484
  $str[] = ord($txt[$i]);
3485
  $upp = false;
3498
  $size = count ($b[1]);
3499
  $txt = '';
3500
  for ($i = 0; $i < $size; $i++) {
3501
+ $txt .= code2utf($b[1][$i]);
3502
  }
3503
+ if ($this->usingCoreFont) {
3504
  $txt = utf8_decode($txt);
3505
  }
3506
  if ($mode == 'SIPSMP') {
3507
  $txt = $this->UTF8toSubset($txt);
3508
  }
3509
+ else {
3510
  if (!$this->usingCoreFont) {
3511
  $txt = $this->UTF8ToUTF16BE($txt, false);
3512
  }
3513
+ $txt=$this->_escape($txt);
3514
  $txt = '('.$txt.')';
3515
  }
3516
  if ($b[2]) { // space
3517
+ $s.=sprintf(' /F%d %.3F Tf %d Tz', $fid, $this->FontSizePt, 100);
3518
  $s.=sprintf(' %.3F Tc', ($this->charspacing+$this->ws));
3519
  $s.=sprintf(' %s Tj', $txt);
3520
  }
3521
+ else if ($upp) {
3522
+ $s.=sprintf(' /F%d %.3F Tf', $fid, $this->FontSizePt*$this->smCapsScale);
3523
+ $s.=sprintf(' %d Tz', $this->smCapsStretch);
3524
  $s.=sprintf(' %.3F Tc', ($this->charspacing*100/$this->smCapsStretch));
3525
  $s.=sprintf(' %s Tj', $txt);
3526
  }
3527
+ else {
3528
+ $s.=sprintf(' /F%d %.3F Tf %d Tz', $fid, $this->FontSizePt, 100);
3529
+ $s.=sprintf(' %.3F Tc', ($this->charspacing));
3530
  $s.=sprintf(' %s Tj', $txt);
3531
  }
3532
  }
3634
  // JUSTIFY J using Unicode fonts (Word spacing doesn't work)
3635
  // WORD SPACING UNICODE
3636
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
3637
+ $tmp = str_replace(chr(194).chr(160),chr(32),$tmp );
3638
  $len_ligne = $this->GetStringWidth($tmp );
3639
+ $nb_carac = mb_strlen( $tmp , $this->mb_enc ) ;
3640
+ $nb_spaces = mb_substr_count( $tmp ,' ', $this->mb_enc ) ;
3641
 
3642
  $inclCursive=false;
3643
  if ($checkCursive) {
3712
  // Change NON_BREAKING SPACE to spaces so they are 'spaced' properly
3713
  $tmp = str_replace(chr(160),chr(32),$tmp);
3714
  $len_ligne = $this->GetStringWidth($tmp );
3715
+ $nb_carac = strlen( $tmp ) ;
3716
+ $nb_spaces = substr_count( $tmp ,' ' ) ;
3717
  list($charspacing,$ws) = $this->GetJspacing($nb_carac,$nb_spaces,((($wmax) - $len_ligne) * _MPDFK),false);
3718
  $this->SetSpacing($charspacing,$ws);
3719
  //////////////////////////////////////////
3756
  $saved[ 'style' ] = $this->FontStyle;
3757
  $saved[ 'sizePt' ] = $this->FontSizePt;
3758
  $saved[ 'size' ] = $this->FontSize;
3759
+ $saved[ 'HREF' ] = $this->HREF;
3760
+ $saved[ 'underline' ] = $this->U;
3761
  $saved[ 'smCaps' ] = $this->S;
3762
  $saved[ 'strike' ] = $this->strike;
3763
  $saved[ 'textshadow' ] = $this->textshadow;
3764
+ $saved[ 'SUP' ] = $this->SUP;
3765
+ $saved[ 'SUB' ] = $this->SUB;
3766
  $saved[ 'linewidth' ] = $this->LineWidth;
3767
  $saved[ 'drawcolor' ] = $this->DrawColor;
3768
  $saved[ 'is_outline' ] = $this->outline_on;
3778
  $saved[ 'colorarray' ] = $this->colorarray;
3779
  $saved[ 'bgcolorarray' ] = $this->spanbgcolorarray;
3780
  $saved[ 'border' ] = $this->spanborddet;
3781
+ $saved[ 'color' ] = $this->TextColor;
3782
  $saved[ 'bgcolor' ] = $this->FillColor;
3783
  $saved['lang'] = $this->currentLang;
3784
  $saved['display_off'] = $this->inlineDisplayOff;
3794
 
3795
  $this->currentLang = $saved['lang'];
3796
  if ($this->useLang && !$this->usingCoreFont) {
3797
+ if ($this->currentLang != $this->default_lang && ((strlen($this->currentLang) == 5 && $this->currentLang != 'UTF-8') || strlen($this->currentLang ) == 2)) {
3798
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($this->currentLang, $this->useAdobeCJK);
3799
  if ($mpdf_pdf_unifonts) { $this->RestrictUnicodeFonts($mpdf_pdf_unifonts); }
3800
  else { $this->RestrictUnicodeFonts($this->default_available_fonts ); }
3801
  }
3802
+ else {
3803
  $this->RestrictUnicodeFonts($this->default_available_fonts );
3804
+ }
3805
  }
3806
 
3807
  $this->ColorFlag = ($this->FillColor != $this->TextColor); //Restore ColorFlag as well
3829
  }
3830
  else { $this->fixedlSpacing = false; }
3831
  $this->wSpacingCSS = $saved[ 'wSpacingCSS' ];
3832
+ if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
3833
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
3834
  }
3835
  else { $this->minwSpacing = 0; }
3889
  $saved[ 'sizePt' ] = $this->FontSizePt;
3890
  $saved[ 'size' ] = $this->FontSize;
3891
  $saved[ 'curr' ] = &$this->CurrentFont;
3892
+ $saved[ 'color' ] = $this->TextColor;
3893
+ $saved[ 'spanbgcolor' ] = $this->spanbgcolor;
3894
+ $saved[ 'spanbgcolorarray' ] = $this->spanbgcolorarray;
3895
  $saved[ 'bord' ] = $this->spanborder;
3896
  $saved[ 'border' ] = $this->spanborddet;
3897
  $saved[ 'HREF' ] = $this->HREF;
3898
+ $saved[ 'underline' ] = $this->U;
3899
  $saved[ 'smCaps' ] = $this->S;
3900
  $saved[ 'strike' ] = $this->strike;
3901
  $saved[ 'textshadow' ] = $this->textshadow;
3906
  $saved[ 'is_outline' ] = $this->outline_on;
3907
  $saved[ 'outlineparam' ] = $this->outlineparam;
3908
  $saved[ 'ReqFontStyle' ] = $this->ReqFontStyle;
3909
+ $saved[ 'fontkerning' ] = $this->kerning;
3910
  $saved[ 'fixedlSpacing' ] = $this->fixedlSpacing;
3911
  $saved[ 'minwSpacing' ] = $this->minwSpacing;
3912
  return $saved;
3920
  $this->FontSizePt = $saved[ 'sizePt' ];
3921
  $this->FontSize = $saved[ 'size' ];
3922
  $this->CurrentFont = &$saved[ 'curr' ];
3923
+ $this->TextColor = $saved[ 'color' ];
3924
+ $this->spanbgcolor = $saved[ 'spanbgcolor' ];
3925
+ $this->spanbgcolorarray = $saved[ 'spanbgcolorarray' ];
3926
  $this->spanborder = $saved[ 'bord' ];
3927
  $this->spanborddet = $saved[ 'border' ];
3928
  $this->ColorFlag = ($this->FillColor != $this->TextColor); //Restore ColorFlag as well
3929
+ $this->HREF = $saved[ 'HREF' ];
3930
+ $this->U = $saved[ 'underline' ];
3931
  $this->S = $saved[ 'smCaps' ];
3932
  $this->kerning = $saved[ 'fontkerning' ];
3933
  $this->fixedlSpacing = $saved[ 'fixedlSpacing' ];
3934
  $this->minwSpacing = $saved[ 'minwSpacing' ];
3935
+ $this->strike = $saved[ 'strike' ];
3936
  $this->textshadow = $saved[ 'textshadow' ];
3937
+ $this->SUP = $saved[ 'SUP' ];
3938
+ $this->SUB = $saved[ 'SUB' ];
3939
+ $this->LineWidth = $saved[ 'linewidth' ];
3940
+ $this->DrawColor = $saved[ 'drawcolor' ];
3941
+ $this->outline_on = $saved[ 'is_outline' ];
3942
  $this->outlineparam = $saved[ 'outlineparam' ];
3943
+ if ($write) {
3944
  $this->SetFont($saved[ 'family' ],$saved[ 'style' ].($this->U ? 'U' : '').($this->S ? 'S' : ''),$saved[ 'sizePt' ],true,true); // force output
3945
  $fontout = (sprintf('BT /F%d %.3F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
3946
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['Font']) && $this->pageoutput[$this->page]['Font'] != $fontout) || !isset($this->pageoutput[$this->page]['Font']) || $this->keep_block_together)) { $this->_out($fontout); }
3947
  $this->pageoutput[$this->page]['Font'] = $fontout;
3948
  }
3949
+ else
3950
  $this->SetFont($saved[ 'family' ],$saved[ 'style' ].($this->U ? 'U' : '').($this->S ? 'S' : ''),$saved[ 'sizePt' ]);
3951
  $this->ReqFontStyle = $saved[ 'ReqFontStyle' ];
3952
  }
3953
 
3954
  function newFlowingBlock( $w, $h, $a = '', $is_table = false, $is_list = false, $blockstate = 0, $newblock=true, $blockdir='ltr')
3955
  {
3956
+ if (!$a) {
3957
  if ($blockdir=='rtl') { $a = 'R'; }
3958
  else { $a = 'L'; }
3959
  }
4023
 
4024
  // Print out each chunk
4025
 
4026
+ if ($is_table) {
4027
+ $ipaddingL = 0;
4028
+ $ipaddingR = 0;
4029
  $paddingL = 0;
4030
  $paddingR = 0;
4031
+ }
4032
+ else {
4033
+ $ipaddingL = $this->blk[$this->blklvl]['padding_left'];
4034
+ $ipaddingR = $this->blk[$this->blklvl]['padding_right'];
4035
+ $paddingL = ($ipaddingL * _MPDFK);
4036
  $paddingR = ($ipaddingR * _MPDFK);
4037
  $this->cMarginL = $this->blk[$this->blklvl]['border_left']['w'];
4038
  $this->cMarginR = $this->blk[$this->blklvl]['border_right']['w'];
4042
  $fpaddingL = 0;
4043
 
4044
  $usey = $this->y + 0.002;
4045
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4046
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4047
  }
4048
  } // *TABLES*
4049
 
4050
  // Set Current lineheight (correction factor)
4051
+ $lhfixed = false;
4052
  if ($is_list) {
4053
+ if (preg_match('/([0-9.,]+)mm/',$this->list_lineheight[$this->listlvl][$this->listOcc],$am)) {
4054
+ $lhfixed = true;
4055
  $def_fontsize = $this->InlineProperties['LISTITEM'][$this->listlvl][$this->listOcc][$this->listnum]['size'];
4056
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4057
  }
4058
+ else {
4059
+ $this->lineheight_correction = $this->list_lineheight[$this->listlvl][$this->listOcc];
4060
  }
4061
  }
4062
  else
4063
  if ($is_table) {
4064
+ if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight,$am)) {
4065
+ $lhfixed = true;
4066
  $def_fontsize = $this->FontSize; // needs to be default font-size for block ****
4067
+ $this->lineheight_correction = $lineHeight / $def_fontsize ;
4068
  }
4069
+ else {
4070
+ $this->lineheight_correction = $this->table_lineheight;
4071
  }
4072
  }
4073
  else
4074
  if (isset($this->blk[$this->blklvl]['line_height']) && $this->blk[$this->blklvl]['line_height']) {
4075
+ if (preg_match('/([0-9.,]+)mm/',$this->blk[$this->blklvl]['line_height'],$am)) {
4076
+ $lhfixed = true;
4077
  $def_fontsize = $this->blk[$this->blklvl]['InlineProperties']['size']; // needs to be default font-size for block ****
4078
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4079
  }
4080
+ else {
4081
+ $this->lineheight_correction = $this->blk[$this->blklvl]['line_height'];
4082
  }
4083
+ }
4084
  else {
4085
+ $this->lineheight_correction = $this->normalLineheight;
4086
  }
4087
 
4088
  // correct lineheight to maximum fontsize
4095
  foreach ( $content as $k => $chunk )
4096
  {
4097
  $this->restoreFont( $font[ $k ],false );
4098
+ if (!isset($this->objectbuffer[$k])) {
4099
  // Soft Hyphens chr(173)
4100
  if (!$this->usingCoreFont) {
4101
+ $content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk );
4102
  }
4103
  else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
4104
  $content[$k] = $chunk = str_replace(chr(173),'',$chunk );
4107
  if (($this->SUB || $this->SUP) && count($content)==1) { $actfs = $this->FontSize*100/55; } // 55% is font change for sub/sup
4108
  else { $actfs = $this->FontSize; }
4109
  if (!$lhfixed) { $maxlineHeight = max($maxlineHeight,$actfs * $this->lineheight_correction ); }
4110
+ if ($lhfixed && ($actfs > $def_fontsize || ($actfs > ($lineHeight * $this->lineheight_correction) && $is_list))) {
4111
+ $this->forceExactLineheight = false;
4112
  }
4113
  $maxfontsize = max($maxfontsize,$actfs);
4114
  }
4139
 
4140
  $af = 0; // Above font
4141
  $bf = 0; // Below font
4142
+ $mta = 0; // Maximum top-aligned
4143
+ $mba = 0; // Maximum bottom-aligned
4144
 
4145
  foreach ( $content as $k => $chunk )
4146
  {
4147
+ if (isset($this->objectbuffer[$k])) {
4148
  $oh = $this->objectbuffer[$k]['OUTER-HEIGHT'];
4149
  $va = $this->objectbuffer[$k]['vertical-align']; // = $objattr['vertical-align'] = set as M,T,B,S
4150
  if ($lhfixed && $oh > $def_fontsize) { $this->forceExactLineheight = false; }
4152
  if ($va == 'BS') { // (BASELINE default)
4153
  $af = max($af, ($oh - ($maxfontsize * (0.5 + $this->baselineC))));
4154
  }
4155
+ else if ($va == 'M') {
4156
  $af = max($af, ($oh - $maxfontsize)/2);
4157
  $bf = max($bf, ($oh - $maxfontsize)/2);
4158
  }
4159
+ else if ($va == 'TT') {
4160
  $bf = max($bf, ($oh - $maxfontsize));
4161
  }
4162
+ else if ($va == 'TB') {
4163
  $af = max($af, ($oh - $maxfontsize));
4164
  }
4165
+ else if ($va == 'T') {
4166
  $mta = max($mta, $oh);
4167
  }
4168
+ else if ($va == 'B') {
4169
  $mba = max($mba, $oh);
4170
  }
4171
  }
4174
  $maxlineHeight = $maxfontsize + $af + $bf;
4175
  }
4176
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
4177
+ if ($mta > $maxlineHeight) {
4178
  $bf += ($mta - $maxlineHeight);
4179
  $maxlineHeight = $mta;
4180
  }
4181
+ if ($mba > $maxlineHeight) {
4182
  $af += ($mba - $maxlineHeight);
4183
  $maxlineHeight = $mba;
4184
  }
4185
 
4186
  $lineHeight = $maxlineHeight;
4187
  // If NOT images, and maxfontsize NOT > lineHeight - this value determines text baseline positioning
4188
+ if ($lhfixed && $af==0 && $bf==0 && $maxfontsize<=($def_fontsize * $this->lineheight_correction * 0.8 )) {
4189
+ $this->linemaxfontsize = $def_fontsize;
4190
  }
4191
  else { $this->linemaxfontsize = $maxfontsize; }
4192
 
4198
  // but ? needs to fix potentially more widespread...
4199
  // if (!$content) { $check_h = 0; }
4200
 
4201
+ if ($this->blklvl > 0 && !$is_table) {
4202
+ if ($endofblock && $blockstate > 1) {
4203
  if ($this->blk[$this->blklvl]['page_break_after_avoid']) { $check_h += $lineHeight; }
4204
  $check_h += ($this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w']);
4205
  }
4206
  // mPDF 5.4.03
4207
+ if (($newblock && ($blockstate==1 || $blockstate==3) && $lineCount == 0) || ($endofblock && $blockstate ==3 && $lineCount == 0)) {
4208
  $check_h += ($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['border_top']['w']);
4209
  }
4210
  }
4211
 
4212
  // Force PAGE break if column height cannot take check-height
4213
+ if ($this->ColActive && $check_h > ($this->PageBreakTrigger - $this->y0)) {
4214
  $this->SetCol($this->NbCol-1);
4215
  }
4216
 
4247
 
4248
 
4249
  // TOP MARGIN
4250
+ if ($newblock && ($blockstate==1 || $blockstate==3) && ($this->blk[$this->blklvl]['margin_top']) && $lineCount == 0 && !$is_table && !$is_list) {
4251
+ $this->DivLn($this->blk[$this->blklvl]['margin_top'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
4252
  }
4253
 
4254
+ if ($newblock && ($blockstate==1 || $blockstate==3) && $lineCount == 0 && !$is_table && !$is_list) {
4255
  $this->blk[$this->blklvl]['y0'] = $this->y;
4256
  $this->blk[$this->blklvl]['startpage'] = $this->page;
4257
  }
4258
 
4259
  // ADDED for Paragraph_indent
4260
  $WidthCorrection = 0;
4261
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align != 'C')) {
4262
+ $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4263
+ $WidthCorrection = ($ti*_MPDFK);
4264
+ }
4265
 
4266
 
4267
  // PADDING and BORDER spacing/fill
4268
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && (($this->blk[$this->blklvl]['padding_top']) || ($this->blk[$this->blklvl]['border_top'])) && ($lineCount == 0) && (!$is_table) && (!$is_list)) {
4269
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
4270
+ $this->DivLn($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'],-3,true,false,1);
4271
  $this->x = $currentx;
4272
  }
4273
 
4277
  $fpaddingL = 0;
4278
 
4279
  $usey = $this->y + 0.002;
4280
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4281
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4282
  }
4283
 
4297
  $chunk = str_replace(chr(160),chr(32),$chunk );
4298
  }
4299
  else {
4300
+ $chunk = str_replace(chr(194).chr(160),chr(32),$chunk );
4301
  }
4302
+ $nb_carac += mb_strlen( $chunk, $this->mb_enc );
4303
+ $nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc );
4304
  if ($checkCursive) {
4305
  }
4306
  }
4336
 
4337
  $empty /= _MPDFK;
4338
 
4339
+ if (!$is_table) {
4340
+ $this->maxPosR = max($this->maxPosR , ($this->w - $this->rMargin - $this->blk[$this->blklvl]['outer_right_margin'] - $empty));
4341
+ $this->maxPosL = min($this->maxPosL , ($this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $empty));
4342
  }
4343
 
4344
  $arraysize = count($content);
4358
 
4359
 
4360
  // Paragraph INDENT
4361
+ $WidthCorrection = 0;
4362
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align !='C')) {
4363
+ $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4364
+ $this->x += $ti;
4365
  }
4366
 
4367
 
4373
 
4374
  $va = 'M'; // default for text
4375
  if (isset($this->objectbuffer[$dirk]) && $this->objectbuffer[$dirk]) {
4376
+ $xadj = $this->x - $this->objectbuffer[$dirk]['OUTER-X'];
4377
  $this->objectbuffer[$dirk]['OUTER-X'] += $xadj;
4378
  $this->objectbuffer[$dirk]['BORDER-X'] += $xadj;
4379
  $this->objectbuffer[$dirk]['INNER-X'] += $xadj;
4380
  $va = $this->objectbuffer[$dirk]['vertical-align'];
4381
  $yadj = $this->y - $this->objectbuffer[$dirk]['OUTER-Y'];
4382
+ if ($va == 'BS') {
4383
  $yadj += $af + ($this->linemaxfontsize * (0.5 + $this->baselineC)) - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4384
  }
4385
+ else if ($va == 'M' || $va == '') {
4386
  $yadj += $af + ($this->linemaxfontsize /2) - ($this->objectbuffer[$dirk]['OUTER-HEIGHT']/2);
4387
  }
4388
+ else if ($va == 'TB') {
4389
  $yadj += $af + $this->linemaxfontsize - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4390
  }
4391
+ else if ($va == 'TT') {
4392
  $yadj += $af;
4393
  }
4394
+ else if ($va == 'B') {
4395
  $yadj += $af + $this->linemaxfontsize + $bf - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
4396
  }
4397
+ else if ($va == 'T') {
4398
  $yadj += 0;
4399
  }
4400
  $this->objectbuffer[$dirk]['OUTER-Y'] += $yadj;
4413
  $this->minwSpacing = 0;
4414
 
4415
  // *********** SPAN BACKGROUND COLOR ***************** //
4416
+ if (isset($this->spanbgcolor) && $this->spanbgcolor) {
4417
  $cor = $this->spanbgcolorarray;
4418
  $this->SetFColor($cor);
4419
  $save_fill = $fill; $spanfill = 1; $fill = 1;
4420
  }
4421
+ if (!empty($this->spanborddet)) {
4422
  if (strpos($contentB[$k],'L')!==false && isset($this->spanborddet['L'])) $this->x += $this->spanborddet['L']['w'];
4423
+ if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0;
4424
+ if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0;
4425
  }
4426
  // WORD SPACING
4427
+ $stringWidth = $this->GetStringWidth($chunk ) + ( $this->charspacing * mb_strlen($chunk,$this->mb_enc ) / _MPDFK )
4428
  + ( $this->ws * mb_substr_count($chunk,' ',$this->mb_enc ) / _MPDFK );
4429
+ if (isset($this->objectbuffer[$dirk])) {
4430
+ if ($this->objectbuffer[$dirk]['type']=='dottab') {
4431
+ $this->objectbuffer[$dirk]['OUTER-WIDTH'] +=$empty;
4432
  }
4433
  $stringWidth = $this->objectbuffer[$dirk]['OUTER-WIDTH'];
4434
  }
4437
  if ($k == $arraysize-1) $this->Cell( $stringWidth, $lineHeight, $chunk, '', 1, '', $fill, $this->HREF , $currentx,0,0,'M', $fill, $af, $bf, true ); //mono-style line or last part (skips line)
4438
  else $this->Cell( $stringWidth, $lineHeight, $chunk, '', 0, '', $fill, $this->HREF, 0, 0,0,'M', $fill, $af, $bf, true );//first or middle part
4439
 
4440
+ if (!empty($this->spanborddet)) {
4441
  if (strpos($contentB[$k],'R')!==false && $k != $arraysize-1) $this->x += $this->spanborddet['R']['w'];
4442
  }
4443
  // *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
4444
+ if (isset($spanfill) && $spanfill) {
4445
+ $fill = $save_fill; $spanfill = 0;
4446
  if ($fill) { $this->SetFColor($bcor); }
4447
  }
4448
  }
4461
  $savedFont = $this->saveFont();
4462
 
4463
  $bull = $this->bulletarray;
4464
+ if (isset($bull['level']) && isset($bull['occur']) && isset($this->InlineProperties['LIST'][$bull['level']][$bull['occur']])) {
4465
+ $this->restoreInlineProperties($this->InlineProperties['LIST'][$bull['level']][$bull['occur']]);
4466
  }
4467
  if (isset($bull['level']) && isset($bull['occur']) && isset($bull['num']) && isset($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) && $this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) { $this->restoreInlineProperties($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]); }
4468
  if (isset($bull['font']) && $bull['font'] == 'czapfdingbats') {
4496
 
4497
 
4498
  // PADDING and BORDER spacing/fill
4499
+ if ($endofblock && ($blockstate > 1) && ($this->blk[$this->blklvl]['padding_bottom'] || $this->blk[$this->blklvl]['border_bottom'] || $this->blk[$this->blklvl]['css_set_height']) && (!$is_table) && (!$is_list)) {
4500
+ // If CSS height set, extend bottom - if on same page as block started, and CSS HEIGHT > actual height,
4501
  // and does not force pagebreak
4502
  $extra = 0;
4503
  if ($this->blk[$this->blklvl]['css_set_height'] && $this->blk[$this->blklvl]['startpage']==$this->page) {
4505
  $h1 = ($this->y-$this->blk[$this->blklvl]['y0']) + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'];
4506
  if ($h1 < ($this->blk[$this->blklvl]['css_set_height']+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['padding_top'])) { $extra = ($this->blk[$this->blklvl]['css_set_height']+$this->blk[$this->blklvl]['padding_bottom']+$this->blk[$this->blklvl]['padding_top']) - $h1; }
4507
  if($this->y + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'] + $extra > $this->PageBreakTrigger) {
4508
+ $extra = $this->PageBreakTrigger - ($this->y + $this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w']);
4509
  }
4510
  }
4511
 
4512
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
4513
+ $this->DivLn($this->blk[$this->blklvl]['padding_bottom'] + $this->blk[$this->blklvl]['border_bottom']['w'] + $extra,-3,true,false,2);
4514
  $this->x = $currentx;
4515
 
4516
 
4517
  }
4518
 
4519
  // SET Bottom y1 of block (used for painting borders)
4520
+ if (($endofblock) && ($blockstate > 1) && (!$is_table) && (!$is_list)) {
4521
  $this->blk[$this->blklvl]['y1'] = $this->y;
4522
  }
4523
 
4524
  // BOTTOM MARGIN
4525
+ if (($endofblock) && ($blockstate > 1) && ($this->blk[$this->blklvl]['margin_bottom']) && (!$is_table) && (!$is_list)) {
4526
  if($this->y+$this->blk[$this->blklvl]['margin_bottom'] < $this->PageBreakTrigger and !$this->InFooter) {
4527
+ $this->DivLn($this->blk[$this->blklvl]['margin_bottom'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
4528
  }
4529
  }
4530
 
4538
 
4539
  function printobjectbuffer($is_table=false, $blockdir=false) {
4540
  if (!$blockdir) { $blockdir = $this->directionality; }
4541
+ if ($is_table && $this->shrin_k > 1) { $k = $this->shrin_k; }
4542
  else { $k = 1; }
4543
  $save_y = $this->y;
4544
  $save_x = $this->x;
4546
  $save_currentfontsize = $this->FontSizePt;
4547
  $save_currentfontstyle = $this->FontStyle.($this->U ? 'U' : '').($this->S ? 'S' : '');
4548
  if ($blockdir == 'rtl') { $rtlalign = 'R'; } else { $rtlalign = 'L'; }
4549
+ foreach ($this->objectbuffer AS $ib => $objattr) {
4550
  if ($objattr['type'] == 'bookmark' || $objattr['type'] == 'indexentry' || $objattr['type'] == 'toc') {
4551
+ $x = $objattr['OUTER-X'];
4552
  $y = $objattr['OUTER-Y'];
4553
  $this->y = $y - $this->FontSize/2;
4554
  $this->x = $x;
4555
  }
4556
+ else {
4557
  $y = $objattr['OUTER-Y'];
4558
  $x = $objattr['OUTER-X'];
4559
  $w = $objattr['OUTER-WIDTH'];
4604
  $sy = ($objattr['INNER-HEIGHT']*_MPDFK / $objattr['orig_h']);
4605
 
4606
  if (isset($objattr['ROTATE'])) { $rotate = $objattr['ROTATE']; }
4607
+ if ($rotate==90) {
4608
  // Clockwise
4609
  $obiw = $objattr['INNER-HEIGHT'];
4610
  $obih = $objattr['INNER-WIDTH'];
4613
  $sx = $obiw*_MPDFK / $objattr['orig_h'];
4614
  $sy = $obih*_MPDFK / $objattr['orig_w'];
4615
  }
4616
+ else if ($rotate==-90 || $rotate==270) {
4617
  // AntiClockwise
4618
  $obiw = $objattr['INNER-HEIGHT'];
4619
  $obih = $objattr['INNER-WIDTH'];
4622
  $sx = $obiw*_MPDFK / $objattr['orig_h'];
4623
  $sy = $obih*_MPDFK / $objattr['orig_w'];
4624
  }
4625
+ else if ($rotate==180) {
4626
  // Mirror
4627
  $tr = $this->transformTranslate($objattr['INNER-WIDTH'], -$objattr['INNER-HEIGHT'], true) ;
4628
  $tr .= ' '. $this->transformRotate(180, $objattr['INNER-X'],($objattr['INNER-Y'] +$objattr['INNER-HEIGHT'] ),true) ;
4633
  $gradmask = '';
4634
 
4635
 
4636
+ if (isset($objattr['itype']) && $objattr['itype']=='svg') {
4637
  $outstring = sprintf('q '.$tr.'%.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, -$sy, $objattr['INNER-X']*_MPDFK-$sx*$objattr['wmf_x'], (($this->h-$objattr['INNER-Y'])*_MPDFK)+$sy*$objattr['wmf_y'], $objattr['ID']);
4638
  }
4639
+ else {
4640
  $outstring = sprintf("q ".$tr."%.3F 0 0 %.3F %.3F %.3F cm ".$gradmask."/I%d Do Q",$obiw*_MPDFK, $obih*_MPDFK, $objattr['INNER-X'] *_MPDFK, ($this->h-($objattr['INNER-Y'] +$obih ))*_MPDFK,$objattr['ID'] );
4641
  }
4642
  $this->_out($outstring);
4720
 
4721
  function WriteFlowingBlock( $s)
4722
  {
4723
+ $currentx = $this->x;
4724
  $is_table = $this->flowingBlockAttr[ 'is_table' ];
4725
  $is_list = $this->flowingBlockAttr[ 'is_list' ];
4726
  // width of all the content so far in points
4769
  $oldcolumn = $this->CurrCol;
4770
 
4771
 
4772
+ if ($is_table) {
4773
+ $ipaddingL = 0;
4774
+ $ipaddingR = 0;
4775
+ $paddingL = 0;
4776
+ $paddingR = 0;
4777
  $cpaddingadjustL = 0;
4778
  $cpaddingadjustR = 0;
4779
  // Added mPDF 3.0
4780
  $fpaddingR = 0;
4781
  $fpaddingL = 0;
4782
+ }
4783
+ else {
4784
+ $ipaddingL = $this->blk[$this->blklvl]['padding_left'];
4785
+ $ipaddingR = $this->blk[$this->blklvl]['padding_right'];
4786
+ $paddingL = ($ipaddingL * _MPDFK);
4787
+ $paddingR = ($ipaddingR * _MPDFK);
4788
  $this->cMarginL = $this->blk[$this->blklvl]['border_left']['w'];
4789
  $cpaddingadjustL = -$this->cMarginL;
4790
  $this->cMarginR = $this->blk[$this->blklvl]['border_right']['w'];
4794
  $fpaddingL = 0;
4795
 
4796
  $usey = $this->y + 0.002;
4797
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4798
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4799
  }
4800
  } // *TABLES*
4802
  //OBJECTS - IMAGES & FORM Elements (NB has already skipped line/page if required - in printbuffer)
4803
  if (substr($s,0,3) == "\xbb\xa4\xac") { //identifier has been identified!
4804
  $objattr = $this->_getObjAttr($s);
4805
+ $h_corr = 0;
4806
  if ($is_table) { // *TABLES*
4807
  $maximumW = ($maxWidth/_MPDFK) - ($this->cellPaddingL + $this->cMarginL + $this->cellPaddingR + $this->cMarginR); // *TABLES*
4808
  } // *TABLES*
4809
  else { // *TABLES*
4810
  if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) && (!$is_table)) { $h_corr = $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w']; }
4811
+ $maximumW = ($maxWidth/_MPDFK) - ($this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_right'] + $this->blk[$this->blklvl]['border_right']['w'] + $fpaddingL + $fpaddingR );
4812
  } // *TABLES*
4813
  $objattr = $this->inlineObject($objattr['type'],$this->lMargin + $fpaddingL + ($contentWidth/_MPDFK),($this->y + $h_corr), $objattr, $this->lMargin,($contentWidth/_MPDFK),$maximumW,$lineHeight,true,$is_table);
4814
 
4822
  }
4823
 
4824
  $lbw = $rbw = 0; // Border widths
4825
+ if (!empty($this->spanborddet)) {
4826
  if (isset($this->spanborddet['L'])) $lbw = $this->spanborddet['L']['w'];
4827
  if (isset($this->spanborddet['R'])) $rbw = $this->spanborddet['R']['w'];
4828
  }
4834
  $tmp = mb_strlen( $s, $this->mb_enc );
4835
  }
4836
 
4837
+ $orphs = 0;
4838
  $check = 0;
4839
 
4840
  // for every character in the string
4846
  // Soft Hyphens chr(173)
4847
  $cw = ($this->GetCharWidthCore($c) * _MPDFK);
4848
  if ($this->kerning && $this->useKerning && $i > 0) {
4849
+ if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$c])) {
4850
  $cw += ($this->CurrentFont['kerninfo'][$s[($i-1)]][$c] * $this->FontSizePt / 1000 );
4851
  }
4852
  }
4858
  $lastc = mb_substr($s,($i-1),1,$this->mb_enc );
4859
  $ulastc = $this->UTF8StringToArray($lastc, false);
4860
  $uc = $this->UTF8StringToArray($c, false);
4861
+ if (isset($this->CurrentFont['kerninfo'][$ulastc[0]][$uc[0]])) {
4862
  $cw += ($this->CurrentFont['kerninfo'][$ulastc[0]][$uc[0]] * $this->FontSizePt / 1000 );
4863
  }
4864
  }
4896
  else { $orphs = 0; }
4897
 
4898
  // ADDED for Paragraph_indent
4899
+ $WidthCorrection = 0;
4900
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && isset($this->blk[$this->blklvl]['text_indent']) && ($lineCount == 0) && (!$is_table) && (!$is_list) && ($align != 'C')) {
4901
+ $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
4902
+ $WidthCorrection = ($ti*_MPDFK);
4903
+ }
4904
 
4905
  // Added mPDF 3.0 Float DIV
4906
  $fpaddingR = 0;
4907
  $fpaddingL = 0;
4908
 
4909
  $usey = $this->y + 0.002;
4910
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
4911
  $usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
4912
  }
4913
 
4926
  $savedObj = array();
4927
 
4928
  // cut off and save any partial words at the end of the string
4929
+ $words = explode( ' ', $currContent );
4930
  ///////////////////
4931
  // HYPHENATION
4932
  $currWord = $words[count($words)-1] ;
4939
 
4940
  // mPDF 5.5.10
4941
  $lastchar = mb_substr($words[0],mb_strlen($words[0], $this->mb_enc)-1, 1, $this->mb_enc);
4942
+ $lastContent = $words[0];
4943
  $savedFont = $this->saveFont();
4944
  // replace the current content with the cropped version
4945
  $currContent = rtrim( $lastContent );
4972
  }
4973
 
4974
  // Set Current lineheight (correction factor)
4975
+ $lhfixed = false;
4976
  if ($is_list) {
4977
+ if (preg_match('/([0-9.,]+)mm/',$this->list_lineheight[$this->listlvl][$this->listOcc],$am)) {
4978
+ $lhfixed = true;
4979
  $def_fontsize = $this->InlineProperties['LISTITEM'][$this->listlvl][$this->listOcc][$this->listnum]['size'];
4980
  $this->lineheight_correction = $am[1] / $def_fontsize ;
4981
  }
4982
+ else {
4983
+ $this->lineheight_correction = $this->list_lineheight[$this->listlvl][$this->listOcc];
4984
  }
4985
  }
4986
  else
4987
  if ($is_table) {
4988
+ if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight,$am)) {
4989
+ $lhfixed = true;
4990
  $def_fontsize = $this->FontSize; // needs to be default font-size for block ****
4991
+ $this->lineheight_correction = $lineHeight / $def_fontsize ;
4992
  }
4993
+ else {
4994
+ $this->lineheight_correction = $this->table_lineheight;
4995
  }
4996
  }
4997
  else
4998
  if (isset($this->blk[$this->blklvl]['line_height']) && $this->blk[$this->blklvl]['line_height']) {
4999
+ if (preg_match('/([0-9.,]+)mm/',$this->blk[$this->blklvl]['line_height'],$am)) {
5000
+ $lhfixed = true;
5001
  $def_fontsize = $this->blk[$this->blklvl]['InlineProperties']['size']; // needs to be default font-size for block ****
5002
  $this->lineheight_correction = $am[1] / $def_fontsize ;
5003
  }
5004
+ else {
5005
+ $this->lineheight_correction = $this->blk[$this->blklvl]['line_height'];
5006
  }
5007
+ }
5008
  else {
5009
+ $this->lineheight_correction = $this->normalLineheight;
5010
  }
5011
  // update $contentWidth and $cutoffWidth since they changed with cropping
5012
  // Also correct lineheight to maximum fontsize (not for tables)
5021
  foreach ( $content as $k => $chunk )
5022
  {
5023
  $this->restoreFont( $font[ $k ]);
5024
+ if (!isset($this->objectbuffer[$k])) {
5025
  if (!$this->usingCoreFont) {
5026
+ $content[$k] = $chunk = str_replace("\xc2\xad",'',$chunk );
5027
  }
5028
  // Soft Hyphens chr(173)
5029
  else if ($this->FontFamily!='csymbol' && $this->FontFamily!='czapfdingbats') {
5030
  $content[$k] = $chunk = str_replace(chr(173),'',$chunk );
5031
  }
5032
+ $contentWidth += $this->GetStringWidth( $chunk ) * _MPDFK;
5033
+ if (!empty($this->spanborddet)) {
5034
+ if (strpos($contentB[$k],'L')!==false) $contentWidth += $this->spanborddet['L']['w'] * _MPDFK;
5035
+ if (strpos($contentB[$k],'R')!==false) $contentWidth += $this->spanborddet['R']['w'] * _MPDFK;
5036
  }
5037
  if (!$lhfixed) { $maxlineHeight = max($maxlineHeight,$this->FontSize * $this->lineheight_correction ); }
5038
+ if ($lhfixed && ($this->FontSize > $def_fontsize || ($this->FontSize > ($lineHeight * $this->lineheight_correction) && $is_list))) {
5039
+ $this->forceExactLineheight = false;
5040
  }
5041
+ $maxfontsize = max($maxfontsize,$this->FontSize);
5042
  }
5043
  }
5044
 
5061
 
5062
  $af = 0; // Above font
5063
  $bf = 0; // Below font
5064
+ $mta = 0; // Maximum top-aligned
5065
+ $mba = 0; // Maximum bottom-aligned
5066
 
5067
  foreach ( $content as $k => $chunk ) {
5068
+ if (isset($this->objectbuffer[$k]) && $this->objectbuffer[$k]) {
5069
+ $contentWidth += $this->objectbuffer[$k]['OUTER-WIDTH'] * _MPDFK;
5070
  $oh = $this->objectbuffer[$k]['OUTER-HEIGHT'];
5071
  $va = $this->objectbuffer[$k]['vertical-align']; // = $objattr['vertical-align'] = set as M,T,B,S
5072
  if ($lhfixed && $oh > $def_fontsize) { $this->forceExactLineheight = false; }
5074
  if ($va == 'BS') { // (BASELINE default)
5075
  $af = max($af, ($oh - ($maxfontsize * (0.5 + $this->baselineC))));
5076
  }
5077
+ else if ($va == 'M') {
5078
  $af = max($af, ($oh - $maxfontsize)/2);
5079
  $bf = max($bf, ($oh - $maxfontsize)/2);
5080
  }
5081
+ else if ($va == 'TT') {
5082
  $bf = max($bf, ($oh - $maxfontsize));
5083
  }
5084
+ else if ($va == 'TB') {
5085
  $af = max($af, ($oh - $maxfontsize));
5086
  }
5087
+ else if ($va == 'T') {
5088
  $mta = max($mta, $oh);
5089
  }
5090
+ else if ($va == 'B') {
5091
  $mba = max($mba, $oh);
5092
  }
5093
  }
5097
  }
5098
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
5099
 
5100
+ if ($mta > $maxlineHeight) {
5101
  $bf += ($mta - $maxlineHeight);
5102
  $maxlineHeight = $mta;
5103
  }
5104
+ if ($mba > $maxlineHeight) {
5105
  $af += ($mba - $maxlineHeight);
5106
  $maxlineHeight = $mba;
5107
  }
5108
 
5109
 
5110
+ $lineHeight = $maxlineHeight;
5111
  $cutoffWidth = $contentWidth;
5112
  // If NOT images, and maxfontsize NOT > lineHeight - this value determines text baseline positioning
5113
+ if ($lhfixed && $af==0 && $bf==0 && $maxfontsize<=($def_fontsize * $this->lineheight_correction * 0.8 )) {
5114
+ $this->linemaxfontsize = $def_fontsize;
5115
  }
5116
  else { $this->linemaxfontsize = $maxfontsize; }
5117
 
5123
  $content[$k] = str_replace(chr(160),chr(32),$chunk );
5124
  }
5125
  else {
5126
+ $content[$k] = str_replace(chr(194).chr(160),chr(32),$chunk );
5127
  if ($checkCursive) {
5128
  }
5129
  }
5141
  // WORD SPACING
5142
  foreach ( $content as $k => $chunk ) {
5143
  if (!isset($this->objectbuffer[$k]) || (isset($this->objectbuffer[$k]) && !$this->objectbuffer[$k])) {
5144
+ $nb_carac += mb_strlen( $chunk, $this->mb_enc ) ;
5145
+ $nb_spaces += mb_substr_count( $chunk,' ', $this->mb_enc ) ;
5146
  }
5147
  }
5148
  list($jcharspacing,$jws) = $this->GetJspacing($nb_carac,$nb_spaces,($maxWidth-$lastitalic-$cutoffWidth-$WidthCorrection-(($this->cMarginL+$this->cMarginR)*_MPDFK)-($paddingL+$paddingR +(($fpaddingL + $fpaddingR) * _MPDFK) )),$inclCursive);
5159
  $b = ''; //do not use borders
5160
  // Get PAGEBREAK TO TEST for height including the top border/padding
5161
  $check_h = max($this->divheight,$lineHeight);
5162
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($this->blklvl > 0) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5163
  $check_h += ($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['border_top']['w']);
5164
  }
5165
 
5166
+ if ($this->ColActive && $check_h > ($this->PageBreakTrigger - $this->y0)) {
5167
  $this->SetCol($this->NbCol-1);
5168
  }
5169
 
5170
  // PAGEBREAK
5171
+ // 'If' below used in order to fix "first-line of other page with justify on" bug
5172
  if(!$is_table && ($this->y+$check_h) > $this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) {
5173
  $bak_x=$this->x;//Current X position
5174
 
5196
 
5197
 
5198
  // TOP MARGIN
5199
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($this->blk[$this->blklvl]['margin_top']) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5200
+ $this->DivLn($this->blk[$this->blklvl]['margin_top'],$this->blklvl-1,true,$this->blk[$this->blklvl]['margin_collapse']);
5201
  }
5202
 
5203
 
5204
  // Update y0 for top of block (used to paint border)
5205
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5206
  $this->blk[$this->blklvl]['y0'] = $this->y;
5207
  $this->blk[$this->blklvl]['startpage'] = $this->page;
5208
  }
5209
 
5210
  // TOP PADDING and BORDER spacing/fill
5211
+ if (($newblock) && ($blockstate==1 || $blockstate==3) && (($this->blk[$this->blklvl]['padding_top']) || ($this->blk[$this->blklvl]['border_top'])) && ($lineCount == 1) && (!$is_table) && (!$is_list)) {
5212
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
5213
  $this->DivLn($this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'],-3,true,false,1);
5214
  }
5225
  else if ($align == 'C') { $this->x += ($empty / 2); }
5226
 
5227
  // Paragraph INDENT
5228
+ if (isset($this->blk[$this->blklvl]['text_indent']) && ($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 1) && (!$is_table) && ($blockdir !='rtl') && ($align !='C')) {
5229
+ $ti = $this->ConvertSize($this->blk[$this->blklvl]['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
5230
+ $this->x += $ti;
5231
  }
5232
 
5233
  // DIRECTIONALITY RTL
5241
 
5242
  $va = 'M'; // default for text
5243
  if (isset($this->objectbuffer[$dirk]) && $this->objectbuffer[$dirk]) {
5244
+ $xadj = $this->x - $this->objectbuffer[$dirk]['OUTER-X'] ;
5245
  $this->objectbuffer[$dirk]['OUTER-X'] += $xadj;
5246
  $this->objectbuffer[$dirk]['BORDER-X'] += $xadj;
5247
  $this->objectbuffer[$dirk]['INNER-X'] += $xadj;
5248
  $va = $this->objectbuffer[$dirk]['vertical-align'];
5249
  $yadj = $this->y - $this->objectbuffer[$dirk]['OUTER-Y'];
5250
+ if ($va == 'BS') {
5251
  $yadj += $af + ($this->linemaxfontsize * (0.5 + $this->baselineC)) - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5252
  }
5253
+ else if ($va == 'M' || $va == '') {
5254
  $yadj += $af + ($this->linemaxfontsize /2) - ($this->objectbuffer[$dirk]['OUTER-HEIGHT']/2);
5255
  }
5256
+ else if ($va == 'TB') {
5257
  $yadj += $af + $this->linemaxfontsize - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5258
  }
5259
+ else if ($va == 'TT') {
5260
  $yadj += $af;
5261
  }
5262
+ else if ($va == 'B') {
5263
  $yadj += $af + $this->linemaxfontsize + $bf - $this->objectbuffer[$dirk]['OUTER-HEIGHT'];
5264
  }
5265
+ else if ($va == 'T') {
5266
  $yadj += 0;
5267
  }
5268
  $this->objectbuffer[$dirk]['OUTER-Y'] += $yadj;
5280
  $this->minwSpacing = 0;
5281
 
5282
  // *********** SPAN BACKGROUND COLOR ***************** //
5283
+ if ($this->spanbgcolor) {
5284
  $cor = $this->spanbgcolorarray;
5285
  $this->SetFColor($cor);
5286
  $save_fill = $fill; $spanfill = 1; $fill = 1;
5287
  }
5288
+ if (!empty($this->spanborddet)) {
5289
  if (strpos($contentB[$k],'L')!==false) $this->x += $this->spanborddet['L']['w'];
5290
+ if (strpos($contentB[$k],'L')===false) $this->spanborddet['L']['s'] = $this->spanborddet['L']['w'] = 0;
5291
+ if (strpos($contentB[$k],'R')===false) $this->spanborddet['R']['s'] = $this->spanborddet['R']['w'] = 0;
5292
  }
5293
 
5294
  // WORD SPACING
5299
 
5300
  if ($stringWidth==0) { $stringWidth = 0.000001; }
5301
  if ($k == $arraysize-1) {
5302
+ $stringWidth -= ( $this->charspacing / _MPDFK );
5303
  $this->Cell( $stringWidth, $lineHeight, $chunk, '', 1, '', $fill, $this->HREF, $currentx,0,0,'M', $fill, $af, $bf, true ); //mono-style line or last part (skips line)
5304
  }
5305
+ else $this->Cell( $stringWidth, $lineHeight, $chunk, '', 0, '', $fill, $this->HREF, 0, 0,0,'M', $fill, $af, $bf, true );//first or middle part
5306
 
5307
+ if (!empty($this->spanborddet)) {
5308
  if (strpos($contentB[$k],'R')!==false && $k != $arraysize-1) $this->x += $this->spanborddet['R']['w'];
5309
  }
5310
  // *********** SPAN BACKGROUND COLOR OFF - RESET BLOCK BGCOLOR ***************** //
5311
+ if (isset($spanfill) && $spanfill) {
5312
+ $fill = $save_fill; $spanfill = 0;
5313
  if ($fill) { $this->SetFColor($bcor); }
5314
  }
5315
  }
5316
+ if (!$is_table) {
5317
+ $this->maxPosR = max($this->maxPosR , ($this->w - $this->rMargin - $this->blk[$this->blklvl]['outer_right_margin']));
5318
+ $this->maxPosL = min($this->maxPosL , ($this->lMargin + $this->blk[$this->blklvl]['outer_left_margin']));
5319
  }
5320
 
5321
  // move on to the next line, reset variables, tack on saved content and current char
5329
  $this->ResetSpacing();
5330
 
5331
  $bull = $this->bulletarray;
5332
+ if (isset($bull['level']) && isset($bull['occur']) && isset($this->InlineProperties['LIST'][$bull['level']][$bull['occur']])) {
5333
+ $this->restoreInlineProperties($this->InlineProperties['LIST'][$bull['level']][$bull['occur']]);
5334
  }
5335
  if (isset($bull['level']) && isset($bull['occur']) && isset($bull['num']) && isset($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) && $this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]) { $this->restoreInlineProperties($this->InlineProperties['LISTITEM'][$bull['level']][$bull['occur']][$bull['num']]); }
5336
  if (isset($bull['font']) && $bull['font'] == 'czapfdingbats') {
5362
 
5363
  $this->restoreFont( $savedFont );
5364
  $lbw = $rbw = 0; // Border widths
5365
+ if (!empty($this->spanborddet)) {
5366
  $lbw = $this->spanborddet['L']['w'];
5367
  $rbw = $this->spanborddet['R']['w'];
5368
  }
5444
  }
5445
  $word = mb_substr($word,$i,mb_strlen($word, $this->mb_enc )-$i,$this->mb_enc );
5446
  $wordwidth = $this->GetStringWidth($word);
5447
+ $width = $maxwidth;
5448
  break;
5449
  }
5450
  }
5467
  }
5468
  $text = rtrim($text);
5469
 
5470
+ //Return -(wordsize) if word is bigger than maxwidth
5471
 
5472
  // ADDED
5473
  if ($forcewrap) { return $count; }
5474
  if (($toonarrow) && ($this->table_error_report)) {
5475
+ $this->Error("Word is too long to fit in table - ".$this->table_error_report_param);
5476
  }
5477
  if ($toonarrow) return -$biggestword;
5478
  else return $count;
5479
  }
5480
 
5481
 
5482
+ function _SetTextRendering($mode) {
5483
+ if (!(($mode == 0) || ($mode == 1) || ($mode == 2)))
5484
+ $this->Error("Text rendering mode should be 0, 1 or 2 (value : $mode)");
5485
+ $tr = ($mode.' Tr');
5486
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5487
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5488
 
5489
+ }
5490
 
5491
  function SetTextOutline($width, $col=0) {
5492
  if ($width == false) //Now resets all values
5493
+ {
5494
  $this->outline_on = false;
5495
+ $this->SetLineWidth(0.2);
5496
  $this->SetDColor($this->ConvertColor(0));
5497
+ $this->_SetTextRendering(0);
5498
+ $tr = ('0 Tr');
5499
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5500
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5501
  }
5502
  else
5503
+ {
5504
+ $this->SetLineWidth($width);
5505
  $this->SetDColor($col);
5506
+ $tr = ('2 Tr');
5507
  if($this->page>0 && ((isset($this->pageoutput[$this->page]['TextRendering']) && $this->pageoutput[$this->page]['TextRendering'] != $tr) || !isset($this->pageoutput[$this->page]['TextRendering']) || $this->keep_block_together)) { $this->_out($tr); }
5508
  $this->pageoutput[$this->page]['TextRendering'] = $tr;
5509
+ }
5510
  }
5511
 
5512
  function Image($file,$x,$y,$w=0,$h=0,$type='',$link='',$paint=true, $constrain=true, $watermark=false, $shownoimg=true, $allowvector=true) {
5513
  if(!file_exists($file))
5514
  {
5515
  return false;
5516
+ }
5517
 
5518
  $orig_srcpath = $file;
5519
  $this->GetFullPath($file);
5521
  $info=$this->_getImage($file, true, $allowvector, $orig_srcpath );
5522
  if(!$info && $paint) {
5523
  $info = $this->_getImage($this->noImageFile);
5524
+ if ($info) {
5525
+ $file = $this->noImageFile;
5526
  $w = ($info['w'] * (25.4/$this->dpi)); // 14 x 16px
5527
  $h = ($info['h'] * (25.4/$this->dpi)); // 14 x 16px
5528
  }
5530
  if(!$info) return false;
5531
  //Automatic width and height calculation if needed
5532
  if($w==0 and $h==0) {
5533
+ if ($info['type']=='svg') {
5534
  // returned SVG units are pts
5535
  // divide by k to get user units (mm)
5536
  $w = abs($info['w'])/_MPDFK;
5542
  $h=($info['h']/_MPDFK) * (72/$this->img_dpi);
5543
  }
5544
  }
5545
+ if($w==0) $w=abs($h*$info['w']/$info['h']);
5546
+ if($h==0) $h=abs($w*$info['h']/$info['w']);
5547
 
5548
 
5549
  if ($constrain) {
5580
  }
5581
  } // end of IF constrain
5582
 
5583
+ if ($info['type']=='svg') {
5584
  $sx = $w*_MPDFK / $info['w'];
5585
  $sy = -$h*_MPDFK / $info['h'];
5586
  $outstring = sprintf('q %.3F 0 0 %.3F %.3F %.3F cm /FO%d Do Q', $sx, $sy, $x*_MPDFK-$sx*$info['x'], (($this->h-$y)*_MPDFK)-$sy*$info['y'], $info['i']);
5587
  }
5588
+ else {
5589
  $outstring = sprintf("q %.3F 0 0 %.3F %.3F %.3F cm /I%d Do Q",$w*_MPDFK,$h*_MPDFK,$x*_MPDFK,($this->h-($y+$h))*_MPDFK,$info['i']);
5590
  }
5591
 
5635
 
5636
  // NB $x is only used when paint=true
5637
  // Lmargin not used
5638
+ $w = 0;
5639
  if (isset($objattr['width'])) { $w = $objattr['width']/$k; }
5640
  $h = 0;
5641
  if (isset($objattr['height'])) { $h = abs($objattr['height']/$k); }
5723
  $objattr['ID'] = $info['i'];
5724
  }
5725
 
5726
+ if ($type == 'input' && $objattr['subtype'] == 'IMAGE') {
5727
  $img_w = $w - $extraWidth ;
5728
  $img_h = $h - $extraHeight ;
5729
  $objattr['BORDER-WIDTH'] = $img_w + (($objattr['border_left']['w']/$k + $objattr['border_right']['w']/$k)/2) ;
5762
  }
5763
 
5764
  if ($type == 'hr') {
5765
+ if ($is_table) {
5766
+ $objattr['INNER-WIDTH'] = $maxWidth * $objattr['W-PERCENT']/100;
5767
+ $objattr['width'] = $objattr['INNER-WIDTH'];
5768
  $w = $maxWidth;
5769
  }
5770
+ else {
5771
  if ($w>$maxWidth) { $w = $maxWidth; }
5772
+ $objattr['INNER-WIDTH'] = $w;
5773
  $w = $maxWidth;
5774
  }
5775
  }
5858
  // otherwise, now uses PaintDivBB()
5859
  if (!$this->ColActive && !$this->keep_block_together && !$this->kwt) {
5860
  if ($move_y && !$this->ColActive) { $this->y += $h; }
5861
+ return;
5862
  }
5863
 
5864
  if ($level == -3) { $level = $this->blklvl; }
5888
  $last_fc = $this->FillColor;
5889
  }
5890
  // Reset current block fill
5891
+ if (isset($this->blk[$this->blklvl]['bgcolorarray'])) {
5892
  $bcor = $this->blk[$this->blklvl]['bgcolorarray'];
5893
  $this->SetFColor($bcor);
5894
  }
5937
  if($this->state < 3) $this->Close();
5938
  // fn. error_get_last is only in PHP>=5.2
5939
  if ($this->debug && function_exists('error_get_last') && error_get_last()) {
5940
+ $e = error_get_last();
5941
  if (($e['type'] < 2048 && $e['type'] != 8) || (intval($e['type']) & intval(ini_get("error_reporting")))) {
5942
+ echo "<p>Error message detected - PDF file generation aborted.</p>";
5943
  echo $e['message'].'<br />';
5944
  echo 'File: '.$e['file'].'<br />';
5945
  echo 'Line: '.$e['line'].'<br />';
5946
+ exit;
5947
  }
5948
  }
5949
 
6003
  header('Content-Length: '.strlen($this->buffer));
6004
  }
6005
  header('Content-disposition: inline; filename="'.$name.'"');
6006
+ header('Cache-Control: public, must-revalidate, max-age=0');
6007
  header('Pragma: public');
6008
+ header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
6009
  header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
6010
  }
6011
  echo $this->buffer;
6050
  // Delete any files in tmp/ directory that are >1 hrs old
6051
  $interval = 3600;
6052
  if ($handle = opendir(preg_replace('/\/$/','',_MPDF_TEMP_PATH))) {
6053
+ while (false !== ($file = readdir($handle))) {
6054
  if (!is_dir($file) && ((filemtime(_MPDF_TEMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { // mPDF 5.4.19
6055
+ unlink(_MPDF_TEMP_PATH.$file);
6056
  }
6057
  }
6058
+ closedir($handle);
6059
  }
6060
  //==============================================================================================================
6061
 
6117
  // Select unused fonts (usually default font)
6118
  $unused = array();
6119
  foreach($this->fonts as $fk=>$font) {
6120
+ if (!$font['used'] && ($font['type']=='TTF')) {
6121
  $unused[] = $fk;
6122
  }
6123
  }
6127
  {
6128
  $thispage = $this->pages[$n];
6129
  unset($this->pages[$n]);
6130
+ if(isset($this->OrientationChanges[$n])) {
6131
  $hPt=$this->pageDim[$n]['w']*_MPDFK;
6132
  $wPt=$this->pageDim[$n]['h']*_MPDFK;
6133
  $owidthPt_LR = $this->pageDim[$n]['outer_width_TB']*_MPDFK;
6134
  $owidthPt_TB = $this->pageDim[$n]['outer_width_LR']*_MPDFK;
6135
  }
6136
+ else {
6137
  $wPt=$this->pageDim[$n]['w']*_MPDFK;
6138
  $hPt=$this->pageDim[$n]['h']*_MPDFK;
6139
  $owidthPt_LR = $this->pageDim[$n]['outer_width_LR']*_MPDFK;
6143
  foreach($unused as $fk) {
6144
  if ($this->fonts[$fk]['sip'] || $this->fonts[$fk]['smp']) {
6145
  foreach($this->fonts[$fk]['subsetfontids'] AS $k => $fid) {
6146
+ $thispage = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$thispage);
6147
  }
6148
  }
6149
+ else {
6150
+ $thispage = preg_replace('/\s\/F'.$this->fonts[$fk]['i'].' \d[\d.]* Tf\s/is',' ',$thispage);
6151
  }
6152
  }
6153
  //Replace number of pages
6167
  $x2 = $this->GetStringWidth($nb);
6168
  $xadj = $x1 - $x2;
6169
  if ($pos=='C') { $xadj /= 2; }
6170
+ $rep = sprintf(' q 1 0 0 1 %.3F 0 cm ', $xadj*_MPDFK);
6171
  $thispage = str_replace($m[0][$hi], $rep, $thispage);
6172
  }
6173
  }
6178
  $r = '';
6179
  $nstr = "$nb";
6180
  for($i=0;$i<strlen($nstr);$i++) {
6181
+ $r .= sprintf("%02s", strtoupper(dechex(intval($nstr[$i])+48)));
6182
  }
6183
  $thispage=str_replace($this->aliasNbPgHex,$r,$thispage);
6184
 
6186
  //Replace number of pages in group
6187
  if(!empty($this->aliasNbPgGp)) {
6188
  if (!$this->onlyCoreFonts) { $s1 = $this->UTF8ToUTF16BE($this->aliasNbPgGp, false); }
6189
+ $s2 = $this->aliasNbPgGp;
6190
  $nbt = $this->docPageNumTotal($n);
6191
+ if (!$this->onlyCoreFonts) { $r1 = $this->UTF8ToUTF16BE($nbt, false); }
6192
  $r2 = $nbt;
6193
  if (preg_match_all('/{mpdfheadernbpggp (C|R) ff=(\S*) fs=(\S*) fz=(.*?)}/',$thispage,$m)) {
6194
  for($hi=0;$hi<count($m[0]);$hi++) {
6201
  $x2 = $this->GetStringWidth($nbt);
6202
  $xadj = $x1 - $x2;
6203
  if ($pos=='C') { $xadj /= 2; }
6204
+ $rep = sprintf(' q 1 0 0 1 %.3F 0 cm ', $xadj*_MPDFK);
6205
  $thispage = str_replace($m[0][$hi], $rep, $thispage);
6206
  }
6207
  }
6212
  $r = '';
6213
  $nstr = "$nbt";
6214
  for($i=0;$i<strlen($nstr);$i++) {
6215
+ $r .= sprintf("%02s", strtoupper(dechex(intval($nstr[$i])+48)));
6216
  }
6217
  $thispage=str_replace($this->aliasNbPgGpHex,$r,$thispage);
6218
 
6237
  $y1 = $wPt-$owidthPt_LR+$bleedMargin;
6238
  $this->_out(sprintf('/BleedBox [%.3F %.3F %.3F %.3F]', $x0, $y0, $x1, $y1));
6239
  }
6240
+ $this->_out(sprintf('/TrimBox [%.3F %.3F %.3F %.3F]', $owidthPt_TB, $owidthPt_LR, ($hPt-$owidthPt_TB), ($wPt-$owidthPt_LR)));
6241
  if (isset($this->OrientationChanges[$n]) && $this->displayDefaultOrientation) {
6242
  if ($this->DefOrientation=='P') { $this->_out('/Rotate 270'); }
6243
  else { $this->_out('/Rotate 90'); }
6254
  $y1 = $hPt-$owidthPt_TB+$bleedMargin;
6255
  $this->_out(sprintf('/BleedBox [%.3F %.3F %.3F %.3F]', $x0, $y0, $x1, $y1));
6256
  }
6257
+ $this->_out(sprintf('/TrimBox [%.3F %.3F %.3F %.3F]', $owidthPt_LR, $owidthPt_TB, ($wPt-$owidthPt_LR), ($hPt-$owidthPt_TB)));
6258
  }
6259
  $this->_out('/Resources 2 0 R');
6260
 
6261
  // Important to keep in RGB colorSpace when using transparency
6262
+ if (!$this->PDFA && !$this->PDFX) {
6263
  if ($this->restrictColorSpace == 3)
6264
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceCMYK >> ');
6265
  else if ($this->restrictColorSpace == 1)
6266
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceGray >> ');
6267
+ else
6268
  $this->_out('/Group << /Type /Group /S /Transparency /CS /DeviceRGB >> ');
6269
  }
6270
 
6273
 
6274
  if ($annotsnum || $formsnum) {
6275
  $s = '/Annots [ ';
6276
+ for($i=0;$i<$annotsnum;$i++) {
6277
  $s .= ($annotid + $i) . ' 0 R ';
6278
+ }
6279
  $annotid += $annotsnum;
6280
  $s .= '] ';
6281
  $this->_out($s);
6375
  $used = true;
6376
  $asSubset = false;
6377
  foreach($this->fonts AS $k=>$f) {
6378
+ if ($f['fontkey'] == $fontkey && $f['type']=='TTF') {
6379
+ $used = $f['used'];
6380
  if ($used) {
6381
  $nChars = (ord($f['cw'][0]) << 8) + ord($f['cw'][1]);
6382
  $usage = intval(count($f['subset'])*100 / $nChars);
6481
  }
6482
  $this->_out('>>');
6483
  $this->_out('endobj');
6484
+ }
6485
  // TrueType embedded SUBSETS for SIP (CJK extB containing Supplementary Ideographic Plane 2)
6486
  // Or Unicode Plane 1 - Supplementary Multilingual Plane
6487
  else if ($type=='TTF' && ($font['sip'] || $font['smp'])) {
6501
  $widthstring = '';
6502
  $toUnistring = '';
6503
  foreach($font['subsets'][$sfid] AS $cp=>$u) {
6504
+ $w = $this->_getCharWidth($font['cw'], $u);
6505
  if ($w !== false) {
6506
  $widthstring .= $w.' ';
6507
  }
6577
  $this->_putstream($toUni);
6578
  $this->_out('endobj');
6579
 
6580
+ //Font file
6581
  $this->_newobj();
6582
  $this->_out('<</Length '.strlen($fontstream));
6583
  $this->_out('/Filter /FlateDecode');
6587
  $this->_out('endobj');
6588
  } // foreach subset
6589
  unset($ttf);
6590
+ }
6591
  // TrueType embedded SUBSETS or FULL
6592
  else if ($type=='TTF') {
6593
  $this->fonts[$k]['n']=$this->n+1;
6611
  $this->_out('<</Type /Font');
6612
  $this->_out('/Subtype /Type0');
6613
  $this->_out('/BaseFont /'.$fontname.'');
6614
+ $this->_out('/Encoding /Identity-H');
6615
  $this->_out('/DescendantFonts ['.($this->n + 1).' 0 R]');
6616
  $this->_out('/ToUnicode '.($this->n + 2).' 0 R');
6617
  $this->_out('>>');
6623
  $this->_out('<</Type /Font');
6624
  $this->_out('/Subtype /CIDFontType2');
6625
  $this->_out('/BaseFont /'.$fontname.'');
6626
+ $this->_out('/CIDSystemInfo '.($this->n + 2).' 0 R');
6627
  $this->_out('/FontDescriptor '.($this->n + 3).' 0 R');
6628
  if (isset($font['desc']['MissingWidth'])){
6629
+ $this->_out('/DW '.$font['desc']['MissingWidth'].'');
6630
  }
6631
 
6632
  if (!$asSubset && file_exists(_MPDF_TTFONTDATAPATH.$font['fontkey'].'.cw')) {
6671
 
6672
  // CIDSystemInfo dictionary
6673
  $this->_newobj();
6674
+ $this->_out('<</Registry (Adobe)');
6675
  $this->_out('/Ordering (UCS)');
6676
  $this->_out('/Supplement 0');
6677
  $this->_out('>>');
6742
  $this->_putstream($cidtogidmap);
6743
  $this->_out('endobj');
6744
 
6745
+ //Font file
6746
  if ($asSubset ) {
6747
  $this->_newobj();
6748
  $this->_out('<</Length '.strlen($fontstream));
6753
  $this->_out('endobj');
6754
  unset($ttf);
6755
  }
6756
+ }
6757
  else { $this->Error('Unsupported font type: '.$type.' ('.$name.')'); }
6758
  }
6759
  }
7152
  $this->_newobj();
7153
  if ($this->ICCProfile)
7154
  $s = file_get_contents(_MPDF_PATH.'iccprofiles/'.$this->ICCProfile.'.icc');
7155
+ else
7156
  $s = file_get_contents(_MPDF_PATH.'iccprofiles/sRGB_IEC61966-2-1.icc');
7157
  if ($this->compress) { $s = gzcompress($s); }
7158
  $this->_out('<<');
7186
  if(is_int(strpos($this->DisplayPreferences,'FullScreen'))) $this->_out('/PageMode /FullScreen');
7187
 
7188
  // Metadata
7189
+ if ($this->PDFA || $this->PDFX) {
7190
  $this->_out('/Metadata '.$this->MetadataRoot.' 0 R');
7191
  }
7192
  // OutputIntents
7193
+ if ($this->PDFA || $this->PDFX || $this->ICCProfile) {
7194
  $this->_out('/OutputIntents ['.$this->OutputIntentRoot.' 0 R]');
7195
  }
7196
 
7207
  if(is_int(strpos($this->DisplayPreferences,'CenterWindow'))) $this->_out('/CenterWindow true');
7208
  if(is_int(strpos($this->DisplayPreferences,'FitWindow'))) $this->_out('/FitWindow true');
7209
  // /PrintScaling is PDF 1.6 spec.
7210
+ if(is_int(strpos($this->DisplayPreferences,'NoPrintScaling')) && !$this->PDFA && !$this->PDFX)
7211
  $this->_out('/PrintScaling /None');
7212
  if($this->directionality == 'rtl') $this->_out('/Direction /R2L');
7213
  // /Duplex is PDF 1.7 spec.
7253
  function _enddoc() {
7254
  // Remove references to unused fonts (usually default font)
7255
  foreach($this->fonts as $fk=>$font) {
7256
+ if (!$font['used'] && ($font['type']=='TTF')) {
7257
  if ($font['sip'] || $font['smp']) {
7258
  foreach($font['subsetfontids'] AS $k => $fid) {
7259
+ foreach($this->pages AS $pn=>$page) {
7260
+ $this->pages[$pn] = preg_replace('/\s\/F'.$fid.' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]);
7261
  }
7262
  }
7263
  }
7264
+ else {
7265
+ foreach($this->pages AS $pn=>$page) {
7266
+ $this->pages[$pn] = preg_replace('/\s\/F'.$font['i'].' \d[\d.]* Tf\s/is',' ',$this->pages[$pn]);
7267
  }
7268
  }
7269
  }
7271
 
7272
  // mPDF 5.6.01 - LAYERS
7273
  if (count($this->layers)) {
7274
+ foreach($this->pages AS $pn=>$page) {
7275
  preg_match_all('/\/OCZ-index \/ZI(\d+) BDC(.*?)(EMCZ)-index/is',$this->pages[$pn],$m1);
7276
  preg_match_all('/\/OCBZ-index \/ZI(\d+) BDC(.*?)(EMCBZ)-index/is',$this->pages[$pn],$m2);
7277
  preg_match_all('/\/OCGZ-index \/ZI(\d+) BDC(.*?)(EMCGZ)-index/is',$this->pages[$pn],$m3);
7286
  if ($m[3][$i]=='EMCZ') $key +=2; // background first then gradient then normal
7287
  else if ($m[3][$i]=='EMCGZ') $key +=1;
7288
  $sortarr[$i] = $key;
7289
+ }
7290
  asort($sortarr);
7291
  foreach($sortarr AS $i=>$k) {
7292
  $this->pages[$pn] = str_replace($m[0][$i],'',$this->pages[$pn] );
7293
  $this->pages[$pn] .= "\n".$m[0][$i]."\n";
7294
+ }
7295
+ $this->pages[$pn] = preg_replace('/\/OC[BG]{0,1}Z-index \/ZI(\d+) BDC/is','/OC /ZI\\1 BDC ',$this->pages[$pn]);
7296
+ $this->pages[$pn] = preg_replace('/EMC[BG]{0,1}Z-index/is','EMC',$this->pages[$pn]);
7297
  }
7298
  }
7299
  }
7340
  }
7341
 
7342
  function _beginpage($orientation,$mgl='',$mgr='',$mgt='',$mgb='',$mgh='',$mgf='',$ohname='',$ehname='',$ofname='',$efname='',$ohvalue=0,$ehvalue=0,$ofvalue=0,$efvalue=0,$pagesel='',$newformat='') {
7343
+ if (!($pagesel && $this->page==1 && (sprintf("%0.4f", $this->y)==sprintf("%0.4f", $this->tMargin)))) {
7344
  $this->page++;
7345
  $this->pages[$this->page]='';
7346
  }
7399
  $this->pageDim[$this->page]['w']=$this->w ;
7400
  $this->pageDim[$this->page]['h']=$this->h ;
7401
 
7402
+ $this->pageDim[$this->page]['outer_width_LR'] = isset($this->page_box['outer_width_LR']) ? $this->page_box['outer_width_LR'] : 0;
7403
+ $this->pageDim[$this->page]['outer_width_TB'] = isset($this->page_box['outer_width_TB']) ? $this->page_box['outer_width_TB'] : 0;
7404
  if (!isset($this->page_box['outer_width_LR']) && !isset($this->page_box['outer_width_TB'])) {
7405
  $this->pageDim[$this->page]['bleedMargin'] = 0;
7406
  }
7437
  $this->FontFamily='';
7438
 
7439
  // HEADERS AND FOOTERS
7440
+ if ($ohvalue<0 || strtoupper($ohvalue)=='OFF') {
7441
+ $this->HTMLHeader = '';
7442
+ $this->headerDetails['odd'] = array();
7443
  }
7444
  else if ($ohname && $ohvalue>0) {
7445
+ if (isset($this->pageheaders[$ohname])) { $this->headerDetails['odd'] = $this->pageheaders[$ohname]; }
7446
  else if ($ohname!='_default') { $this->headerDetails['odd'] = array(); }
7447
+ $this->HTMLHeader = '';
7448
  }
7449
 
7450
+ if ($ehvalue<0 || strtoupper($ehvalue)=='OFF') {
7451
+ $this->HTMLHeaderE = '';
7452
+ $this->headerDetails['even'] = array();
7453
  }
7454
  else if ($ehname && $ehvalue>0) {
7455
  if (isset($this->pageheaders[$ehname])) { $this->headerDetails['even'] = $this->pageheaders[$ehname]; }
7456
  else if ($ehname!='_default') { $this->headerDetails['even'] = array(); }
7457
+ $this->HTMLHeaderE = '';
7458
  }
7459
 
7460
+ if ($ofvalue<0 || strtoupper($ofvalue)=='OFF') {
7461
+ $this->HTMLFooter = '';
7462
+ $this->footerDetails['odd'] = array();
7463
  }
7464
  else if ($ofname && $ofvalue>0) {
7465
  if (isset($this->pagefooters[$ofname])) { $this->footerDetails['odd'] = $this->pagefooters[$ofname]; }
7466
  else if ($ofname!='_default') { $this->footerDetails['odd'] = array(); }
7467
+ $this->HTMLFooter = '';
7468
  }
7469
 
7470
+ if ($efvalue<0 || strtoupper($efvalue)=='OFF') {
7471
+ $this->HTMLFooterE = '';
7472
+ $this->footerDetails['even'] = array();
7473
  }
7474
  else if ($efname && $efvalue>0) {
7475
+ if (isset($this->pagefooters[$efname])) { $this->footerDetails['even'] = $this->pagefooters[$efname]; }
7476
  else if ($efname!='_default') { $this->footerDetails['even'] = array(); }
7477
+ $this->HTMLFooterE = '';
7478
  }
7479
 
7480
 
7494
  $this->y=$this->tMargin;
7495
  }
7496
 
7497
+ /*
7498
+ * Blue Liquid Designs Edit
7499
+ * Add isset() to if statement as it throws errors
7500
+ */
7501
  function _setAutoHeaderHeight(&$det, &$htmlh) {
7502
  if ($this->setAutoTopMargin=='pad') {
7503
  if (isset($htmlh['h']) && $htmlh['h']) { $h = $htmlh['h']; }
7514
  }
7515
 
7516
 
7517
+ /*
7518
+ * Blue Liquid Designs Edit
7519
+ * Add isset() to if statement as it throws errors
7520
  */
7521
  function _setAutoFooterHeight(&$det, &$htmlf) {
7522
  if ($this->setAutoBottomMargin=='pad') {
7576
  function _dounderline($x,$y,$txt) {
7577
  // Now print line exactly where $y secifies - called from Text() and Cell() - adjust position there
7578
  // WORD SPACING
7579
+ $w =($this->GetStringWidth($txt)*_MPDFK) + ($this->charspacing * mb_strlen( $txt, $this->mb_enc ))
7580
  + ( $this->ws * mb_substr_count( $txt, ' ', $this->mb_enc ));
7581
  //Draw a line
7582
  return sprintf('%.3F %.3F m %.3F %.3F l S',$x*_MPDFK,($this->h-$y)*_MPDFK,($x*_MPDFK)+$w,($this->h-$y)*_MPDFK);
7593
  }
7594
 
7595
 
7596
+ function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=false) {
7597
  // firsttime i.e. whether to add to this->images - use false when calling iteratively
7598
  // Image Data passed directly as var:varname
7599
+ if (preg_match('/var:\s*(.*)/',$file, $v)) {
7600
  $data = $this->$v[1];
7601
  $file = md5($data);
7602
  }
7603
  // mPDF 5.5.13
7604
+ if (preg_match('/data:image\/(gif|jpeg|png);base64,(.*)/',$file, $v)) {
7605
  $type = $v[1];
7606
  $data = base64_decode($v[2]);
7607
  $file = md5($data);
7617
  else if ($orig_srcpath && isset($this->formobjects[$orig_srcpath])) { $file=$orig_srcpath; return $this->formobjects[$file]; }
7618
  else if (isset($this->formobjects[$file])) { return $this->formobjects[$file]; }
7619
  // Save re-trying image URL's which have already failed
7620
+ else if ($firsttime && isset($this->failedimages[$file])) { return $this->_imageError($file, $firsttime, ''); }
7621
  if (empty($data)) {
7622
  $type = '';
7623
  $data = '';
7624
 
7625
  if ($orig_srcpath && $this->basepathIsLocal && $check = @fopen($orig_srcpath,"rb")) {
7626
+ fclose($check);
7627
  $file=$orig_srcpath;
7628
  $data = file_get_contents($file);
7629
  $type = $this->_imageTypeFromString($data);
7630
  }
7631
  if (!$data && $check = @fopen($file,"rb")) {
7632
+ fclose($check);
7633
  $data = file_get_contents($file);
7634
  $type = $this->_imageTypeFromString($data);
7635
  }
7645
  {
7646
  /* Blue Liquid Designs Edit
7647
  Ensure Wordpress compatibility
7648
+ */
7649
  if( !class_exists( 'WP_Http' ) ) {
7650
  include_once( ABSPATH . WPINC. '/class-http.php' );
7651
  }
7654
  if ( !is_wp_error($result) ) {
7655
  $data = $result['body'];
7656
  $type = $this->_imageTypeFromString($data);
7657
+ }
7658
  }
7659
 
7660
  }
7661
  if (!$data) { return $this->_imageError($file, $firsttime, 'Could not find image file'); }
7662
+ if (empty($type)) { $type = $this->_imageTypeFromString($data); }
7663
  if (($type == 'wmf' || $type == 'svg') && !$allowvector) { return $this->_imageError($file, $firsttime, 'WMF or SVG image file not supported in this context'); }
7664
 
7665
  // SVG
7685
  if (!$hdr) { return $this->_imageError($file, $firsttime, 'Error parsing JPG header'); }
7686
  $a = $this->_jpgDataFromHeader($hdr);
7687
  $j = strpos($data,'JFIF');
7688
+ if ($j) {
7689
  //Read resolution
7690
  $unitSp=ord(substr($data,($j+7),1));
7691
  if ($unitSp > 0) {
7743
  // PNG
7744
  else if ($type == 'png') {
7745
  //Check signature
7746
+ if(substr($data,0,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
7747
+ return $this->_imageError($file, $firsttime, 'Error parsing PNG identifier');
7748
  }
7749
  //Read header chunk
7750
+ if(substr($data,12,4)!='IHDR') {
7751
+ return $this->_imageError($file, $firsttime, 'Incorrect PNG file (no IHDR block found)');
7752
  }
7753
 
7754
  $w=$this->_fourbytes2int(substr($data,16,4));
7755
  $h=$this->_fourbytes2int(substr($data,20,4));
7756
  $bpc=ord(substr($data,24,1));
7757
  $errpng = false;
7758
+ $pngalpha = false;
7759
  if($bpc>8) { $errpng = 'not 8-bit depth'; }
7760
  $ct=ord(substr($data,25,1));
7761
  if($ct==0) { $colspace='DeviceGray'; }
7762
  elseif($ct==2) { $colspace='DeviceRGB'; }
7763
  elseif($ct==3) { $colspace='Indexed'; }
7764
  elseif($ct==4) { $colspace='DeviceGray'; $errpng = 'alpha channel'; $pngalpha = true; }
7765
+ else { $colspace='DeviceRGB'; $errpng = 'alpha channel'; $pngalpha = true; }
7766
  if(ord(substr($data,26,1))!=0) { $errpng = 'compression method'; }
7767
  if(ord(substr($data,27,1))!=0) { $errpng = 'filter method'; }
7768
  if(ord(substr($data,28,1))!=0) { $errpng = 'interlaced file'; }
7769
  $j = strpos($data,'pHYs');
7770
+ if ($j) {
7771
  //Read resolution
7772
  $unitSp=ord(substr($data,($j+12),1));
7773
  if ($unitSp == 1) {
7831
  }
7832
  // create temp alpha file
7833
  $tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.RAND(1,10000).'.png';
7834
+ if (!is_writable($tempfile_alpha)) {
7835
+ ob_start();
7836
  $check = @imagepng($imgalpha);
7837
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7838
  imagedestroy($imgalpha);
7845
  // create temp image file
7846
  $minfo = $this->_getImage($this->_tempimglnk, false);
7847
  if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
7848
+ ob_start();
7849
  $check = @imagepng($imgplain);
7850
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7851
  $this->_tempimg = ob_get_contents();
7898
  }
7899
  else { // No alpha/transparency set
7900
  imagealphablending($im, false);
7901
+ imagesavealpha($im, false);
7902
  imageinterlace($im, false);
7903
+ if (!is_writable($tempfile)) {
7904
+ ob_start();
7905
  $check = @imagepng($im);
7906
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
7907
  $this->_tempimg = ob_get_contents();
7916
  if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile.') parsing PNG image ('.$errpng.')'); }
7917
  imagedestroy($im);
7918
  $info = $this->_getImage($tempfile, false) ;
7919
+ unlink($tempfile );
7920
  if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse PNG image'); }
7921
  }
7922
  if ($ppUx) { $info['set-dpi'] = $ppUx; }
7991
  if ($im) {
7992
  $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png';
7993
  imagealphablending($im, false);
7994
+ imagesavealpha($im, false);
7995
  imageinterlace($im, false);
7996
+ if (!is_writable($tempfile)) {
7997
+ ob_start();
7998
  $check = @imagepng($im);
7999
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse GIF image'); }
8000
  $this->_tempimg = ob_get_contents();
8022
  else { return $this->_imageError($file, $firsttime, 'Error creating GD image file from GIF image'); }
8023
  }
8024
 
8025
+ if (!class_exists('gif', false)) {
8026
+ include_once(_MPDF_PATH.'classes/gif.php');
8027
  }
8028
  $gif=new CGIF();
8029
 
8062
  $gif->ClearData();
8063
 
8064
  if($colspace=='Indexed' and empty($pal)) {
8065
+ return $this->_imageError($file, $firsttime, 'Error parsing GIF image - missing colour palette');
8066
  }
8067
  if ($this->compress) {
8068
  $gifdata=gzcompress($gifdata);
8069
  $info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'f'=>'FlateDecode', 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
8070
+ }
8071
  else {
8072
  $info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
8073
+ }
8074
  $info['type']='gif';
8075
  if ($firsttime) {
8076
  $info['i']=count($this->images)+1;
8089
  if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); }
8090
  $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.RAND(1,10000).'.png';
8091
  imagealphablending($im, false);
8092
+ imagesavealpha($im, false);
8093
  imageinterlace($im, false);
8094
  $check = @imagepng($im, $tempfile);
8095
  if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse unknown image type'); }
8106
  }
8107
  }
8108
 
8109
+ return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised');
8110
  }
8111
  //==============================================================
8112
  function _convImage(&$data, $colspace, $targetcs, $w, $h, $dpi, $mask) {
8120
  //Read transparency info
8121
  $trns=array();
8122
  $trnsrgb = false;
8123
+ if (!$this->PDFA && !$this->PDFX) {
8124
  $p = strpos($data,'tRNS');
8125
+ if ($p) {
8126
  $n=$this->_fourbytes2int(substr($data,($p-4),4));
8127
+ $t = substr($data,($p+4),$n);
8128
+ if ($colspace=='DeviceGray') {
8129
+ $trns=array(ord(substr($t,1,1)));
8130
  $trnsrgb = array($trns[0],$trns[0],$trns[0]);
8131
  }
8132
+ else if ($colspace=='DeviceRGB') {
8133
+ $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
8134
  $trnsrgb = $trns;
8135
  if ($targetcs=='DeviceCMYK') {
8136
  $col = $this->rgb2cmyk(array(3,$trns[0],$trns[1],$trns[2]));
8227
  $info = array('w'=>$w,'h'=>$h,'cs'=>$targetcs,'bpc'=>8,'f'=>'FlateDecode','data'=>$imgdata, 'type'=>'png',
8228
  'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
8229
  if ($dpi) { $info['set-dpi'] = $dpi; }
8230
+ if ($mask) {
8231
+ $mimgdata = gzcompress($mimgdata);
8232
  $minfo = array('w'=>$w,'h'=>$h,'cs'=>'DeviceGray','bpc'=>8,'f'=>'FlateDecode','data'=>$mimgdata, 'type'=>'png',
8233
  'parms'=>'/DecodeParms <</Colors '.$ncols.' /BitsPerComponent 8 /Columns '.$w.'>>');
8234
  if ($dpi) { $minfo['set-dpi'] = $dpi; }
8324
 
8325
  function _imageTypeFromString(&$data) {
8326
  $type = '';
8327
+ if (substr($data, 6, 4)== 'JFIF' || substr($data, 6, 4)== 'Exif') {
8328
+ $type = 'jpeg';
8329
  }
8330
+ else if (substr($data, 0, 6)== "GIF87a" || substr($data, 0, 6)== "GIF89a") {
8331
  $type = 'gif';
8332
  }
8333
+ else if (substr($data, 0, 8)== chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
8334
  $type = 'png';
8335
  }
8336
+ else if (preg_match('/<svg.*<\/svg>/is',$data)) {
8337
  $type = 'svg';
8338
  }
8339
  // BMP images
8340
+ else if (substr($data, 0, 2)== "BM") {
8341
  $type = 'bmp';
8342
  }
8343
  return $type;
8409
  $this->headerbuffer.= $s."\n";
8410
  }
8411
  else if ($this->table_rotate && !$this->processingHeader && !$this->processingFooter) {
8412
+ // Captures eveything in buffer for rotated tables;
8413
  $this->tablebuffer .= $s . "\n";
8414
  }
8415
  else if ($this->kwt && !$this->processingHeader && !$this->processingFooter) {
8416
+ // Captures eveything in buffer for keep-with-table (h1-6);
8417
  $this->kwt_buffer[] = array(
8418
+ 's' => $s, // Text string to output
8419
+ 'x' => $this->x, // x when printed
8420
+ 'y' => $this->y, // y when printed
8421
  );
8422
  }
8423
  else if (($this->keep_block_together) && !$this->processingHeader && !$this->processingFooter) {
8425
  $this->ktBlock[$this->page]['bottom_margin'] = $this->y;
8426
  }
8427
 
8428
+ // Captures eveything in buffer;
8429
+ if (preg_match('/q \d+\.\d\d+ 0 0 (\d+\.\d\d+) \d+\.\d\d+ \d+\.\d\d+ cm \/(I|FO)\d+ Do Q/',$s,$m)) { // Image data
8430
  $h = ($m[1]/_MPDFK);
8431
  // Update/overwrite the lowest bottom of printing y value for Keep together block
8432
  $this->ktBlock[$this->page]['bottom_margin'] = $this->y+$h;
8438
  if ($h < 0) { $h = -$h; }
8439
  $this->divbuffer[] = array(
8440
  'page' => $this->page,
8441
+ 's' => $s, // Text string to output
8442
+ 'x' => $this->x, // x when printed
8443
  'y' => $this->y, // y when printed (after column break)
8444
  'h' => $h // actual y at bottom when printed = y+h
8445
  );
8569
  $orig_fid = $this->CurrentFont['subsetfontids'][0];
8570
  $last_fid = $this->CurrentFont['subsetfontids'][0];
8571
  foreach($unicode as $c) {
8572
+ if ($c == 7 || $c == 8) {
8573
  if ($orig_fid != $last_fid) {
8574
  $ret .= '> Tj /F'.$orig_fid.' '.$this->FontSizePt.' Tf <';
8575
  $last_fid = $orig_fid;
8619
 
8620
  // Converts UTF-8 strings to UTF16-BE.
8621
  function UTF8ToUTF16BE($str, $setbom=true) {
8622
+ if ($this->checkSIP && preg_match("/([\x{20000}-\x{2FFFF}])/u", $str)) {
8623
  if (!in_array($this->currentfontfamily, array('gb','big5','sjis','uhc','gbB','big5B','sjisB','uhcB','gbI','big5I','sjisI','uhcI',
8624
  'gbBI','big5BI','sjisBI','uhcBI'))) {
8625
  $str = preg_replace("/[\x{20000}-\x{2FFFF}]/u", chr(0), $str);
8626
  }
8627
  }
8628
+ if ($this->checkSMP && preg_match("/([\x{10000}-\x{1FFFF}])/u", $str )) {
8629
  $str = preg_replace("/[\x{10000}-\x{1FFFF}]/u", chr(0), $str );
8630
  }
8631
  $outstr = ""; // string to be returned
8654
  if ($this->onlyCoreFonts) { return false; }
8655
  if (!$af && $af !== 0) { $af = AUTOFONT_ALL; }
8656
  $this->autoFontGroups = $af;
8657
+ if ($this->autoFontGroups ) {
8658
  $this->useLang = true;
8659
  }
8660
  }
8691
 
8692
 
8693
  function SetDirectionality($dir='ltr') {
8694
+ $this->directionality = 'ltr';
8695
  $this->defaultAlign = 'L';
8696
  $this->defaultTableAlign = 'L';
8697
  $this->CSS['BODY']['DIRECTION'] = $this->directionality;
8709
  function SetLineHeight($FontPt='',$spacing = '') {
8710
  if ($this->shrin_k > 1) { $k = $this->shrin_k; }
8711
  else { $k = 1; }
8712
+ if ($spacing > 0) {
8713
+ if (preg_match('/mm/',$spacing)) {
8714
  $this->lineheight = ($spacing + 0.0) / $k; // convert to number
8715
  }
8716
+ else {
8717
  if ($FontPt) { $this->lineheight = (($FontPt/_MPDFK) *$spacing); }
8718
  else { $this->lineheight = (($this->FontSizePt/_MPDFK) *$spacing); }
8719
  }
8728
  if ($this->shrin_k > 1) { $k = $this->shrin_k; }
8729
  else { $k = 1; }
8730
  if (!$fs) { $fs = $this->FontSize; }
8731
+ if (preg_match('/mm/',$lh)) {
8732
  return (($lh + 0.0) / $k); // convert to number
8733
  }
8734
+ else if ($lh > 0) {
8735
  return ($fs * $lh);
8736
  }
8737
  else if (isset($this->normalLineheight)) { return ($fs * $this->normalLineheight); }
8738
+ else return ($fs * $this->default_lineheight_correction);
8739
  }
8740
 
8741
 
8743
  if ( isset($_SERVER['HTTP_HOST']) ) { $host = $_SERVER['HTTP_HOST']; }
8744
  else if ( isset($_SERVER['SERVER_NAME']) ) { $host = $_SERVER['SERVER_NAME']; }
8745
  else { $host = ''; }
8746
+ if (!$str) {
8747
  if ($_SERVER['SCRIPT_NAME']) { $currentPath = dirname($_SERVER['SCRIPT_NAME']); }
8748
  else { $currentPath = dirname($_SERVER['PHP_SELF']); }
8749
  $currentPath = str_replace("\\","/",$currentPath);
8750
  if ($currentPath == '/') { $currentPath = ''; }
8751
  if ($host) { $currpath = 'http://' . $host . $currentPath .'/'; }
8752
  else { $currpath = ''; }
8753
+ $this->basepath = $currpath;
8754
+ $this->basepathIsLocal = true;
8755
+ return;
8756
  }
8757
  $str = preg_replace('/\?.*/','',$str);
8758
+ if (!preg_match('/(http|https|ftp):\/\/.*\//i',$str)) { $str .= '/'; }
8759
  $str .= 'xxx'; // in case $str ends in / e.g. http://www.bbc.co.uk/
8760
  $this->basepath = dirname($str) . "/"; // returns e.g. e.g. http://www.google.com/dir1/dir2/dir3/
8761
  $this->basepath = str_replace("\\","/",$this->basepath); //If on Windows
8788
  $path = $path . "/" . $filepath; //Make it an absolute path
8789
  }
8790
  else if( strpos($path,":/") === false || strpos($path,":/") > 10) { //It is a Local Link
8791
+ if (substr($path,0,1) == "/") {
8792
  $tr = parse_url($basepath);
8793
  $root = $tr['scheme'].'://'.$tr['host'];
8794
+ $path = $root . $path;
8795
  }
8796
  else { $path = $basepath . $path; }
8797
  }
8811
  $ap=realpath($lp);
8812
  $ap=str_replace("\\","/",$ap);
8813
  $docroot=substr($ap,0,strpos($ap,$lp));
8814
+ // WriteHTML parses all paths to full URLs; may be local file name
8815
+ if ($tr['scheme'] && $tr['host'] && $_SERVER["DOCUMENT_ROOT"] ) {
8816
+ $localpath = $_SERVER["DOCUMENT_ROOT"] . $tr['path'];
8817
  }
8818
  // DOCUMENT_ROOT is not returned on IIS
8819
  else if ($docroot) {
8844
  $lastreset = 0;
8845
  foreach($this->PageNumSubstitutions AS $psarr) {
8846
  if ($num >= $psarr['from']) {
8847
+ if ($psarr['reset']) {
8848
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8849
+ $ppgno = $num - $psarr['from'] + 1 + $offset;
8850
  $lastreset = $psarr['from'];
8851
  }
8852
  if ($psarr['type']) { $type = $psarr['type']; }
8871
 
8872
 
8873
  function docPageSettings($num = 0) {
8874
+ // Returns current type (numberstyle), suppression state for this page number;
8875
  // reset is only returned if set for this page number
8876
  if ($num < 1) { $num = $this->page; }
8877
  $type = '1'; // set default decimal
8881
  $reset = '';
8882
  foreach($this->PageNumSubstitutions AS $psarr) {
8883
  if ($num >= $psarr['from']) {
8884
+ if ($psarr['reset']) {
8885
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8886
+ $ppgno = $num - $psarr['from'] + 1 + $offset;
8887
  }
8888
  if ($psarr['type']) { $type = $psarr['type']; }
8889
  if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
8900
  if ($num < 1) { $num = $this->page; }
8901
  $type = '1'; // set default decimal
8902
  $ppgstart = 1;
8903
+ $ppgend = count($this->pages)+1;
8904
  $suppress = 0;
8905
  $offset = 0;
8906
  foreach($this->PageNumSubstitutions AS $psarr) {
8907
  if ($num >= $psarr['from']) {
8908
+ if ($psarr['reset']) {
8909
  if ($psarr['reset']>1) { $offset = $psarr['reset']-1; }
8910
+ $ppgstart = $psarr['from'] + $offset;
8911
+ $ppgend = count($this->pages)+1 + $offset;
8912
  }
8913
  if ($psarr['type']) { $type = $psarr['type']; }
8914
  if (strtoupper($psarr['suppress'])=='ON' || $psarr['suppress']==1) { $suppress = 1; }
8915
  else if (strtoupper($psarr['suppress'])=='OFF') { $suppress = 0; }
8916
  }
8917
  if ($num < $psarr['from']) {
8918
+ if ($psarr['reset']) {
8919
+ $ppgend = $psarr['from'] + $offset;
8920
  break;
8921
  }
8922
  }
8923
  }
8924
  if ($suppress) { return ''; }
8925
+ $ppgno = $ppgend-$ppgstart+$offset;
8926
  if ($extras) { $ppgno = $this->nbpgPrefix . $ppgno . $this->nbpgSuffix; }
8927
  return $ppgno;
8928
  }
8955
  $headerlmargin = $this->orig_lMargin;
8956
  }
8957
  }
8958
+ else {
8959
+ $yadj = 0;
8960
  $headerpgwidth = $this->pgwidth;
8961
  $headerlmargin = $this->lMargin;
8962
  }
8968
  $this->bullet = false;
8969
 
8970
  // only show pagenumber if numbering on
8971
+ $pgno = $this->docPageNum($this->page, true);
8972
 
8973
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
8974
  $side = 'even';
8996
  else { $hfsz = $this->original_default_font_size; } // pts
8997
  $maxfontheight = max($maxfontheight,$hfsz);
8998
  $hfst = '';
8999
+ if (isset($h[$side][$pos]['font-style']) && $h[$side][$pos]['font-style']) {
9000
  $hfst = $h[$side][$pos]['font-style'];
9001
  }
9002
+ if (isset($h[$side][$pos]['color']) && $h[$side][$pos]['color']) {
9003
+ $hfcol = $h[$side][$pos]['color'];
9004
  $cor = $this->ConvertColor($hfcol);
9005
  if ($cor) { $this->SetTColor($cor); }
9006
  }
9018
  // DIRECTIONALITY RTL
9019
  // Font-specific ligature substitution for Indic fonts
9020
  $align = $pos;
9021
+ if ($pos!='L' && (strpos($hd,$this->aliasNbPg)!==false || strpos($hd,$this->aliasNbPgGp)!==false)) {
9022
  if (strpos($hd,$this->aliasNbPgGp)!==false) { $type= 'nbpggp'; } else { $type= 'nbpg'; }
9023
+ $this->_out('{mpdfheader'.$type.' '.$pos.' ff='.$hff.' fs='.$hfst.' fz='.$hfsz.'}');
9024
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9025
  $this->_out('Q');
9026
  }
9027
+ else {
9028
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9029
  }
9030
  if ($hfcol) { $this->SetTColor($this->ConvertColor(0)); }
9033
  //Return Font to normal
9034
  $this->SetFont($this->default_font,'',$this->original_default_font_size);
9035
  // LINE
9036
+ if (isset($h[$side]['line']) && $h[$side]['line']) {
9037
  $this->SetLineWidth(0.1);
9038
  $this->SetDColor($this->ConvertColor(0));
9039
  $this->Line($headerlmargin , $this->margin_header + ($maxfontheight*(1+$this->header_line_spacing)/_MPDFK) - $yadj , $headerlmargin + $headerpgwidth, $this->margin_header + ($maxfontheight*(1+$this->header_line_spacing)/_MPDFK) - $yadj );
9057
  if ($horf=='H') { // Only if header
9058
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; }
9059
  else { $adv = $table['max_cell_border_width']['T'] /2 ; }
9060
+ if ($adv) {
9061
  if ($this->table_rotate) {
9062
  $this->y += ($adv);
9063
  }
9064
  else {
9065
+ $this->DivLn($adv,$this->blklvl,true);
9066
  }
9067
  }
9068
  }
9130
  $this->x = $x;
9131
 
9132
  if ($this->ColActive) {
9133
+ if ($table['borders_separate']) {
9134
  $tablefill = isset($table['bgcolor'][-1]) ? $table['bgcolor'][-1] : 0;
9135
  if ($tablefill) {
9136
  $color = $this->ConvertColor($tablefill);
9161
  }
9162
 
9163
  if ($table['empty_cells']!='hide' || !empty($textbuffer) || !$table['borders_separate']) { $paintcell = true; }
9164
+ else { $paintcell = false; }
9165
 
9166
  //Vertical align
9167
  if ($R && INTVAL($R) > 0 && isset($va) && $va!='B') { $va='B';}
9172
 
9173
  //TABLE ROW OR CELL FILL BGCOLOR
9174
  $fill = 0;
9175
+ if (isset($tablehf['bgcolor']) && $tablehf['bgcolor'] && $tablehf['bgcolor']!='transparent') {
9176
  $fill = $tablehf['bgcolor'];
9177
  $leveladj = 6;
9178
  }
9183
  if ($fill && $paintcell) {
9184
  $color = $this->ConvertColor($fill);
9185
  if ($color) {
9186
+ if ($table['borders_separate']) {
9187
  if ($this->ColActive) {
9188
  $this->SetFColor($color);
9189
  $this->Rect($x+ ($table['border_spacing_H']/2), $y+ ($table['border_spacing_V']/2), $w- $table['border_spacing_H'], $h- $table['border_spacing_V'], 'F');
9192
  $this->tableBackgrounds[$level*9+$leveladj][] = array('gradient'=>false, 'x'=>($x + ($table['border_spacing_H']/2)), 'y'=>($y + ($table['border_spacing_V']/2)), 'w'=>($w - $table['border_spacing_H']), 'h'=>($h - $table['border_spacing_V']), 'col'=>$color);
9193
  }
9194
  }
9195
+ else {
9196
  if ($this->ColActive) {
9197
  $this->SetFColor($color);
9198
  $this->Rect($x, $y, $w, $h, 'F');
9207
 
9208
 
9209
  //Cell Border
9210
+ if ($table['borders_separate'] && $paintcell && $border) {
9211
  $this->_tableRect($x+ ($table['border_spacing_H']/2)+($border_details['L']['w'] /2), $y+ ($table['border_spacing_V']/2)+($border_details['T']['w'] /2), $w-$table['border_spacing_H']-($border_details['L']['w'] /2)-($border_details['R']['w'] /2), $h- $table['border_spacing_V']-($border_details['T']['w'] /2)-($border_details['B']['w']/2), $border, $border_details, false, $table['borders_separate']);
9212
  }
9213
+ else if ($paintcell && $border) {
9214
  $this->_tableRect($x, $y, $w, $h, $border, $border_details, true, $table['borders_separate']); // true causes buffer
9215
  }
9216
 
9217
  //Print cell content
9218
+ //$this->divheight = $this->table_lineheight*$this->lineheight;
9219
  if (!empty($textbuffer)) {
9220
  if ($horf=='F' && preg_match('/{colsum([0-9]*)[_]*}/', $textbuffer[0][0], $m)) {
9221
  $rep = sprintf("%01.".intval($m[1])."f", $this->colsums[$colctr-1]);
9235
  else if ($angle > 0 && $angle <45) { $angle = 45; }
9236
  else if ($angle < 0) { $angle = -90; }
9237
  $offset = ((sin(deg2rad($angle))) * 0.37 * $cellFontHeight);
9238
+ if (isset($align) && $align =='R') {
9239
+ $this->x += ($w) + ($offset) - ($cellFontHeight/3) - ($padding['R'] + $border_details['R']['w']);
9240
  }
9241
+ else if (!isset($align ) || $align =='C') {
9242
+ $this->x += ($w/2) + ($offset);
9243
  }
9244
+ else {
9245
+ $this->x += ($offset) + ($cellFontHeight/3)+($padding['L'] + $border_details['L']['w']);
9246
  }
9247
  $str = '';
9248
  foreach($tablehf['textbuffer'] AS $t) { $str .= $t[0].' '; }
9249
  $str = trim($str);
9250
 
9251
+ if (!isset($va) || $va=='M') {
9252
  $this->y -= ($h-$mih)/2; //Undo what was added earlier VERTICAL ALIGN
9253
  if ($angle > 0) { $this->y += (($h-$mih)/2)+($padding['T'] + $border_details['T']['w']) + ($mih-($padding['T'] + $border_details['T']['w']+$border_details['B']['w']+$padding['B'])); }
9254
  else if ($angle < 0) { $this->y += (($h-$mih)/2)+($padding['T'] + $border_details['T']['w']); }
9255
  }
9256
+ else if (isset($va) && $va=='B') {
9257
  $this->y -= $h-$mih; //Undo what was added earlier VERTICAL ALIGN
9258
  if ($angle > 0) { $this->y += $h-($border_details['B']['w']+$padding['B']); }
9259
  else if ($angle < 0) { $this->y += $h-$mih+($padding['T'] + $border_details['T']['w']); }
9260
  }
9261
+ else if (isset($va) && $va=='T') {
9262
  if ($angle > 0) { $this->y += $mih-($border_details['B']['w']+$padding['B']); }
9263
  else if ($angle < 0) { $this->y += ($padding['T'] + $border_details['T']['w']); }
9264
  }
9269
  $s_st = $this->FontStyle;
9270
  if (!empty($textbuffer[0][3])) { //Font Color
9271
  $cor = $textbuffer[0][3];
9272
+ $this->SetTColor($cor);
9273
  }
9274
  $s_str = $this->strike;
9275
  $this->strike = $textbuffer[0][8]; //Strikethrough
9305
 
9306
 
9307
  // TABLE BORDER - if separate OR collapsed and only table border
9308
+ if (($table['borders_separate'] || ($this->simpleTables && !$table['simple']['border'])) && $table['border']) {
9309
  $halfspaceL = $table['padding']['L'] + ($table['border_spacing_H']/2);
9310
  $halfspaceR = $table['padding']['R'] + ($table['border_spacing_H']/2);
9311
  $halfspaceT = $table['padding']['T'] + ($table['border_spacing_V']/2);
9319
  if ($i == $firstrow && $horf=='H') { // Top
9320
  $tby -= $halfspaceT + ($table['border_details']['T']['w']/2);
9321
  $tbh += $halfspaceT + ($table['border_details']['T']['w']/2);
9322
+ $this->setBorder($tab_bord , _BORDER_TOP);
9323
  $corner .= 'T';
9324
  }
9325
  if (($i == ($lastrow) || (isset($tablehf['rowspan']) && ($i+$tablehf['rowspan']) == ($lastrow+1))) && $horf=='F') { // Bottom
9326
  $tbh += $halfspaceB + ($table['border_details']['B']['w']/2);
9327
+ $this->setBorder($tab_bord , _BORDER_BOTTOM);
9328
  $corner .= 'B';
9329
  }
9330
  if ($colctr == 1 && $firstSpread) { // Left
9331
  $tbx -= $halfspaceL + ($table['border_details']['L']['w']/2);
9332
  $tbw += $halfspaceL + ($table['border_details']['L']['w']/2);
9333
+ $this->setBorder($tab_bord , _BORDER_LEFT);
9334
  $corner .= 'L';
9335
  }
9336
  if ($colctr == count($content[$i]) && $finalSpread) { // Right
9337
  $tbw += $halfspaceR + ($table['border_details']['R']['w']/2);
9338
+ $this->setBorder($tab_bord , _BORDER_RIGHT);
9339
  $corner .= 'R';
9340
  }
9341
  $this->_tableRect($tbx, $tby, $tbw, $tbh, $tab_bord , $table['border_details'], false, $table['borders_separate'], 'table', $corner, $table['border_spacing_V'], $table['border_spacing_H'] );
9419
  else { $this->headerDetails = $Harray; }
9420
  }
9421
 
9422
+ if ($write) {
9423
  $save_y = $this->y;
9424
  $this->Header();
9425
+ $this->SetY($save_y) ;
9426
  }
9427
  }
9428
 
9497
  $headerlmargin = $this->orig_lMargin;
9498
  }
9499
  }
9500
+ else {
9501
+ $yadj = 0;
9502
  $headerpgwidth = $this->pgwidth;
9503
  $headerlmargin = $this->lMargin;
9504
  }
9510
  $this->bullet = false;
9511
 
9512
  // only show pagenumber if numbering on
9513
+ $pgno = $this->docPageNum($this->page, true);
9514
 
9515
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
9516
  $side = 'even';
9539
  $maxfontheight = max($maxfontheight,$hfsz);
9540
  if (isset($h[$side][$pos]['font-style']) && $h[$side][$pos]['font-style']) { $hfst = $h[$side][$pos]['font-style']; }
9541
  else { $hfst = ''; }
9542
+ if (isset($h[$side][$pos]['color']) && $h[$side][$pos]['color']) {
9543
+ $hfcol = $h[$side][$pos]['color'];
9544
  $cor = $this->ConvertColor($hfcol);
9545
  if ($cor) { $this->SetTColor($cor); }
9546
  }
9557
  // DIRECTIONALITY RTL
9558
  // Font-specific ligature substitution for Indic fonts
9559
  $align = $pos;
9560
+ if ($this->directionality == 'rtl') {
9561
  if ($pos == 'L') { $align = 'R'; }
9562
  else if ($pos == 'R') { $align = 'L'; }
9563
  }
9564
 
9565
+ if ($pos!='L' && (strpos($hd,$this->aliasNbPg)!==false || strpos($hd,$this->aliasNbPgGp)!==false)) {
9566
  if (strpos($hd,$this->aliasNbPgGp)!==false) { $type= 'nbpggp'; } else { $type= 'nbpg'; }
9567
+ $this->_out('{mpdfheader'.$type.' '.$pos.' ff='.$hff.' fs='.$hfst.' fz='.$hfsz.'}');
9568
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9569
  $this->_out('Q');
9570
  }
9571
+ else {
9572
  $this->Cell($headerpgwidth ,$maxfontheight/_MPDFK ,$hd,0,0,$align,0,'',0,0,0,'M');
9573
  }
9574
  if ($hfcol) { $this->SetTColor($this->ConvertColor(0)); }
9579
 
9580
  // LINE
9581
 
9582
+ if (isset($h[$side]['line']) && $h[$side]['line']) {
9583
  $this->SetLineWidth(0.1);
9584
  $this->SetDColor($this->ConvertColor(0));
9585
  $this->Line($headerlmargin , $this->y-($maxfontheight*($this->footer_line_spacing)/_MPDFK), $headerlmargin +$headerpgwidth, $this->y-($maxfontheight*($this->footer_line_spacing)/_MPDFK));
9613
  if ($sub == 1) { $html = '<style> '.$html.' </style>'; } // stylesheet only
9614
 
9615
  if ($this->allow_charset_conversion) {
9616
+ if ($sub < 1) {
9617
+ $this->ReadCharset($html);
9618
  }
9619
+ if ($this->charset_in && $sub!=4) { // mPDF 5.4.14
9620
+ $success = iconv($this->charset_in,'UTF-8//TRANSLIT',$html);
9621
  if ($success) { $html = $success; }
9622
  }
9623
  }
9633
  }
9634
 
9635
  $zproperties = array();
9636
+ if ($sub < 2) {
9637
+ $this->ReadMetaTags($html);
9638
 
9639
  // NB default stylesheet now in mPDF.css - read on initialising class
9640
+ $html = $this->ReadCSS($html);
9641
 
9642
+ if ($this->useLang && !$this->usingCoreFont && preg_match('/<html [^>]*lang=[\'\"](.*?)[\'\"]/ism',$html,$m)) {
9643
+ $html_lang = $m[1];
9644
  }
9645
 
9646
+ if (preg_match('/<html [^>]*dir=[\'\"]\s*rtl\s*[\'\"]/ism',$html)) {
9647
+ $zproperties['DIRECTION'] = 'rtl';
9648
  }
9649
 
9650
  // allow in-line CSS for body tag to be parsed // Get <body> tag inline CSS
9651
+ if (preg_match('/<body([^>]*)>(.*?)<\/body>/ism',$html,$m) || preg_match('/<body([^>]*)>(.*)$/ism',$html,$m)) {
9652
+ $html = $m[2];
9653
  // Changed to allow style="background: url('bg.jpg')"
9654
+ if (preg_match('/style=[\"](.*?)[\"]/ism',$m[1],$mm) || preg_match('/style=[\'](.*?)[\']/ism',$m[1],$mm)) {
9655
+ $zproperties = $this->readInlineCSS($mm[1]);
9656
  }
9657
+ if (preg_match('/dir=[\'\"]\s*rtl\s*[\'\"]/ism',$m[1])) {
9658
+ $zproperties['DIRECTION'] = 'rtl';
9659
  }
9660
  if (isset($html_lang) && $html_lang) { $zproperties['LANG'] = $html_lang; }
9661
  if ($this->useLang && !$this->onlyCoreFonts && preg_match('/lang=[\'\"](.*?)[\'\"]/ism',$m[1],$mm)) {
9662
+ $zproperties['LANG'] = $mm[1];
9663
  }
9664
 
9665
  }
9668
  if ($zproperties) { $properties = $this->array_merge_recursive_unique($properties,$zproperties); }
9669
 
9670
  if (isset($properties['DIRECTION']) && $properties['DIRECTION']) {
9671
+ $this->CSS['BODY']['DIRECTION'] = $properties['DIRECTION'];
9672
  }
9673
  if (!isset($this->CSS['BODY']['DIRECTION'])) {
9674
+ $this->CSS['BODY']['DIRECTION'] = $this->directionality;
9675
  }
9676
  else { $this->SetDirectionality($this->CSS['BODY']['DIRECTION']); }
9677
 
9678
+ $this->setCSS($properties,'','BODY');
9679
  $this->blk[0]['InlineProperties'] = $this->saveInlineProperties();
9680
 
9681
  if ($sub == 1) { return ''; }
9683
 
9684
 
9685
 
9686
+ $parseonly = false;
9687
+ $this->bufferoutput = false;
9688
+ if ($sub == 3) {
9689
+ $parseonly = true;
9690
  // Close any open block tags
9691
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
9692
  // Output any text left in buffer
9693
  if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
9694
  $this->textbuffer=array();
9695
+ }
9696
+ else if ($sub == 4) {
9697
  // Close any open block tags
9698
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
9699
  // Output any text left in buffer
9700
  if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); }
9701
+ $this->bufferoutput = true;
9702
  $this->textbuffer=array();
9703
  $this->headerbuffer='';
9704
  $properties = $this->MergeCSS('BLOCK','BODY','');
9705
+ $this->setCSS($properties,'','BODY');
9706
+ }
9707
 
9708
+ mb_internal_encoding('UTF-8');
9709
 
9710
  $html = $this->AdjustHTML($html, $this->tabSpaces); //Try to make HTML look more like XHTML
9711
 
9723
  $html=str_replace('<?','< ',$html); //Fix '<?XML' bug from HTML code generated by MS Word
9724
 
9725
  $this->checkSIP = false;
9726
+ $this->checkSMP = false;
9727
+ $this->checkCJK = false;
9728
  if ($this->onlyCoreFonts) { $html = $this->SubstituteChars($html); }
9729
  else {
9730
  if (preg_match("/([\x{20000}-\x{2FFFF}])/u", $html)) { $this->checkSIP = true; }
9732
  }
9733
 
9734
  // Don't allow non-breaking spaces that are converted to substituted chars or will break anyway and mess up table width calc.
9735
+ $html = str_replace('<tta>160</tta>',chr(32),$html);
9736
+ $html = str_replace('</tta><tta>','|',$html);
9737
+ $html = str_replace('</tts><tts>','|',$html);
9738
+ $html = str_replace('</ttz><ttz>','|',$html);
9739
 
9740
  //Add new supported tags in the DisableTags function
9741
  $html=strip_tags($html,$this->enabledtags); //remove all unsupported tags, but the ones inside the 'enabledtags' string
9746
  // if changing - also change in fn.SubstituteChars()
9747
  // $a = preg_split ('/<((?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+)>/ms', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
9748
 
9749
+ if ($this->mb_enc) {
9750
+ mb_internal_encoding($this->mb_enc);
9751
  }
9752
  $pbc = 0;
9753
  $this->subPos = -1;
9765
  $e = strcode2utf($e);
9766
  $e = $this->lesser_entity_decode($e);
9767
 
9768
+ if ($this->usingCoreFont) {
9769
  // If core font is selected in document which is not onlyCoreFonts - substitute with non-core font
9770
  if ($this->useSubstitutions && !$this->onlyCoreFonts && $this->subPos<$i && !$this->specialcontent) {
9771
+ $cnt += $this->SubstituteCharsNonCore($a, $i, $e);
9772
  }
9773
  // CONVERT ENCODING
9774
+ $e = mb_convert_encoding($e,$this->mb_enc,'UTF-8');
9775
  if ($this->toupper) { $e = strtoupper($e); }
9776
  if ($this->tolower) { $e = strtolower($e); }
9777
  if ($this->capitalize) { $e = ucwords($e); }
9778
  }
9779
  else {
9780
+ if ($this->checkSIP && $this->CurrentFont['sipext'] && $this->subPos<$i && !$this->specialcontent) {
9781
+ $cnt += $this->SubstituteCharsSIP($a, $i, $e);
9782
  }
9783
  if ($this->useSubstitutions && !$this->onlyCoreFonts && $this->CurrentFont['type']!='Type0' && $this->subPos<$i && !$this->specialcontent) {
9784
+ $cnt += $this->SubstituteCharsMB($a, $i, $e);
9785
  }
9786
  // mPDF 5.4.05 removes U+200E/U+200F LTR and RTL mark
9787
  // mPDF 5.4.06 removes U+200C/U+200D Zero-width Joiner and Non-joiner
9813
  if (($this->blockjustfinished || $this->listjustfinished) && $this->cell[$this->row][$this->col]['s']>0) {
9814
  $this->_saveCellTextBuffer("\n");
9815
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
9816
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
9817
  }
9818
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
9819
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
9820
  }
9821
  $this->cell[$this->row][$this->col]['s'] = 0;// reset
9822
  }
9826
  $this->_saveCellTextBuffer($e, $this->HREF);
9827
 
9828
  if (!isset($this->cell[$this->row][$this->col]['R']) || !$this->cell[$this->row][$this->col]['R']) {
9829
+ if (isset($this->cell[$this->row][$this->col]['s'])) {
9830
  $this->cell[$this->row][$this->col]['s'] += $this->GetStringWidth($e, false);
9831
  }
9832
  else { $this->cell[$this->row][$this->col]['s'] = $this->GetStringWidth($e, false); }
9833
+ if (!empty($this->spanborddet)) {
9834
  $this->cell[$this->row][$this->col]['s'] += $this->spanborddet['L']['w'] + $this->spanborddet['R']['w'];
9835
  }
9836
  }
9837
 
9838
 
9839
+ if ($this->tableLevel==1 && $this->useGraphs) {
9840
  $this->graphs[$this->currentGraphId]['data'][$this->row][$this->col] = $e;
9841
  }
9842
  $this->nestedtablejustfinished = false;
9858
 
9859
 
9860
  // Check for tags where HTML specifies optional end tags,
9861
+ // and/or does not allow nesting e.g. P inside P, or
9862
  $endtag = trim(strtoupper(substr($e,1))); // mPDF 5.4.20
9863
+ if($this->blk[$this->blklvl]['hide']) {
9864
+ if (in_array($endtag, $this->outerblocktags) || in_array($endtag, $this->innerblocktags)) {
9865
  unset($this->blk[$this->blklvl]);
9866
+ $this->blklvl--;
9867
  }
9868
+ continue;
9869
  }
9870
 
9871
  if ($this->allow_html_optional_endtags && !$parseonly) {
9876
  if ($this->lastoptionaltag == 'DT' && $endtag == 'DL') { $this->CloseTag($this->lastoptionaltag ); }
9877
  if ($this->lastoptionaltag == 'OPTION' && $endtag == 'SELECT') { $this->CloseTag($this->lastoptionaltag ); }
9878
  if ($endtag == 'TABLE') {
9879
+ if ($this->lastoptionaltag == 'THEAD' || $this->lastoptionaltag == 'TBODY' || $this->lastoptionaltag == 'TFOOT') {
9880
  $this->CloseTag($this->lastoptionaltag);
9881
  }
9882
  if ($this->lastoptionaltag == 'TR') { $this->CloseTag('TR'); }
9883
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); }
9884
  }
9885
+ if ($endtag == 'THEAD' || $endtag == 'TBODY' || $endtag == 'TFOOT') {
9886
  if ($this->lastoptionaltag == 'TR') { $this->CloseTag('TR'); }
9887
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); }
9888
  }
9890
  if ($this->lastoptionaltag == 'TD' || $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); }
9891
  }
9892
  }
9893
+ $this->CloseTag($endtag);
9894
  }
9895
 
9896
  else { // OPENING TAG
9897
+ if($this->blk[$this->blklvl]['hide']) {
9898
  if (strpos($e,' ')) { $te = strtoupper(substr($e,0,strpos($e,' '))); }
9899
+ else { $te = strtoupper($e); }
9900
+ if (in_array($te, $this->outerblocktags) || in_array($te, $this->innerblocktags)) {
9901
  $this->blklvl++;
9902
  $this->blk[$this->blklvl]['hide']=true;
9903
  }
9904
+ continue;
9905
  }
9906
 
9907
  $regexp = '|=\'(.*?)\'|s'; // eliminate single quotes, if any
9908
  $e = preg_replace($regexp,"=\"\$1\"",$e);
9909
  // changes anykey=anyvalue to anykey="anyvalue" (only do this inside tags)
9910
  if (substr($e,0,10)!='pageheader' && substr($e,0,10)!='pagefooter') {
9911
+ $regexp = '| (\\w+?)=([^\\s>"]+)|si';
9912
  $e = preg_replace($regexp," \$1=\"\$2\"",$e);
9913
  }
9914
 
9921
  preg_match($regexp,$e,$auxiliararray);
9922
  if (isset($auxiliararray[2])) { $path = $auxiliararray[2]; }
9923
  else { $path = ''; }
9924
+ if (trim($path) != '' && !(stristr($e,"src=") !== false && substr($path,0,4)=='var:')) {
9925
  $orig_srcpath = $path;
9926
+ $this->GetFullPath($path);
9927
  $regexp = '/ (href|src)="(.*?)"/i';
9928
  $e = preg_replace($regexp,' \\1="'.$path.'"',$e);
9929
  }
9999
  $this->linemaxfontsize = '';
10000
  $this->lineheight_correction = $this->default_lineheight_correction;
10001
 
10002
+ $this->bufferoutput = false;
10003
 
10004
 
10005
  }
10021
  $blk['border_left']['w'] = 0;
10022
  $blk['border_bottom']['w'] = 0;
10023
  $blk['border_right']['w'] = 0;
10024
+ $blk['hide'] = false;
10025
+ $blk['outer_left_margin'] = 0;
10026
+ $blk['outer_right_margin'] = 0;
10027
+ $blk['cascadeCSS'] = array();
10028
+ $blk['block-align'] = false;
10029
+ $blk['bgcolor'] = false;
10030
+ $blk['page_break_after_avoid'] = false;
10031
+ $blk['keep_block_together'] = false;
10032
+ $blk['float'] = false;
10033
+ $blk['line_height'] = '';
10034
+ $blk['margin_collapse'] = false;
10035
  }
10036
 
10037
 
10041
  if (isset($this->blk[$this->blklvl]['inner_width'])) { $refw = $this->blk[$this->blklvl]['inner_width']; }
10042
  else if (isset($this->blk[$this->blklvl-1]['inner_width'])) { $refw = $this->blk[$this->blklvl-1]['inner_width']; }
10043
  else { $refw = $this->w; }
10044
+ if ( count($prop) == 1 ) {
10045
  $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
10046
  if ($bsize > 0) {
10047
  return array('s' => 1, 'w' => $bsize, 'c' => $this->ConvertColor(0), 'style'=>'solid');
10049
  else { return array('w' => 0, 's' => 0); }
10050
  }
10051
 
10052
+ else if (count($prop) == 2 ) {
10053
+ // 1px solid
10054
  if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $prop[2] = ''; }
10055
+ // solid #000000
10056
  else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $prop[0] = ''; $prop[1] = $prop[0]; $prop[2] = $prop[1]; }
10057
+ // 1px #000000
10058
  else { $prop[1] = ''; $prop[2] = $prop[1]; }
10059
  }
10060
  else if ( count($prop) == 3 ) {
10063
  // Change solid #000000 1px to 1px solid #000000 (proper)
10064
  else if (substr($prop[0],1,1) == '#') { $tmp = $prop[1]; $prop[0] = $prop[2]; $prop[1] = $prop[0]; $prop[2] = $tmp; }
10065
  // Change solid 1px #000000 to 1px solid #000000 (proper)
10066
+ else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
10067
+ $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $tmp;
10068
  }
10069
  }
10070
+ else { return array(); }
10071
  // Size
10072
  $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
10073
  //color
10074
  $coul = $this->ConvertColor($prop[2]); // returns array
10075
  // Style
10076
  $prop[1] = strtolower($prop[1]);
10077
+ if (in_array($prop[1],$this->borderstyles) && $bsize > 0) { $on = 1; }
10078
+ else if ($prop[1] == 'hidden') { $on = 1; $bsize = 0; $coul = ''; }
10079
+ else if ($prop[1] == 'none') { $on = 0; $bsize = 0; $coul = ''; }
10080
  else { $on = 0; $bsize = 0; $coul = ''; $prop[1] = ''; }
10081
  return array('s' => $on, 'w' => $bsize, 'c' => $coul, 'style'=> $prop[1] );
10082
  }
10085
  function _fix_borderStr($bd) {
10086
  // mPDF 5.5.04
10087
  preg_match_all("/\((.*?)\)/", $bd, $m);
10088
+ if (count($m[1])) {
10089
  for($i=0;$i<count($m[1]);$i++) {
10090
  $sub = preg_replace("/ /", "", $m[1][$i]);
10091
+ $bd = preg_replace('/'.preg_quote($m[1][$i], '/').'/si', $sub, $bd);
10092
  }
10093
  }
10094
 
10097
  $c = '#000000';
10098
  $s = 'none';
10099
 
10100
+ if ( count($prop) == 1 ) {
10101
  // solid
10102
  if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
10103
  // #000000
10104
  else if (is_array($this->ConvertColor($prop[0]))) { $c = $prop[0]; }
10105
+ // 1px
10106
  else { $w = $prop[0]; }
10107
  }
10108
+ else if (count($prop) == 2 ) {
10109
+ // 1px solid
10110
  if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
10111
+ // solid #000000
10112
  else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
10113
+ // 1px #000000
10114
  else { $w = $prop[0]; $c = $prop[1]; }
10115
  }
10116
  else if ( count($prop) == 3 ) {
10119
  // Change solid #000000 1px to 1px solid #000000 (proper)
10120
  else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
10121
  // Change solid 1px #000000 to 1px solid #000000 (proper)
10122
+ else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
10123
+ $s = $prop[0]; $w = $prop[1]; $c = $prop[2];
10124
  }
10125
  else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
10126
  }
10127
+ else { return ''; }
10128
  $s = strtolower($s);
10129
  return $w.' '.$s.' '.$c;
10130
  }
10133
 
10134
  // NEW FUNCTION FOR CSS MARGIN or PADDING called from SetCSS
10135
  function fixCSS($prop) {
10136
+ if (!is_array($prop) || (count($prop)==0)) return array();
10137
+ $newprop = array();
10138
  foreach($prop AS $k => $v) {
10139
  if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
10140
  $v = strtolower($v);
10144
  $s = trim($v);
10145
  preg_match_all('/\"(.*?)\"/',$s,$ff);
10146
  if (count($ff[1])) {
10147
+ foreach($ff[1] AS $ffp) {
10148
  $w = preg_split('/\s+/',$ffp);
10149
+ $s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
10150
  }
10151
  }
10152
  preg_match_all('/\'(.*?)\'/',$s,$ff);
10153
  if (count($ff[1])) {
10154
+ foreach($ff[1] AS $ffp) {
10155
  $w = preg_split('/\s+/',$ffp);
10156
+ $s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
10157
  }
10158
  }
10159
+ $s = preg_replace('/\s*,\s*/',',',$s);
10160
  $bits = preg_split('/\s+/',$s);
10161
  if (count($bits)>1) {
10162
  $k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
10163
  $fs = $bits[(count($bits)-2)];
10164
+ if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
10165
  $newprop['FONT-SIZE'] = $fsp[1];
10166
  $newprop['LINE-HEIGHT'] = $fsp[2];
10167
  }
10168
+ else { $newprop['FONT-SIZE'] = $fs; }
10169
  if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
10170
  else { $newprop['FONT-STYLE'] = 'normal'; }
10171
  if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
10182
  $fonttype = preg_replace('/ /','',$fonttype);
10183
  $v = strtolower(trim($fonttype));
10184
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
10185
+ if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) ||
10186
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
10187
+ ($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
10188
+ in_array($v, array('sjis','uhc','big5','gb'))) {
10189
+ $newprop[$k] = $v;
10190
  $found = 1;
10191
  break;
10192
  }
10198
  $fonttype = preg_replace('/ /','',$fonttype);
10199
  $v = strtolower(trim($fonttype));
10200
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
10201
+ if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
10202
  $newprop[$k] = $v;
10203
  break;
10204
  }
10263
 
10264
  else if ($k == 'BORDER-SPACING') {
10265
  $prop = preg_split('/\s+/',trim($v));
10266
+ if (count($prop) == 1 ) {
10267
  $newprop['BORDER-SPACING-H'] = $prop[0];
10268
  $newprop['BORDER-SPACING-V'] = $prop[0];
10269
  }
10270
+ else if (count($prop) == 2 ) {
10271
  $newprop['BORDER-SPACING-H'] = $prop[0];
10272
  $newprop['BORDER-SPACING-V'] = $prop[1];
10273
  }
10315
  $angle = ($angle % 360);
10316
  $angle /= 90;
10317
  $angle = round($angle) * 90;
10318
+ $newprop['IMAGE-ORIENTATION'] = $angle;
10319
  }
10320
  }
10321
+ else {
10322
+ $newprop[$k] = $v;
10323
  }
10324
  }
10325
 
10342
  if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
10343
  if (isset($p[2])) {
10344
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
10345
+ $new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10346
  }
10347
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
10348
  if (isset($p[3])) {
10349
  if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
10350
+ $new['spread'] = $this->ConvertSize(trim($p[3]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10351
  }
10352
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[3])); }
10353
  if (isset($p[4])) {
10376
  if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
10377
  if (isset($p[2])) {
10378
  if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
10379
+ $new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
10380
  }
10381
  else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
10382
  if (isset($p[3])) {
10405
 
10406
  function expand24($mp) {
10407
  $prop = preg_split('/\s+/',trim($mp));
10408
+ if (count($prop) == 1 ) {
10409
  return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
10410
  }
10411
+ if (count($prop) == 2 ) {
10412
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
10413
  }
10414
 
10415
+ if (count($prop) == 3 ) {
10416
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
10417
  }
10418
+ if (count($prop) == 4 ) {
10419
  return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
10420
  }
10421
+ return array();
10422
  }
10423
 
10424
 
10429
  function fixLineheight($v) {
10430
  $lh = false;
10431
  if (preg_match('/^[0-9\.,]*$/',$v) && $v >= 0) { return ($v + 0); }
10432
+ else if (strtoupper($v) == 'NORMAL') {
10433
+ return $this->normalLineheight;
10434
  }
10435
+ else {
10436
+ $tlh = $this->ConvertSize($v,$this->FontSize,$this->FontSize,true);
10437
  if ($tlh) { return ($tlh.'mm'); }
10438
  }
10439
  return $this->normalLineheight;
10453
  function _mergeCSS($p, &$t) {
10454
  // Save Cascading CSS e.g. "div.topic p" at this block level
10455
  if (isset($p) && $p) {
10456
+ if ($t) {
10457
  $t = $this->array_merge_recursive_unique($t, $p);
10458
  }
10459
  else { $t = $p; }
10478
  $ret[$key] = $value;
10479
  }
10480
  }
10481
+ }
10482
  }
10483
  return $ret;
10484
  }
10540
  if (isset($m)) {
10541
  if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
10542
  if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
10543
+ if (is_array($m)) {
10544
+ $p = array_merge($p,$m);
10545
  $this->_mergeBorders($p,$m);
10546
  }
10547
  }
10578
 
10579
  function MergeCSS($inherit,$tag,$attr) {
10580
  $p = array();
10581
+ $zp = array();
10582
 
10583
  $classes = array();
10584
  if (isset($attr['CLASS'])) {
10609
  }
10610
  $this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
10611
  //===============================================
10612
+ // Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
10613
  //===============================================
10614
  // STYLESHEET TAG e.g. table
10615
  $this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
10638
  }
10639
  $this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
10640
  //===============================================
10641
+ // Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS
10642
  //===============================================
10643
  // STYLESHEET TAG e.g. table
10644
  $this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
10668
 
10669
  if (isset($this->blk[$this->blklvl-1]['direction']) && $this->blk[$this->blklvl-1]['direction']) { $p['DIRECTION'] = $this->blk[$this->blklvl-1]['direction']; }
10670
 
10671
+ if (isset($this->blk[$this->blklvl-1]['align']) && $this->blk[$this->blklvl-1]['align']) {
10672
+ if ($this->blk[$this->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
10673
+ else if ($this->blk[$this->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
10674
+ else if ($this->blk[$this->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
10675
+ else if ($this->blk[$this->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
10676
  }
10677
+ if ($this->ColActive || $this->keep_block_together) {
10678
  if (isset($this->blk[$this->blklvl-1]['bgcolor']) && $this->blk[$this->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
10679
  $cor = $this->blk[$this->blklvl-1]['bgcolorarray' ];
10680
  $p['BACKGROUND-COLOR'] = $this->_colAtoString($cor);
10690
  if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
10691
  if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; }
10692
  if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
10693
+ if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) {
10694
  $cor = $biilp[ 'colorarray' ];
10695
  $p['COLOR'] = $this->_colAtoString($cor);
10696
  }
10699
  else { $p['FONT-KERNING'] = 'none'; }
10700
  }
10701
  if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; }
10702
+ if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; }
10703
  if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
10704
  else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
10705
  else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
10706
+ // CSS says text-decoration is not inherited, but IE7 does??
10707
  if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
10708
  if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
10709
 
10718
  if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
10719
  if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; }
10720
  if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
10721
+ if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) {
10722
  $cor = $bilp[ 'colorarray' ];
10723
  $p['COLOR'] = $this->_colAtoString($cor);
10724
  }
10743
  //===============================================
10744
  //===============================================
10745
  // DEFAULT for this TAG set in DefaultCSS
10746
+ if (isset($this->defaultCSS[$tag])) {
10747
  $zp = $this->fixCSS($this->defaultCSS[$tag]);
10748
  if (is_array($zp)) { // Default overwrites Inherited
10749
  $p = array_merge($p,$zp); // !! Note other way round !!
10752
  }
10753
  //===============================================
10754
  // cellPadding overwrites TD/TH default but not specific CSS set on cell
10755
+ if (($tag=='TD' || $tag=='TH') && isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']) && ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'] || $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']===0)) {
10756
  $p['PADDING-LEFT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
10757
  $p['PADDING-RIGHT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
10758
  $p['PADDING-TOP'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
10760
  }
10761
  //===============================================
10762
  // STYLESHEET TAG e.g. h1 p div table
10763
+ if (isset($this->CSS[$tag]) && $this->CSS[$tag]) {
10764
  $zp = $this->CSS[$tag];
10765
+ if (is_array($zp)) {
10766
+ $p = array_merge($p,$zp);
10767
  $this->_mergeBorders($p,$zp);
10768
  }
10769
  }
10772
  foreach($classes AS $class) {
10773
  $zp = array();
10774
  if (isset($this->CSS['CLASS>>'.$class]) && $this->CSS['CLASS>>'.$class]) { $zp = $this->CSS['CLASS>>'.$class]; }
10775
+ if (is_array($zp)) {
10776
+ $p = array_merge($p,$zp);
10777
  $this->_mergeBorders($p,$zp);
10778
  }
10779
  }
10805
  if ($select) {
10806
  $zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
10807
  if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); }
10808
+ if (is_array($zp)) {
10809
+ $p = array_merge($p,$zp);
10810
  $this->_mergeBorders($p,$zp);
10811
  }
10812
  }
10817
  // STYLESHEET ID e.g. #smallone{} #redletter{}
10818
  if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) {
10819
  $zp = $this->CSS['ID>>'.$attr['ID']];
10820
+ if (is_array($zp)) {
10821
+ $p = array_merge($p,$zp);
10822
  $this->_mergeBorders($p,$zp);
10823
  }
10824
  }
10827
  foreach($classes AS $class) {
10828
  $zp = array();
10829
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class]) && $this->CSS[$tag.'>>CLASS>>'.$class]) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
10830
+ if (is_array($zp)) {
10831
+ $p = array_merge($p,$zp);
10832
  $this->_mergeBorders($p,$zp);
10833
  }
10834
  }
10836
  // STYLESHEET CLASS e.g. p#smallone{} div#redletter{}
10837
  if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) {
10838
  $zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
10839
+ if (is_array($zp)) {
10840
+ $p = array_merge($p,$zp);
10841
  $this->_mergeBorders($p,$zp);
10842
  }
10843
  }
10909
  }
10910
  //===============================================
10911
  else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS
10912
+ // false = don't check for 'depth'
10913
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false);
10914
  foreach($classes AS $class) {
10915
  $this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false);
10925
  // INLINE STYLE e.g. style="CSS:property"
10926
  if (isset($attr['STYLE'])) {
10927
  $zp = $this->readInlineCSS($attr['STYLE']);
10928
+ if (is_array($zp)) {
10929
+ $p = array_merge($p,$zp);
10930
  $this->_mergeBorders($p,$zp);
10931
  }
10932
  }
10985
  function PreviewBlockCSS($tag,$attr) {
10986
  // Looks ahead from current block level to a new level
10987
  $p = array();
10988
+ $zp = array();
10989
  $oldcascadeCSS = $this->blk[$this->blklvl]['cascadeCSS'];
10990
  $classes = array();
10991
  if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
10992
  //===============================================
10993
  // DEFAULT for this TAG set in DefaultCSS
10994
+ if (isset($this->defaultCSS[$tag])) {
10995
  $zp = $this->fixCSS($this->defaultCSS[$tag]);
10996
  if (is_array($zp)) { $p = array_merge($zp,$p); } // Inherited overwrites default
10997
  }
10998
  // STYLESHEET TAG e.g. h1 p div table
10999
+ if (isset($this->CSS[$tag])) {
11000
  $zp = $this->CSS[$tag];
11001
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11002
  }
11003
  // STYLESHEET CLASS e.g. .smallone{} .redletter{}
11004
  foreach($classes AS $class) {
11005
+ $zp = array();
11006
  if (isset($this->CSS['CLASS>>'.$class])) { $zp = $this->CSS['CLASS>>'.$class]; }
11007
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11008
  }
11013
  }
11014
  // STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
11015
  foreach($classes AS $class) {
11016
+ $zp = array();
11017
  if (isset($this->CSS[$tag.'>>CLASS>>'.$class])) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
11018
  if (is_array($zp)) { $p = array_merge($p,$zp); }
11019
  }
11067
 
11068
  // What this gets: < $tag $attr['WIDTH']="90px" > does not get content here </closeTag here>
11069
  // Correct tags where HTML specifies optional end tags,
11070
+ // and/or does not allow nesting e.g. P inside P, or
11071
  if ($this->allow_html_optional_endtags) {
11072
  if (($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag=='PRE' || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DL' || $tag == 'HR' ) && $this->lastoptionaltag == 'P') { $this->CloseTag($this->lastoptionaltag ); }
11073
  if ($tag == 'DD' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); }
11090
  //Opening tag
11091
  switch($tag){
11092
 
11093
+ case 'DOTTAB':
11094
  $objattr = array();
11095
  $objattr['type'] = 'dottab';
11096
  $dots=str_repeat('.', 3)." "; // minimum number of dots
11112
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11113
  }
11114
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11115
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11116
  }
11117
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11118
  $this->_saveCellTextBuffer($e);
11122
  } // *TABLES*
11123
  break;
11124
 
11125
+ case 'PAGEHEADER':
11126
  case 'PAGEFOOTER':
11127
+ $this->ignorefollowingspaces = true;
11128
  if ($attr['NAME']) { $pname = $attr['NAME']; }
11129
  else { $pname = '_default'; }
11130
 
11134
  $p['L']=array();
11135
  $p['C']=array();
11136
  $p['R']=array();
11137
+ $p['L']['font-style'] = '';
11138
+ $p['C']['font-style'] = '';
11139
+ $p['R']['font-style'] = '';
11140
 
11141
  if (isset($attr['CONTENT-LEFT'])) {
11142
  $p['L']['content'] = $attr['CONTENT-LEFT'];
11151
  if (isset($attr['HEADER-STYLE']) || isset($attr['FOOTER-STYLE'])) { // font-family,size,weight,style,color
11152
  if ($tag=='PAGEHEADER') { $properties = $this->readInlineCSS($attr['HEADER-STYLE']); }
11153
  else { $properties = $this->readInlineCSS($attr['FOOTER-STYLE']); }
11154
+ if (isset($properties['FONT-FAMILY'])) {
11155
+ $p['L']['font-family'] = $properties['FONT-FAMILY'];
11156
+ $p['C']['font-family'] = $properties['FONT-FAMILY'];
11157
+ $p['R']['font-family'] = $properties['FONT-FAMILY'];
11158
  }
11159
+ if (isset($properties['FONT-SIZE'])) {
11160
+ $p['L']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11161
+ $p['C']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11162
+ $p['R']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
11163
  }
11164
  if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='bold') {
11165
+ $p['L']['font-style'] = 'B';
11166
+ $p['C']['font-style'] = 'B';
11167
+ $p['R']['font-style'] = 'B';
11168
  }
11169
+ if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') {
11170
+ $p['L']['font-style'] .= 'I';
11171
+ $p['C']['font-style'] .= 'I';
11172
+ $p['R']['font-style'] .= 'I';
11173
  }
11174
+ if (isset($properties['COLOR'])) {
11175
+ $p['L']['color'] = $properties['COLOR'];
11176
+ $p['C']['color'] = $properties['COLOR'];
11177
+ $p['R']['color'] = $properties['COLOR'];
11178
  }
11179
  }
11180
  if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) {
11213
 
11214
 
11215
 
11216
+ case 'SETPAGEHEADER':
11217
  case 'SETPAGEFOOTER':
11218
+ $this->ignorefollowingspaces = true;
11219
  if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
11220
  else { $pname = '_default'; }
11221
  if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
11274
  for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
11275
  if(!empty($this->textbuffer)) { //Output previously buffered content
11276
  $this->printbuffer($this->textbuffer);
11277
+ $this->textbuffer=array();
11278
  }
11279
  $this->ignorefollowingspaces = true;
11280
  $save_cols = false;
11281
 
11282
 
11283
+ if (isset($attr['SHEET-SIZE']) && $tag != 'FORMFEED' && !$this->restoreBlockPageBreaks) {
11284
  // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
11285
  $prop = preg_split('/\s+/',trim($attr['SHEET-SIZE']));
11286
  if (count($prop) == 2 ) {
11343
  // Re-open block tags
11344
  $t = $this->blk[0]['tag'];
11345
  $a = $this->blk[0]['attr'];
11346
+ $this->blklvl = 0;
11347
  for ($b=0; $b<=$save_blklvl;$b++) {
11348
  $tc = $t;
11349
  $ac = $a;
11350
  $t = $this->blk[$b+1]['tag'];
11351
  $a = $this->blk[$b+1]['attr'];
11352
  unset($this->blk[$b+1]);
11353
+ $this->OpenTag($tc,$ac);
11354
  }
11355
  $this->spanlvl = $save_spanlvl;
11356
  $this->InlineProperties = $save_ilp;
11392
  if (in_array($this->FontFamily,$this->mono_fonts)) {
11393
  $this->setCSS(array('FONT-FAMILY'=>'ccourier'),'INLINE');
11394
  }
11395
+ else if (in_array($this->FontFamily,$this->serif_fonts)) {
11396
  $this->setCSS(array('FONT-FAMILY'=>'ctimes'),'INLINE');
11397
  }
11398
  else {
11434
  $this->spanlvl++;
11435
  $this->InlineProperties['SPAN'][$this->spanlvl] = $this->saveInlineProperties();
11436
  }
11437
+ else {
11438
  if (!isset($this->InlineProperties[$tag])) $this->InlineProperties[$tag] = $this->saveInlineProperties(); // mPDF 5.4.13
11439
  }
11440
  $properties = $this->MergeCSS('INLINE',$tag,$attr);
11443
 
11444
 
11445
  case 'A':
11446
+ if (isset($attr['NAME']) and $attr['NAME'] != '') {
11447
  $e = '';
11448
  if($this->tableLevel) { // *TABLES*
11449
  $this->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
11452
  $this->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
11453
  } // *TABLES*
11454
  }
11455
+ if (isset($attr['HREF'])) {
11456
  $this->InlineProperties['A'] = $this->saveInlineProperties();
11457
  $properties = $this->MergeCSS('',$tag,$attr);
11458
  if (!empty($properties)) $this->setCSS($properties,'INLINE');
11479
  if ($max < $min) { $max = $min; }
11480
 
11481
  if (isset($attr['VALUE']) && ($attr['VALUE'] || $attr['VALUE']==='0')) {
11482
+ $value = $attr['VALUE'];
11483
  if ($value < $min) { $value = $min; }
11484
  else if ($value > $max) { $value = $max; }
11485
  }
11516
  $objattr['border_right']['w'] = 0;
11517
 
11518
  $properties = $this->MergeCSS('',$tag,$attr);
11519
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
11520
+ return;
11521
  }
11522
+ $objattr['visibility'] = 'visible';
11523
  if (isset($properties['VISIBILITY'])) {
11524
  $v = strtolower($properties['VISIBILITY']);
11525
+ if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
11526
+ $objattr['visibility'] = $v;
11527
  }
11528
  }
11529
 
11564
  $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
11565
 
11566
  // Image file
11567
+ if (!class_exists('meter', false)) {
11568
+ include(_MPDF_PATH.'classes/meter.php');
11569
  }
11570
  $this->meter = new meter();
11571
  $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
11573
  $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.strtolower($tag).'.svg';
11574
  file_put_contents($srcpath, $svg);
11575
  $orig_srcpath = $srcpath;
11576
+ $this->GetFullPath($srcpath);
11577
 
11578
  $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
11579
  if(!$info) {
11580
  $info = $this->_getImage($this->noImageFile);
11581
+ if ($info) {
11582
+ $srcpath = $this->noImageFile;
11583
+ $w = ($info['w'] * (25.4/$this->dpi));
11584
  $h = ($info['h'] * (25.4/$this->dpi));
11585
  }
11586
  }
11594
  $h = $this->FontSize/(10/_MPDFK) * abs($info['h'])/_MPDFK;
11595
  }
11596
  // IF WIDTH OR HEIGHT SPECIFIED
11597
+ if($w==0) $w=abs($h*$info['w']/$info['h']);
11598
  if($h==0) $h=abs($w*$info['h']/$info['w']);
11599
 
11600
  // Resize to maximum dimensions of page
11649
 
11650
  $this->_saveCellTextBuffer("\n");
11651
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
11652
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11653
  }
11654
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11655
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11656
  }
11657
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11658
  }
11662
  }
11663
  $this->_saveTextBuffer("\n");
11664
  } // *TABLES*
11665
+ $this->ignorefollowingspaces = true;
11666
  $this->blockjustfinished=false;
11667
  $this->listjustfinished=false;
11668
 
11681
  case 'CENTER':
11682
 
11683
  case 'BLOCKQUOTE':
11684
+ case 'ADDRESS':
11685
 
11686
  case 'CAPTION':
11687
  case 'P':
11709
  case 'NAV':
11710
  case 'SECTION':
11711
  $p = $this->PreviewBlockCSS($tag,$attr);
11712
+ if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') {
11713
  $this->blklvl++;
11714
+ $this->blk[$this->blklvl]['hide'] = true;
11715
+ return;
11716
  }
11717
  if($tag == 'CAPTION') {
11718
  // position is written in AdjstHTML
11724
  if (isset($attr['ALIGN'])) { unset($attr['ALIGN']); }
11725
  if ($cappos != $divpos) {
11726
  $this->blklvl++;
11727
+ $this->blk[$this->blklvl]['hide'] = true;
11728
+ return;
11729
  }
11730
  }
11731
 
11732
 
11733
 
11734
  // Start Block
11735
+ $this->ignorefollowingspaces = true;
11736
 
11737
  if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
11738
  else { $lastbottommargin = 0; }
11741
 
11742
  if ($this->listlvl>0) { return; }
11743
 
11744
+ $this->InlineProperties = array();
11745
  $this->spanlvl = 0;
11746
  $this->listjustfinished=false;
11747
  $this->divbegin=true;
11757
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11758
  }
11759
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
11760
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
11761
  }
11762
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
11763
  }
11797
 
11798
  $this->Reset();
11799
  $properties = $this->MergeCSS('BLOCK',$tag,$attr);
11800
+ $pagesel = '';
11801
 
11802
  // If page-box has changed AND/OR PAGE-BREAK-BEFORE
11803
  $save_cols = false;
11830
  $this->blk[0]['inner_width'] =& $this->pgwidth;
11831
  $this->blk[0]['blockContext'] = $this->blockContext;
11832
  $properties = $this->MergeCSS('BLOCK','BODY','');
11833
+ $this->setCSS($properties,'','BODY');
11834
  $this->blklvl++;
11835
  $currblk =& $this->blk[$this->blklvl];
11836
  $prevblk =& $this->blk[$this->blklvl-1];
11847
  // Re-open block tags
11848
  $t = $this->blk[0]['tag'];
11849
  $a = $this->blk[0]['attr'];
11850
+ $this->blklvl = 0;
11851
  for ($b=0; $b<=$save_blklvl;$b++) {
11852
  $tc = $t;
11853
  $ac = $a;
11854
  $t = $this->blk[$b+1]['tag'];
11855
  $a = $this->blk[$b+1]['attr'];
11856
  unset($this->blk[$b+1]);
11857
+ $this->OpenTag($tc,$ac);
11858
  }
11859
  $this->spanlvl = $save_spanlvl;
11860
  $this->InlineProperties = $save_ilp;
11880
 
11881
  // mPDF 5.6.01 - LAYERS
11882
  if (isset($properties['Z-INDEX']) && $this->currentlayer==0) {
11883
+ $v = intval($properties['Z-INDEX']);
11884
  if ($v > 0) {
11885
+ $currblk['z-index'] = $v;
11886
  $this->BeginLayer($v);
11887
  }
11888
  }
11892
 
11893
  if (isset($properties['VISIBILITY'])) {
11894
  $v = strtolower($properties['VISIBILITY']);
11895
+ if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible' && !$this->tableLevel) {
11896
+ $currblk['visibility'] = $v;
11897
  $this->SetVisibility($v);
11898
  }
11899
  }
11901
  if(isset($attr['DIR']) && $attr['DIR']) { $currblk['direction'] = strtolower($attr['DIR']); }
11902
  if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; }
11903
 
11904
+ if (isset($properties['HEIGHT'])) {
11905
+ $currblk['css_set_height'] = $this->ConvertSize($properties['HEIGHT'],($this->h - $this->tMargin - $this->bMargin),$this->FontSize,false);
11906
  if (($currblk['css_set_height'] + $this->y) > $this->PageBreakTrigger && $this->y > $this->tMargin+5 && $currblk['css_set_height'] < ($this->h - ($this->tMargin + $this->bMargin))) { $this->AddPage($this->CurOrientation); }
11907
  }
11908
  else { $currblk['css_set_height'] = false; }
11927
  // Hanging indent - if negative indent: ensure padding is >= indent
11928
  if(!isset($currblk['text_indent'])) { $currblk['text_indent'] = null; }
11929
  if(!isset($currblk['inner_width'])) { $currblk['inner_width'] = null; }
11930
+ $cbti = $this->ConvertSize($currblk['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
11931
  if ($cbti < 0) {
11932
  $hangind = -($cbti);
11933
  $currblk['padding_left'] = max($currblk['padding_left'],$hangind);
11934
  }
11935
 
11936
  if (isset($currblk['css_set_width'])) {
11937
+ if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') {
11938
  // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width)
11939
  $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
11940
  if ($anyextra>0) {
11944
  $currblk['margin_left'] = $currblk['margin_right'] = 0;
11945
  }
11946
  }
11947
+ else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
11948
  // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
11949
  $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']);
11950
  if ($currblk['margin_left'] < 0) {
11951
  $currblk['margin_left'] = 0;
11952
  }
11953
  }
11954
+ else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
11955
  // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
11956
  $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
11957
  if ($currblk['margin_right'] < 0) {
11958
  $currblk['margin_right'] = 0;
11959
  }
11960
  }
11961
+ else {
11962
  // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
11963
  // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
11964
  $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
12007
  $this->kwt_BMoutlines = array();
12008
  $this->kwt_toc = array();
12009
  }
12010
+ else {
12011
+ $this->kwt = false;
12012
  } // *TABLES*
12013
 
12014
  //Save x,y coords in case we need to print borders...
12027
  $properties = $this->readInlineCSS($attr['STYLE']);
12028
  }
12029
 
12030
+ $this->ignorefollowingspaces = true;
12031
 
12032
  $objattr = array();
12033
  $objattr['margin_top'] = 0;
12046
  if (isset($properties['WIDTH'])) { $objattr['width'] = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']); }
12047
  if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
12048
 
12049
+ if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12050
  $objattr['align'] = 'R';
12051
  }
12052
+ if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12053
  $objattr['align'] = 'L';
12054
+ if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12055
  $objattr['align'] = 'C';
12056
  }
12057
  }
12064
 
12065
  if ($this->tableLevel) {
12066
  $objattr['W-PERCENT'] = 100;
12067
+ if (isset($properties['WIDTH']) && stristr($properties['WIDTH'],'%')) {
12068
+ $properties['WIDTH'] += 0; //make "90%" become simply "90"
12069
  $objattr['W-PERCENT'] = $properties['WIDTH'];
12070
  }
12071
+ if (isset($attr['WIDTH']) && stristr($attr['WIDTH'],'%')) {
12072
+ $attr['WIDTH'] += 0; //make "90%" become simply "90"
12073
  $objattr['W-PERCENT'] = $attr['WIDTH'];
12074
  }
12075
  }
12087
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
12088
  }
12089
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
12090
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
12091
  }
12092
  $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
12093
  $this->_saveCellTextBuffer($e, $this->HREF);
12115
  $this->graphs[$gid]['attr'] = $attr;
12116
 
12117
 
12118
+ if (isset($this->graphs[$gid]['attr']['WIDTH']) && $this->graphs[$gid]['attr']['WIDTH']) {
12119
+ $this->graphs[$gid]['attr']['cWIDTH']=$this->ConvertSize($this->graphs[$gid]['attr']['WIDTH'],$pgwidth);
12120
  } // mm
12121
+ if (isset($this->graphs[$gid]['attr']['HEIGHT']) && $this->graphs[$gid]['attr']['HEIGHT']) {
12122
+ $this->graphs[$gid]['attr']['cHEIGHT']=$this->ConvertSize($this->graphs[$gid]['attr']['HEIGHT'],$pgwidth);
12123
  }
12124
 
12125
  $graph_img = print_graph($this->graphs[$gid],$this->blk[$this->blklvl]['inner_width']);
12126
+ if ($graph_img) {
12127
  if(isset($attr['ROTATE'])) {
12128
  if ($attr['ROTATE']==90 || $attr['ROTATE']==-90) {
12129
  $tmpw = $graph_img['w'];
12131
  $graph_img['h']= $tmpw;
12132
  }
12133
  }
12134
+ $attr['SRC'] = $graph_img['file'];
12135
+ $attr['WIDTH'] = $graph_img['w'];
12136
+ $attr['HEIGHT'] = $graph_img['h'];
12137
  }
12138
  else { break; }
12139
 
12158
  $srcpath = $attr['SRC'];
12159
  $orig_srcpath = $attr['ORIG_SRC'];
12160
  $properties = $this->MergeCSS('',$tag,$attr);
12161
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
12162
+ return;
12163
  }
12164
  // mPDF 5.6.01 - LAYERS
12165
  if (isset($properties['Z-INDEX']) && $this->currentlayer==0) {
12166
+ $v = intval($properties['Z-INDEX']);
12167
  if ($v > 0) {
12168
+ $objattr['z-index'] = $v;
12169
  }
12170
  }
12171
 
12172
+ $objattr['visibility'] = 'visible';
12173
  if (isset($properties['VISIBILITY'])) {
12174
  $v = strtolower($properties['VISIBILITY']);
12175
+ if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
12176
+ $objattr['visibility'] = $v;
12177
  }
12178
  }
12179
 
12225
  $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
12226
  if(!$info) {
12227
  $info = $this->_getImage($this->noImageFile);
12228
+ if ($info) {
12229
+ $srcpath = $this->noImageFile;
12230
+ $w = ($info['w'] * (25.4/$this->dpi));
12231
  $h = ($info['h'] * (25.4/$this->dpi));
12232
  }
12233
  }
12248
  $objattr['file'] = $srcpath;
12249
  //Default width and height calculation if needed
12250
  if($w==0 and $h==0) {
12251
+ if ($info['type']=='svg') {
12252
  // SVG units are pixels
12253
  $w = abs($info['w'])/_MPDFK;
12254
  $h = abs($info['h'])/_MPDFK;
12258
  $w=($info['w']/_MPDFK) * (72/$this->img_dpi);
12259
  $h=($info['h']/_MPDFK) * (72/$this->img_dpi);
12260
  }
12261
+ if (isset($properties['IMAGE-RESOLUTION'])) {
12262
  if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi']>0) {
12263
  $w *= $this->img_dpi / $info['set-dpi'];
12264
  $h *= $this->img_dpi / $info['set-dpi'];
12265
  }
12266
  else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
12267
+ $dpi = $m[1];
12268
  if ($dpi > 0) {
12269
  $w *= $this->img_dpi / $dpi;
12270
  $h *= $this->img_dpi / $dpi;
12273
  }
12274
  }
12275
  // IF WIDTH OR HEIGHT SPECIFIED
12276
+ if($w==0) $w=abs($h*$info['w']/$info['h']);
12277
  if($h==0) $h=abs($w*$info['h']/$info['w']);
12278
 
12279
  // mPDF 5.5.15
12352
  $this->InlineProperties[$tag] = $this->saveInlineProperties();
12353
  $properties = $this->MergeCSS('INLINE',$tag,$attr);
12354
 
12355
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
12356
+ return;
12357
  }
12358
  if (isset($attr['R'])) { $objattr['r']=$this->ConvertSize($attr['R'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
12359
+ if(isset($attr['TOP-TEXT'])) {
12360
  $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
12361
  $objattr['top-text'] = $this->lesser_entity_decode($objattr['top-text']);
12362
  if ($this->onlyCoreFonts)
12363
+ $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mb_enc,'UTF-8');
12364
  }
12365
+ if(isset($attr['BOTTOM-TEXT'])) {
12366
  $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
12367
  $objattr['bottom-text'] = $this->lesser_entity_decode($objattr['bottom-text']);
12368
  if ($this->onlyCoreFonts)
12369
+ $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mb_enc,'UTF-8');
12370
  }
12371
  if(isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) { $objattr['space-width'] = $attr['SPACE-WIDTH']; }
12372
  if(isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) { $objattr['char-width'] = $attr['CHAR-WIDTH']; }
12373
 
12374
  // VISIBILITY
12375
+ $objattr['visibility'] = 'visible';
12376
  if (isset($properties['VISIBILITY'])) {
12377
  $v = strtolower($properties['VISIBILITY']);
12378
+ if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible') {
12379
+ $objattr['visibility'] = $v;
12380
  }
12381
  }
12382
  // mPDF 5.5.23
12383
+ if (isset($properties['FONT-SIZE'])) {
12384
  if (strtolower($properties['FONT-SIZE'])=='auto') {
12385
  if ($objattr['top-text'] && $objattr['bottom-text']) {
12386
  $objattr['fontsize'] = -2;
12400
  $objattr['divider'] = strcode2utf($attr['DIVIDER']);
12401
  $objattr['divider'] = $this->lesser_entity_decode($objattr['divider']);
12402
  if ($this->onlyCoreFonts)
12403
+ $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mb_enc,'UTF-8');
12404
 
12405
  }
12406
 
12414
  if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $objattr['fontstyle'] .= 'I'; }
12415
  }
12416
 
12417
+ if (isset($properties['FONT-FAMILY'])) {
12418
  $this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
12419
  }
12420
  $objattr['fontfamily'] = $this->FontFamily;
12518
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['levelid'] = $this->tbctr[$this->tableLevel];
12519
 
12520
  if ($this->tableLevel > $this->innermostTableLevel) { $this->innermostTableLevel = $this->tableLevel; }
12521
+ if ($this->tableLevel > 1) {
12522
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nestedpos'] = array($this->row,$this->col,$this->tbctr[($this->tableLevel-1)]);
12523
  }
12524
  //++++++++++++++++++++++++++++
12525
 
12584
  $this->lastblockbottommargin = 0;
12585
  $this->blockjustfinished=false;
12586
 
12587
+ if ($this->tableLevel==1) {
12588
  $this->tableCJK = false;
12589
  $this->table_lineheight = $this->normalLineheight;
12590
  $table['headernrows'] = 0;
12591
+ $table['footernrows'] = 0;
12592
  $this->base_table_properties = array();
12593
  }
12594
 
12595
+ // ADDED CSS FUNCIONS FOR TABLE
12596
  if ($this->tbCSSlvl==1) {
12597
  $properties = $this->MergeCSS('TOPTABLE',$tag,$attr);
12598
  }
12610
  else if (isset($properties['BACKGROUND'])) { $table['bgcolor'][-1] = $properties['BACKGROUND']; }
12611
  if (isset($properties['VERTICAL-ALIGN'])) { $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
12612
  if (isset($properties['TEXT-ALIGN'])) { $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
12613
+ if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->tableLevel ==1) {
12614
+ $this->shrink_this_table_to_fit = $properties['AUTOSIZE'];
12615
  if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 0; }
12616
  }
12617
+ if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->tableLevel ==1) {
12618
+ $this->table_rotate = $properties['ROTATE'];
12619
  }
12620
  if (isset($properties['TOPNTAIL'])) { $table['topntail'] = $properties['TOPNTAIL']; }
12621
  if (isset($properties['THEAD-UNDERLINE'])) { $table['thead-underline'] = $properties['THEAD-UNDERLINE']; }
12622
 
12623
+ if (isset($properties['BORDER'])) {
12624
  $bord = $this->border_details($properties['BORDER']);
12625
  if ($bord['s']) {
12626
  $table['border'] = _BORDER_ALL;
12630
  $table['border_details']['B'] = $bord;
12631
  }
12632
  }
12633
+ if (isset($properties['BORDER-RIGHT'])) {
12634
  $table['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
12635
+ $this->setBorder($table['border'], _BORDER_RIGHT, $table['border_details']['R']['s']);
12636
  }
12637
+ if (isset($properties['BORDER-LEFT'])) {
12638
  $table['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
12639
+ $this->setBorder($table['border'], _BORDER_LEFT, $table['border_details']['L']['s']);
12640
  }
12641
+ if (isset($properties['BORDER-BOTTOM'])) {
12642
  $table['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
12643
+ $this->setBorder($table['border'], _BORDER_BOTTOM, $table['border_details']['B']['s']);
12644
  }
12645
+ if (isset($properties['BORDER-TOP'])) {
12646
  $table['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
12647
+ $this->setBorder($table['border'], _BORDER_TOP, $table['border_details']['T']['s']);
12648
  }
12649
  if ($table['border']){
12650
  $this->table_border_css_set = 1;
12653
  $this->table_border_css_set = 0;
12654
  }
12655
 
12656
+ if (isset($properties['FONT-FAMILY'])) {
12657
  $this->default_font = $properties['FONT-FAMILY'];
12658
  $this->SetFont($this->default_font,'',0,false);
12659
  }
12660
  $this->base_table_properties['FONT-FAMILY'] = $this->FontFamily; // mPDF 5.4.10
12661
 
12662
+ if (isset($properties['FONT-SIZE'])) {
12663
  // mPDF 5.4.10
12664
  if ($this->tableLevel>1) { $mmsize = $this->ConvertSize($properties['FONT-SIZE'], $this->base_table_properties['FONT-SIZE']); }
12665
  else { $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK); }
12689
  $this->base_table_properties['WORD-SPACING'] = $properties['WORD-SPACING'];
12690
  }
12691
 
12692
+ if (isset($properties['PADDING-LEFT'])) {
12693
  $table['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12694
  }
12695
+ if (isset($properties['PADDING-RIGHT'])) {
12696
  $table['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12697
  }
12698
+ if (isset($properties['PADDING-TOP'])) {
12699
  $table['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12700
  }
12701
+ if (isset($properties['PADDING-BOTTOM'])) {
12702
  $table['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12703
  }
12704
 
12705
+ if (isset($properties['MARGIN-TOP'])) {
12706
+ if ($lastbottommargin) {
12707
  $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12708
  if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
12709
  else { $properties['MARGIN-TOP'] = 0; }
12710
  }
12711
+ $table['margin']['T'] = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12712
  }
12713
 
12714
+ if (isset($properties['MARGIN-BOTTOM'])) {
12715
+ $table['margin']['B'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12716
  }
12717
  if (isset($properties['MARGIN-LEFT'])) {
12718
+ $table['margin']['L'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12719
  }
12720
 
12721
  if (isset($properties['MARGIN-RIGHT'])) {
12722
+ $table['margin']['R'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12723
  }
12724
+ if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12725
+ $table['a'] = 'C';
12726
  }
12727
+ else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
12728
+ $table['a'] = 'R';
12729
  }
12730
+ else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
12731
+ $table['a'] = 'L';
12732
  }
12733
 
12734
+ if (isset($properties['LINE-HEIGHT']) && $this->tableLevel==1) {
12735
  $this->table_lineheight = $this->fixLineheight($properties['LINE-HEIGHT']);
12736
  if (!$this->table_lineheight) { $this->table_lineheight = $this->normalLineheight; }
12737
  }
12738
 
12739
+ if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE'])=='SEPARATE') {
12740
+ $table['borders_separate'] = true;
12741
  }
12742
+ else {
12743
+ $table['borders_separate'] = false;
12744
  }
12745
 
12746
+ if (isset($properties['BORDER-SPACING-H'])) {
12747
+ $table['border_spacing_H'] = $this->ConvertSize($properties['BORDER-SPACING-H'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12748
  }
12749
+ if (isset($properties['BORDER-SPACING-V'])) {
12750
+ $table['border_spacing_V'] = $this->ConvertSize($properties['BORDER-SPACING-V'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
12751
  }
12752
 
12753
+ if (isset($properties['EMPTY-CELLS'])) {
12754
  $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
12755
  }
12756
+ else { $table['empty_cells'] = ''; }
12757
 
12758
  if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE'])=='AVOID' && $this->tableLevel==1 && !$this->writingHTMLfooter) {
12759
+ $this->table_keep_together = true;
12760
  }
12761
+ else if ($this->tableLevel==1) {
12762
+ $this->table_keep_together = false;
12763
  }
12764
  if (isset($properties['PAGE-BREAK-AFTER']) && $this->tableLevel==1) {
12765
  $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
12766
  }
12767
 
12768
 
12769
+ if (isset($properties['OVERFLOW'])) {
12770
  $table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
12771
  if (($this->ColActive || $this->tableLevel>1) && $table['overflow']=='visible') { unset($table['overflow']); }
12772
  }
12774
  $properties = array();
12775
 
12776
  if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; }
12777
+ else if (isset($attr['CELLSPACING'])) {
12778
+ $table['border_spacing_H'] = $table['border_spacing_V'] = $this->ConvertSize($attr['CELLSPACING'],$this->blk[$this->blklvl]['inner_width']);
12779
  }
12780
 
12781
 
12801
  $this->table_border_attr_set = 0;
12802
  }
12803
  if (isset($attr['ALIGN'])) { $table['a'] = $align[strtolower($attr['ALIGN'])]; }
12804
+ if (!$table['a']) {
12805
  if ($table['direction'] == 'rtl' ) { $table['a'] = 'R'; }
12806
  else { $table['a'] = 'L'; }
12807
  }
12810
  if (isset($attr['WIDTH']) && $attr['WIDTH']) { $w = $attr['WIDTH']; }
12811
  if ($w) { // set here or earlier in $properties
12812
  $maxwidth = $this->blk[$this->blklvl]['inner_width'];
12813
+ if ($table['borders_separate']) {
12814
  $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['border_details']['L']['w']/2 + $table['border_details']['R']['w']/2;
12815
  }
12816
+ else {
12817
  $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2;
12818
  }
12819
+ if (strpos($w,'%') && $this->tableLevel == 1 && !$this->ignore_table_percents ) {
12820
  // % needs to be of inner box without table margins etc.
12821
  $maxwidth -= $tblblw ;
12822
  $wmm = $this->ConvertSize($w,$maxwidth,$this->FontSize,false);
12823
  $table['w'] = $wmm + $tblblw ;
12824
  }
12825
+ if (strpos($w,'%') && $this->tableLevel > 1 && !$this->ignore_table_percents && $this->keep_table_proportions) {
12826
  $table['wpercent'] = $w + 0; // makes 80% -> 80
12827
  }
12828
  if (!strpos($w,'%') && !$this->ignore_table_widths ) {
12834
  }
12835
  }
12836
 
12837
+ if (isset($attr['AUTOSIZE']) && $this->tableLevel==1) {
12838
+ $this->shrink_this_table_to_fit = $attr['AUTOSIZE'];
12839
  if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 1; }
12840
  }
12841
+ if (isset($attr['ROTATE']) && $this->tableLevel==1) {
12842
+ $this->table_rotate = $attr['ROTATE'];
12843
  }
12844
 
12845
  //++++++++++++++++++++++++++++
12865
  $this->kwt_saved = true;
12866
  }
12867
 
12868
+ if ($this->tableLevel==1 && $this->useGraphs) {
12869
  if (isset($attr['ID']) && $attr['ID']) { $this->currentGraphId = strtoupper($attr['ID']); }
12870
  else { $this->currentGraphId = '0'; }
12871
  $this->graphs[$this->currentGraphId] = array();
12879
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12880
  $this->tbCSSlvl++;
12881
  $this->tablethead = 1;
12882
+ $this->tabletfoot = 0;
12883
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12884
  if (isset($properties['FONT-WEIGHT'])) {
12885
  if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->thead_font_weight = 'B'; }
12907
  case 'TFOOT':
12908
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12909
  $this->tbCSSlvl++;
12910
+ $this->tabletfoot = 1;
12911
  $this->tablethead = 0;
12912
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12913
  if (isset($properties['FONT-WEIGHT'])) {
12919
  if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->tfoot_font_style = 'I'; }
12920
  else { $this->tfoot_font_style = ''; }
12921
  }
12922
+ if (isset($properties['FONT-VARIANT'])) {
12923
  if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->tfoot_font_smCaps = 'S'; }
12924
  else { $this->tfoot_font_smCaps = ''; }
12925
  }
12951
  $this->col = -1;
12952
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
12953
 
12954
+ if (!$this->simpleTables && (!isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate']) || !$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate'])) {
12955
  if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-left'][$this->row] = $properties['BORDER-LEFT']; }
12956
  if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row] = $properties['BORDER-RIGHT']; }
12957
  if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-top'][$this->row] = $properties['BORDER-TOP']; }
12978
 
12979
  case 'TH':
12980
  case 'TD':
12981
+ $this->ignorefollowingspaces = true;
12982
  $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
12983
  $this->tbCSSlvl++;
12984
  $this->InlineProperties = array();
13056
  $c['border_details']['L'] = $table['border_details']['L'];
13057
  $c['border_details']['T'] = $table['border_details']['T'];
13058
  $c['border_details']['B'] = $table['border_details']['B'];
13059
+ $c['border'] = $table['border'];
13060
+ $c['border_details']['L']['dom'] = 1;
13061
+ $c['border_details']['R']['dom'] = 1;
13062
+ $c['border_details']['T']['dom'] = 1;
13063
+ $c['border_details']['B']['dom'] = 1;
13064
  }
13065
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13066
  $table['simple']['border_details']['R'] = $table['border_details']['R'];
13067
  $table['simple']['border_details']['L'] = $table['border_details']['L'];
13068
  $table['simple']['border_details']['T'] = $table['border_details']['T'];
13069
  $table['simple']['border_details']['B'] = $table['border_details']['B'];
13070
+ $table['simple']['border'] = $table['border'];
13071
  }
13072
  }
13073
+ }
13074
  // INHERITED THEAD CSS Properties
13075
+ if ($this->tablethead) {
13076
+ if ($this->thead_valign_default) $c['va'] = $align[strtolower($this->thead_valign_default)];
13077
+ if ($this->thead_textalign_default) $c['a'] = $align[strtolower($this->thead_textalign_default)];
13078
  if ($this->thead_font_weight == 'B') { $this->SetStyle('B',true); }
13079
  if ($this->thead_font_style == 'I') { $this->SetStyle('I',true); }
13080
  if ($this->thead_font_smCaps == 'S') { $this->SetStyle('S',true); }
13081
  }
13082
 
13083
  // INHERITED TFOOT CSS Properties
13084
+ if ($this->tabletfoot) {
13085
+ if ($this->tfoot_valign_default) $c['va'] = $align[strtolower($this->tfoot_valign_default)];
13086
+ if ($this->tfoot_textalign_default) $c['a'] = $align[strtolower($this->tfoot_textalign_default)];
13087
  if ($this->tfoot_font_weight == 'B') { $this->SetStyle('B',true); }
13088
  if ($this->tfoot_font_style == 'I') { $this->SetStyle('I',true); }
13089
  if ($this->tfoot_font_style == 'S') { $this->SetStyle('S',true); }
13091
 
13092
 
13093
  if ($this->trow_text_rotate){
13094
+ $c['R'] = $this->trow_text_rotate;
13095
  }
13096
 
13097
+ $this->cell_border_dominance_L = 0;
13098
+ $this->cell_border_dominance_R = 0;
13099
+ $this->cell_border_dominance_T = 0;
13100
+ $this->cell_border_dominance_B = 0;
13101
 
13102
  $properties = $this->MergeCSS('TABLE',$tag,$attr);
13103
  $properties = $this->array_merge_recursive_unique($this->base_table_properties, $properties);
13109
 
13110
  if (isset($properties['LETTER-SPACING']) && ($properties['LETTER-SPACING'] || $properties['LETTER-SPACING']==='0') && strtoupper($properties['LETTER-SPACING']) != 'NORMAL') {
13111
  $this->lSpacingCSS = strtoupper($properties['LETTER-SPACING']);
13112
+ $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
13113
  }
13114
+ else {
13115
  $this->lSpacingCSS = '';
13116
+ $this->fixedlSpacing = false;
13117
  }
13118
+ if (isset($properties['WORD-SPACING']) && strtoupper($properties['WORD-SPACING']) != 'NORMAL') {
13119
  $this->wSpacingCSS = strtoupper($properties['WORD-SPACING']);
13120
+ $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
13121
  }
13122
+ else {
13123
+ $this->minwSpacing = 0;
13124
  $this->wSpacingCSS = '';
13125
  }
13126
 
13132
  if (isset($properties['TEXT-ALIGN'])) { $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
13133
 
13134
  if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE']==="0")){
13135
+ $c['R'] = $properties['TEXT-ROTATE'];
13136
  }
13137
+ if (isset($properties['BORDER'])) {
13138
  $bord = $this->border_details($properties['BORDER']);
13139
  if ($bord['s']) {
13140
  if (!$this->simpleTables){
13143
  $c['border_details']['L'] = $bord;
13144
  $c['border_details']['T'] = $bord;
13145
  $c['border_details']['B'] = $bord;
13146
+ $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
13147
+ $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
13148
+ $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
13149
+ $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
13150
  }
13151
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13152
  $table['simple']['border'] = _BORDER_ALL;
13158
  }
13159
  }
13160
  if (!$this->simpleTables){
13161
+ if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
13162
  $c['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
13163
+ $this->setBorder($c['border'], _BORDER_RIGHT, $c['border_details']['R']['s']);
13164
+ $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
13165
  }
13166
+ if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
13167
  $c['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
13168
+ $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
13169
+ $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
13170
  }
13171
+ if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
13172
  $c['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
13173
+ $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
13174
+ $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
13175
  }
13176
+ if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
13177
  $c['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
13178
+ $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
13179
+ $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
13180
  }
13181
  }
13182
  else if ($this->simpleTables && $this->row==0 && $this->col==0){
13183
+ if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
13184
  $bord = $this->border_details($properties['BORDER-LEFT']);
13185
  if ($bord['s']) { $table['simple']['border'] = _BORDER_ALL; }
13186
  else { $table['simple']['border'] = 0; }
13193
 
13194
  if ($this->simpleTables && $this->row==0 && $this->col==0 && !$table['borders_separate'] && $table['simple']['border'] ){
13195
  $table['border_details'] = $table['simple']['border_details'];
13196
+ $table['border'] = $table['simple']['border'];
13197
  }
13198
 
13199
  // Border set on TR (if collapsed only)
13200
  if (!$table['borders_separate'] && !$this->simpleTables && isset($table['trborder-left'][$this->row])) {
13201
+ if ($this->col==0) {
13202
  $left = $this->border_details($table['trborder-left'][$this->row]);
13203
  $c['border_details']['L'] = $left;
13204
+ $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
13205
  }
13206
  $c['border_details']['B'] = $this->border_details($table['trborder-bottom'][$this->row]);
13207
+ $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
13208
  $c['border_details']['T'] = $this->border_details($table['trborder-top'][$this->row]);
13209
+ $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
13210
  }
13211
 
13212
  if ($this->packTableData && !$this->simpleTables) {
13215
  unset($c['border_details']);
13216
  }
13217
 
13218
+ if (isset($properties['PADDING-LEFT'])) {
13219
  $c['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13220
  }
13221
+ if (isset($properties['PADDING-RIGHT'])) {
13222
  $c['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13223
  }
13224
+ if (isset($properties['PADDING-BOTTOM'])) {
13225
  $c['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13226
  }
13227
+ if (isset($properties['PADDING-TOP'])) {
13228
  $c['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13229
  }
13230
 
13231
  $w = '';
13232
  if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
13233
  if (isset($attr['WIDTH'])) { $w = $attr['WIDTH']; }
13234
+ if ($w) {
13235
  if (strpos($w,'%') && !$this->ignore_table_percents ) { $c['wpercent'] = $w + 0; } // makes 80% -> 80
13236
  else if (!strpos($w,'%') && !$this->ignore_table_widths ) { $c['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
13237
  }
13240
 
13241
  if (isset($properties['COLOR'])) {
13242
  $cor = $this->ConvertColor($properties['COLOR']);
13243
+ if ($cor) {
13244
  $this->colorarray = $cor;
13245
+ $this->SetTColor($cor);
13246
  }
13247
  }
13248
  if (isset($properties['FONT-FAMILY'])) {
13249
  $this->SetFont($properties['FONT-FAMILY'],'',0,false);
13250
  }
13251
+ if (isset($properties['FONT-SIZE'])) {
13252
  $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
13253
  if ($mmsize) {
13254
  $this->SetFontSize($mmsize*(_MPDFK),false);
13296
 
13297
  if (isset($attr['BGCOLOR'])) $c['bgcolor'] = $attr['BGCOLOR'];
13298
  if (isset($attr['TEXT-ROTATE'])) {
13299
+ $c['R'] = $attr['TEXT-ROTATE'];
13300
  }
13301
  if (isset($attr['NOWRAP']) && $attr['NOWRAP']) $c['nowrap']= 1;
13302
 
13306
 
13307
  $cs = $rs = 1;
13308
  if (isset($attr['COLSPAN']) && $attr['COLSPAN']>1) $cs = $this->cell[$this->row][$this->col]['colspan'] = $attr['COLSPAN'];
13309
+ if ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] < $this->col+$cs) {
13310
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] = $this->col+$cs;
13311
  } // following code moved outside if...
13312
  for($l=$this->col; $l < $this->col+$cs ;$l++) {
13313
  if ($l-$this->col) $this->cell[$this->row][$l] = 0;
13336
  $this->lastoptionaltag = ''; // Save current HTML specified optional endtag
13337
  $this->listCSSlvl++;
13338
  if((!$this->tableLevel) && ($this->listlvl == 0)) {
13339
+ $blockstate = 0;
13340
  //if ($this->lastblocklevelchange == 1) { $blockstate = -1; } // Top margins/padding only
13341
  //else if ($this->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding
13342
  // called from block after new div e.g. <div> ... <ol> ... Outputs block top margin/border and padding
13382
  else {
13383
  $properties = $this->MergeCSS('LIST',$tag,$attr);
13384
  }
13385
+ if (!empty($properties)) $this->setCSS($properties,'LIST');
13386
  // List-type
13387
 
13388
  $this->listtype = '';
13389
  if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listtype = $attr['TYPE']; }
13390
+ else if (isset($properties['LIST-STYLE-TYPE'])) {
13391
  $this->listtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
13392
  }
13393
+ else if (isset($properties['LIST-STYLE'])) {
13394
  $this->listtype = $this->_getListStyle($properties['LIST-STYLE']);
13395
  }
13396
  if (!$this->listtype) {
13432
 
13433
  // TOP LEVEL ONLY
13434
  if ($this->listlvl == 1) {
13435
+ if (isset($properties['MARGIN-TOP'])) {
13436
+ if ($lastbottommargin) {
13437
  $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13438
  if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
13439
  else { $properties['MARGIN-TOP'] = 0; }
13440
  }
13441
  $this->DivLn($this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false),$this->blklvl,true,1); // collapsible
13442
  }
13443
+ if (isset($properties['MARGIN-BOTTOM'])) {
13444
+ $this->list_margin_bottom = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
13445
  }
13446
 
13447
  if (isset($this->blk[$this->blklvl]['line_height'])) {
13455
  $this->list_indent[$this->listlvl][$occur] = 5; // mm default indent for each level
13456
  if (isset($properties['TEXT-INDENT'])) { $this->list_indent[$this->listlvl][$occur] = $this->ConvertSize($properties['TEXT-INDENT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
13457
 
13458
+ if (isset($properties['TEXT-ALIGN'])) {
13459
+ $this->list_align[$this->listlvl][$occur] = $align[strtolower($properties['TEXT-ALIGN'])];
13460
  }
13461
 
13462
 
13463
+ if (isset($properties['LINE-HEIGHT'])) {
13464
  $this->list_lineheight[$this->listlvl][$occur] = $this->fixLineheight($properties['LINE-HEIGHT']);
13465
  }
13466
+ else if ($this->listlvl>1 && isset($this->list_lineheight[($this->listlvl - 1)][1])) {
13467
  $this->list_lineheight[$this->listlvl][$occur] = end($this->list_lineheight[($this->listlvl - 1)]);
13468
  }
13469
+ if (!isset($this->list_lineheight[$this->listlvl][$occur]) || !$this->list_lineheight[$this->listlvl][$occur]) {
13470
+ $this->list_lineheight[$this->listlvl][$occur] = $this->normalLineheight;
13471
  }
13472
 
13473
  $this->InlineProperties['LIST'][$this->listlvl][$occur] = $this->saveInlineProperties();
13491
  $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13492
  }
13493
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
13494
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13495
  }
13496
  $this->cell[$this->row][$this->col]['s'] = 0 ;
13497
  }
13519
  $blt = $this->listnum.$this->list_number_suffix;
13520
  break;
13521
  default:
13522
+ if ($this->listlvl % 3 == 1 && $this->_charDefined($this->CurrentFont['cw'],8226)) { $blt = "\xe2\x80\xa2"; } // &#8226;
13523
+ else if ($this->listlvl % 3 == 2 && $this->_charDefined($this->CurrentFont['cw'],9900)) { $blt = "\xe2\x9a\xac"; } // &#9900;
13524
+ else if ($this->listlvl % 3 == 0 && $this->_charDefined($this->CurrentFont['cw'],9642)) { $blt = "\xe2\x96\xaa"; } // &#9642;
13525
  else { $blt = '-'; }
13526
  break;
13527
  }
13528
 
13529
  // change to &nbsp; spaces
13530
+ if ($this->usingCoreFont) {
13531
+ $ls = str_repeat(chr(160).chr(160),($this->listlvl-1)*2) . $blt . ' ';
13532
  }
13533
  else {
13534
+ $ls = str_repeat("\xc2\xa0\xc2\xa0",($this->listlvl-1)*2) . $blt . ' ';
13535
  }
13536
 
13537
  $this->_saveCellTextBuffer($ls, $this->HREF);
13571
 
13572
  // List-type
13573
  if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listitemtype = $attr['TYPE']; }
13574
+ else if (isset($properties['LIST-STYLE-TYPE'])) {
13575
  $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
13576
  }
13577
+ else if (isset($properties['LIST-STYLE'])) {
13578
  $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE']);
13579
  }
13580
  else $this->listitemtype = '';
13587
  function _getListStyle($ls) {
13588
  if (stristr($ls,'decimal')) { return '1'; }
13589
  /* CSS3 list-styles numeric (selected) + I added tamil
13590
+ arabic-indic | bengali | devanagari | gujarati | gurmukhi | kannada | malayalam | oriya | persian | telugu | thai | urdu
13591
  */
13592
+ else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu)/i',$ls,$m)) {
13593
+ return strtolower(trim($m[1]));
13594
  }
13595
  else if (stristr($ls,'lower-roman')) { return 'i'; }
13596
  else if (stristr($ls,'upper-roman')) { return 'I'; }
13617
  }
13618
 
13619
 
13620
+ if($tag=='FONT' || $tag=='SPAN' || $tag=='CODE' || $tag=='KBD' || $tag=='SAMP' || $tag=='TT' || $tag=='VAR'
13621
  || $tag=='INS' || $tag=='STRONG' || $tag=='CITE' || $tag=='SUB' || $tag=='SUP' || $tag=='S' || $tag=='STRIKE' || $tag=='DEL'
13622
  || $tag=='Q' || $tag=='EM' || $tag=='B' || $tag=='I' || $tag=='U' | $tag=='SMALL' || $tag=='BIG' || $tag=='ACRONYM'
13623
+ || $tag=='MARK' || $tag=='TIME' || $tag=='PROGRESS' || $tag=='METER'
13624
  ) { // mPDF 5.5.09
13625
 
13626
  if ($tag == 'SPAN') {
13628
  unset($this->InlineProperties['SPAN'][$this->spanlvl]);
13629
  $this->spanlvl--;
13630
  }
13631
+ else {
13632
  if (isset($this->InlineProperties[$tag]) && $this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
13633
  unset($this->InlineProperties[$tag]);
13634
  }
13641
 
13642
 
13643
  if($tag=='A') {
13644
+ $this->HREF='';
13645
  if (isset($this->InlineProperties['A'])) { $this->restoreInlineProperties($this->InlineProperties['A']); }
13646
  unset($this->InlineProperties['A']);
13647
  }
13648
 
13649
  if($tag=='LEGEND') { // mPDF 5.4.18
13650
+ if (count($this->textbuffer) && !$this->tableLevel) {
13651
+ $leg = $this->textbuffer[(count($this->textbuffer)-1)];
13652
  unset($this->textbuffer[(count($this->textbuffer)-1)]);
13653
  $this->textbuffer = array_values($this->textbuffer);
13654
  $this->blk[$this->blklvl]['border_legend'] = $leg;
13666
 
13667
  // *********** BLOCKS ********************
13668
  // mPDF 5.4.18
13669
+ if($tag=='P' || $tag=='DIV' || $tag=='H1' || $tag=='H2' || $tag=='H3' || $tag=='H4' || $tag=='H5' || $tag=='H6' || $tag=='PRE'
13670
+ || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DT' || $tag=='DD' || $tag=='DL'
13671
+ || $tag=='CAPTION' || $tag=='FIELDSET'
13672
+ || $tag=='ARTICLE' || $tag=='ASIDE' || $tag=='FIGURE' || $tag=='FIGCAPTION' || $tag=='FOOTER' || $tag=='HEADER' || $tag=='HGROUP'
13673
  || $tag=='NAV' || $tag=='SECTION' || $tag=='DETAILS' || $tag=='SUMMARY'
13674
  ) { // mPDF 5.5.09 // mPDF 5.5.22
13675
 
13681
 
13682
  if($this->tableLevel) {
13683
  if ($this->linebreakjustfinished) { $this->blockjustfinished=false; }
13684
+ if (isset($this->InlineProperties['BLOCKINTABLE'])) {
13685
  if ($this->InlineProperties['BLOCKINTABLE']) { $this->restoreInlineProperties($this->InlineProperties['BLOCKINTABLE']); }
13686
  unset($this->InlineProperties['BLOCKINTABLE']);
13687
  }
13719
  $this->PaintDivBB('',$blockstate);
13720
  }
13721
  else {
13722
+ $this->printbuffer($this->textbuffer,$blockstate);
13723
  }
13724
 
13725
 
13726
  $this->textbuffer=array();
13727
 
13728
  if ($this->blk[$this->blklvl]['keep_block_together']) {
13729
+ $this->printdivbuffer();
13730
  }
13731
 
13732
  if ($this->kwt) {
13752
  $this->EndLayer();
13753
  }
13754
 
13755
+ if ($this->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
13756
  if ($this->blk[$this->blklvl]['tag'] == $tag) {
13757
  unset($this->blk[$this->blklvl]);
13758
  $this->blklvl--;
13790
  $this->blk[0]['inner_width'] =& $this->pgwidth;
13791
  $this->blk[0]['blockContext'] = $this->blockContext;
13792
  $properties = $this->MergeCSS('BLOCK','BODY','');
13793
+ $this->setCSS($properties,'','BODY');
13794
  $this->blklvl++;
13795
  $currblk =& $this->blk[$this->blklvl];
13796
  $prevblk =& $this->blk[$this->blklvl-1];
13807
  // Re-open block tags
13808
  $t = $this->blk[0]['tag'];
13809
  $a = $this->blk[0]['attr'];
13810
+ $this->blklvl = 0;
13811
  for ($b=0; $b<=$save_blklvl;$b++) {
13812
  $tc = $t;
13813
  $ac = $a;
13814
  $t = $this->blk[$b+1]['tag'];
13815
  $a = $this->blk[$b+1]['attr'];
13816
  unset($this->blk[$b+1]);
13817
+ $this->OpenTag($tc,$ac);
13818
  }
13819
  $this->spanlvl = $save_spanlvl;
13820
  $this->InlineProperties = $save_ilp;
13837
  // Added for correct calculation of cell column width - otherwise misses the last line if not end </p> etc.
13838
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
13839
  if (!is_array($this->cell[$this->row][$this->col])) { $this->Error("You may have an error in your HTML code e.g. &lt;/td&gt;&lt;/td&gt;"); }
13840
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13841
  }
13842
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
13843
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
13844
  }
13845
 
13846
  // Remove last <br> if at end of cell
13856
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['ptr'] += $clen;
13857
  }
13858
 
13859
+ if ($this->tablethead) {
13860
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead'][$this->row] = true;
13861
  if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] , ($this->row+1)); }
13862
  }
13863
+ if ($this->tabletfoot) {
13864
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true;
13865
  if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] , ($this->row+1 - $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] )); }
13866
  }
13880
  }
13881
  else { $cell = $c; }
13882
  $cell['border_details']['R'] = $this->border_details($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row]);
13883
+ $this->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
13884
  if ($this->packTableData) {
13885
  $c['borderbin'] = $this->_packCellBorder($cell);
13886
  unset($c['border']);
13889
  else { $c = $cell; }
13890
  }
13891
  if ($this->cacheTables) {
13892
+ $fh = fopen($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cache'], "r+b");
13893
  $this->_cacheUpdateBorder($c, $fh, $this->cell[$this->row][$this->col]);
13894
  fclose($fh);
13895
  }
13970
  foreach($this->table[($this->tableLevel+1)] AS $nid=>$nested) {
13971
  $this->table[($this->tableLevel+1)][$nid]['nestedpos'][0] -= count($temptf);
13972
  }
13973
+ }
13974
  $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = array_merge($temp, $temptf);
13975
 
13976
  // Update other arays set on row number
14036
  $this->base_table_properties = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['baseProperties'];
14037
  $this->cell = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'];
14038
  // mPDF 5.4.10
14039
+ if (isset($this->cell['PARENTCELL'])) {
14040
  if ($this->cell['PARENTCELL']) { $this->restoreInlineProperties($this->cell['PARENTCELL']); }
14041
  unset($this->cell['PARENTCELL']);
14042
  }
14053
  $this->_saveCellTextBuffer($e);
14054
  $this->cell[$this->row][$this->col]['s'] += $tl ;
14055
  if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
14056
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
14057
  }
14058
  elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
14059
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
14060
  }
14061
  $this->cell[$this->row][$this->col]['s'] = 0;// reset
14062
  if ((isset($this->cell[$this->row][$this->col]['nestedmaw']) && $this->cell[$this->row][$this->col]['nestedmaw'] < $tmaw) || !isset($this->cell[$this->row][$this->col]['nestedmaw'])) { $this->cell[$this->row][$this->col]['nestedmaw'] = $tmaw ; }
14076
  $this->cellPaddingB = 0;
14077
 
14078
  if (isset($this->table[1][1]['overflow']) && $this->table[1][1]['overflow']=='visible') {
14079
+ if ($this->kwt || $this->table_rotate || $this->table_keep_together || $this->ColActive) {
14080
  $this->kwt = false;
14081
  $this->table_rotate = 0;
14082
  $this->table_keep_together = false;
14089
  if (!$this->kwt_saved) { $this->kwt_height = 0; }
14090
 
14091
  list($check,$tablemiw) = $this->_tableColumnWidth($this->table[1][1],true);
14092
+ $save_table = $this->table;
14093
  if ($this->cacheTables) { $this->_backupCacheFiles(); }
14094
  $reset_to_minimum_width = false;
14095
  $added_page = false;
14096
 
14097
  if ($check > 1) {
14098
+ if ($check > $this->shrink_this_table_to_fit && $this->table_rotate) {
14099
  if ($this->y != $this->tMargin) {
14100
  $this->AddPage($this->CurOrientation);
14101
+ $this->kwt_moved = true;
14102
  }
14103
  $added_page = true;
14104
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14150
  if ($this->cacheTables) {
14151
  $c = $this->_uncacheCell($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol], $this->table[($lvl-1)][$parentnid]['cache'], null);
14152
  }
14153
+ else
14154
  $c =& $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol];
14155
 
14156
  if (isset($c['colspan']) && $c['colspan']> 1) {
14157
  $parentwidth = 0;
14158
  for($cs=0;$cs<$c['colspan'] ; $cs++) {
14159
+ $parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
14160
  }
14161
  }
14162
  else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
14167
  if ($this->packTableData) {
14168
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
14169
  }
14170
+ else {
14171
  $br = $c['border_details']['R']['w'];
14172
  $bl = $c['border_details']['L']['w'];
14173
  }
14224
  $r = 0; $c = 0; $p = 0; $y = 0;
14225
  while (!$finished) {
14226
  list($finished,$r,$c,$p,$y,$y0) = $this->_tableWrite($this->table[1][1],true,$r,$c,$p,$y);
14227
+ if (!$finished) {
14228
+ $this->AddPage($this->CurOrientation);
14229
  // If printed something on first spread, set same y
14230
  if ($r==0 && $y0 > -1) { $this->y = $y0; }
14231
  }
14235
  $recalculate = 1;
14236
  $forcerecalc = false;
14237
  // RESIZING ALGORITHM
14238
+ if ($maxrowheight > $fullpage) {
14239
+ $recalculate = $this->tbsqrt($maxrowheight / $fullpage, 1);
14240
  $forcerecalc = true;
14241
  }
14242
  else if ($this->table_rotate) { // NB $remainingpage == $fullpage == the width of the page
14243
+ if ($tableheight > $remainingpage) {
14244
  // If can fit on remainder of page whilst respecting autsize value..
14245
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
14246
+ $recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
14247
  }
14248
  else if (!$added_page) {
14249
  if ($this->y != $this->tMargin) {
14250
  $this->AddPage($this->CurOrientation);
14251
+ $this->kwt_moved = true;
14252
  }
14253
  $added_page = true;
14254
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14258
  }
14259
  else { $recalculate = 1; }
14260
  }
14261
+ else if ($this->table_keep_together || ($this->table[1][1]['nr']==1 && !$this->writingHTMLfooter)) {
14262
+ if ($tableheight > $fullpage) {
14263
  if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, 1)) <= $this->shrink_this_table_to_fit) {
14264
+ $recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
14265
  }
14266
  else if ($this->tableMinSizePriority) {
14267
+ $this->table_keep_together = false;
14268
+ $recalculate = 1.001;
14269
  }
14270
  else {
14271
  if ($this->y != $this->tMargin) { // mPDF 5.1
14272
  $this->AddPage($this->CurOrientation);
14273
+ $this->kwt_moved = true;
14274
  }
14275
  $added_page = true;
14276
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14277
+ $recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
14278
  }
14279
  }
14280
+ else if ($tableheight > $remainingpage) {
14281
  // If can fit on remainder of page whilst respecting autsize value..
14282
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
14283
+ $recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
14284
  }
14285
  else {
14286
  if ($this->y != $this->tMargin) {
14287
  $this->AddPage($this->CurOrientation);
14288
  $this->kwt_moved = true;
14289
+ }
14290
  $added_page = true;
14291
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14292
+ $recalculate = 1.001;
14293
  }
14294
  }
14295
  else { $recalculate = 1; }
14296
  }
14297
  else { $recalculate = 1; }
14298
 
14299
+ if ($recalculate > $this->shrink_this_table_to_fit && !$forcerecalc) { $recalculate = $this->shrink_this_table_to_fit; }
14300
 
14301
  $iteration = 1;
14302
 
14335
  if ($this->cacheTables) {
14336
  $c = $this->_uncacheCell($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol], $this->table[($lvl-1)][$parentnid]['cache'], null);
14337
  }
14338
+ else
14339
  $c =& $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol];
14340
 
14341
  if (isset($c['colspan']) && $c['colspan']> 1) {
14342
  $parentwidth = 0;
14343
  for($cs=0;$cs<$c['colspan'] ; $cs++) {
14344
+ $parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
14345
  }
14346
  }
14347
  else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
14351
  if ($this->packTableData) {
14352
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
14353
  }
14354
+ else {
14355
  $br = $c['border_details']['R']['w'];
14356
  $bl = $c['border_details']['L']['w'];
14357
  }
14406
  // RESIZING ALGORITHM
14407
 
14408
  if ($maxrowheight > $fullpage) { $recalculate = $this->tbsqrt($maxrowheight / $fullpage, $iteration); $iteration++; }
14409
+ else if ($this->table_rotate && $tableheight > $remainingpage && !$added_page) {
14410
  // If can fit on remainder of page whilst respecting autosize value..
14411
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14412
+ $recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
14413
  }
14414
  else {
14415
+ if (!$added_page) {
14416
+ $this->AddPage($this->CurOrientation);
14417
  $added_page = true;
14418
+ $this->kwt_moved = true;
14419
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14420
  }
14421
  // 0.001 to force it to recalculate
14423
  }
14424
  }
14425
  else if ($this->table_keep_together || ($this->table[1][1]['nr']==1 && !$this->writingHTMLfooter)) {
14426
+ if ($tableheight > $fullpage) {
14427
  if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14428
+ $recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14429
  }
14430
  else if ($this->tableMinSizePriority) {
14431
+ $this->table_keep_together = false;
14432
+ $recalculate = (1 / $this->shrin_k) + 0.001;
14433
  }
14434
  else {
14435
  if (!$added_page && $this->y != $this->tMargin) {
14436
  $this->AddPage($this->CurOrientation);
14437
  $added_page = true;
14438
+ $this->kwt_moved = true;
14439
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14440
  }
14441
+ $recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14442
  }
14443
  }
14444
+ else if ($tableheight > $remainingpage) {
14445
  // If can fit on remainder of page whilst respecting autosize value..
14446
  if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
14447
+ $recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
14448
  }
14449
  else {
14450
+ if (!$added_page) {
14451
+ $this->AddPage($this->CurOrientation);
14452
  $added_page = true;
14453
+ $this->kwt_moved = true;
14454
  $this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
14455
  }
14456
 
14457
+ //$recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
14458
  $recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
14459
  }
14460
  }
14465
 
14466
 
14467
  if ($maxfirstrowheight > $remainingpage && !$added_page && !$this->table_rotate && !$this->ColActive && !$this->table_keep_together && !$this->writingHTMLheader && !$this->writingHTMLfooter) {
14468
+ $this->AddPage($this->CurOrientation);
14469
  $this->kwt_moved = true;
14470
  }
14471
 
14499
 
14500
  $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
14501
 
14502
+ $this->maxPosR = max($this->maxPosR , ($this->x + $this->table[1][1]['w']));
14503
 
14504
  $this->blockjustfinished=true;
14505
  $this->lastblockbottommargin = $this->table[1][1]['margin']['B'];
14527
  $this->shrink_this_table_to_fit = 0;
14528
 
14529
  unset($this->table);
14530
+ $this->table=array(); //array
14531
  $this->tableLevel=0;
14532
  $this->tbctr=array();
14533
  $this->innermostTableLevel=0;
14535
  $this->tablecascadeCSS = array();
14536
 
14537
  unset($this->cell);
14538
+ $this->cell=array(); //array
14539
 
14540
  $this->col=-1; //int
14541
  $this->row=-1; //int
14580
  $this->blk[0]['inner_width'] =& $this->pgwidth;
14581
  $this->blk[0]['blockContext'] = $this->blockContext;
14582
  $properties = $this->MergeCSS('BLOCK','BODY','');
14583
+ $this->setCSS($properties,'','BODY');
14584
  }
14585
 
14586
  if ($this->restoreBlockPagebreaks) {
14588
  // Re-open block tags
14589
  $t = $this->blk[0]['tag'];
14590
  $a = $this->blk[0]['attr'];
14591
+ $this->blklvl = 0;
14592
  for ($b=0; $b<=$save_blklvl;$b++) {
14593
  $tc = $t;
14594
  $ac = $a;
14595
  $t = $this->blk[$b+1]['tag'];
14596
  $a = $this->blk[$b+1]['attr'];
14597
  unset($this->blk[$b+1]);
14598
+ $this->OpenTag($tc,$ac);
14599
  }
14600
  $this->spanlvl = $save_spanlvl;
14601
  $this->InlineProperties = $save_ilp;
14607
 
14608
  // *********** LISTS ********************
14609
 
14610
+ if($tag=='LI') {
14611
+ $this->lastoptionaltag = '';
14612
  unset($this->listcascadeCSS[$this->listCSSlvl]);
14613
  $this->listCSSlvl--;
14614
+ if (isset($this->listoccur[$this->listlvl]) && isset($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]])) { $this->restoreInlineProperties($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]]); }
14615
  }
14616
 
14617
 
14633
 
14634
  if ($this->listlvl > 1) { // returning one level
14635
  $this->listjustfinished=true;
14636
+ if (!empty($this->textbuffer)) {
14637
  $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
14638
  }
14639
+ else {
14640
  $this->listnum--;
14641
  }
14642
 
14654
  if (!empty($this->textbuffer)) {
14655
  $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
14656
  }
14657
+ else {
14658
  $this->listnum--;
14659
  }
14660
 
14661
+ $occur = $this->listoccur[$this->listlvl];
14662
  $this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum;
14663
  $this->textbuffer = array();
14664
  $this->listlvl--;
14671
  $this->DivLn($this->list_margin_bottom,$this->blklvl,true,1); // collapsible
14672
  }
14673
  if (isset($this->blk[$this->blklvl]['InlineProperties'])) { $this->restoreInlineProperties($this->blk[$this->blklvl]['InlineProperties']);}
14674
+ $this->listjustfinished = true;
14675
  $this->listCSSlvl = 0;
14676
  $this->listcascadeCSS = array();
14677
  $this->blockjustfinished=true;
14710
  $currIndentLvl = -1;
14711
  $lastIndent = array();
14712
  $bak_page = $this->page;
14713
+ $indent = 0;
14714
  foreach($this->listitem as $item)
14715
  {
14716
  // COLS
14730
  $clh = $this->FontSize;
14731
 
14732
  $this->SetLineHeight($this->FontSizePt,$this->list_lineheight[$lvl][$occur]);
14733
+ $this->listOcc = $occur;
14734
+ $this->listnum = $num;
14735
 
14736
  if (isset($this->list_align[$this->listlvl][$occur])) { $this->divalign = $this->list_align[$this->listlvl][$occur]; }
14737
+ else {
14738
  if (isset($this->blk[$this->blklvl]['direction']) && $this->blk[$this->blklvl]['direction']=='rtl') { $this->divalign = 'R'; }
14739
  else { $this->divalign = 'L'; }
14740
  }
14754
  $blt_width = $this->GetStringWidth($list_item_marker);
14755
  $typefont = '';
14756
  if (preg_match('/rgb\(.*?\)/',$type,$m)) {
14757
+ $list_item_color = $this->ConvertColor($m[0]);
14758
  }
14759
  }
14760
  else {
14761
+ $list_item_color = false;
14762
 
14763
  switch($type) //Format type
14764
  {
14828
  break;
14829
  case 'disc':
14830
  if ($this->PDFA || $this->PDFX) {
14831
+ if ($this->_charDefined($this->CurrentFont['cw'],8226)) { $list_item_marker = "\xe2\x80\xa2"; } // &#8226;
14832
  else { $list_item_marker = '-'; }
14833
  $blt_width = $this->GetCharWidth($list_item_marker);
14834
  break;
14835
  }
14836
  $list_item_marker = chr(108); // bullet disc in Zapfdingbats 'l'
14837
  $typefont = 'czapfdingbats';
14838
+ $blt_width = (0.791 * $this->FontSize/2.5);
14839
  break;
14840
  case 'circle':
14841
  if ($this->PDFA || $this->PDFX) {
14842
+ if ($this->_charDefined($this->CurrentFont['cw'],9900)) { $list_item_marker = "\xe2\x9a\xac"; } // &#9900;
14843
  else { $list_item_marker = '-'; }
14844
  $blt_width = $this->GetCharWidth($list_item_marker);
14845
  break;
14846
  }
14847
  $list_item_marker = chr(109); // circle in Zapfdingbats 'm'
14848
  $typefont = 'czapfdingbats';
14849
+ $blt_width = (0.873 * $this->FontSize/2.5);
14850
  break;
14851
  case 'square':
14852
  if ($this->PDFA || $this->PDFX) {
14853
+ if ($this->_charDefined($this->CurrentFont['cw'],9642)) { $list_item_marker = "\xe2\x96\xaa"; } // &#9642;
14854
  else { $list_item_marker = '-'; }
14855
  $blt_width = $this->GetCharWidth($list_item_marker);
14856
  break;
14857
  }
14858
  $list_item_marker = chr(110); //black square in Zapfdingbats font 'n'
14859
  $typefont = 'czapfdingbats';
14860
+ $blt_width = (0.761 * $this->FontSize/2.5);
14861
  break;
14862
 
14863
  /* CSS3 list-styles numeric + I added tamil
14864
+ arabic-indic | bengali | cambodian | devanagari | gujarati | gurmukhi | kannada | khmer | lao | malayalam | mongolian | myanmar | oriya | persian | telugu | tibetan | thai | urdu
14865
  */
14866
  case 'arabic-indic':
14867
  $cp = 0x0660;
14879
  case 'bengali':
14880
  $cp = 0x09E6;
14881
  $rnum = $this->dec2other($num, $cp);
14882
+ $list_item_marker = $rnum . $this->list_number_suffix;
14883
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14884
  break;
14885
  case 'devanagari':
14886
  $cp = 0x0966;
14887
  $rnum = $this->dec2other($num, $cp);
14888
+ $list_item_marker = $rnum . $this->list_number_suffix;
14889
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14890
  break;
14891
  case 'gujarati':
14892
  $cp = 0x0AE6;
14893
  $rnum = $this->dec2other($num, $cp);
14894
+ $list_item_marker = $rnum . $this->list_number_suffix;
14895
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14896
  break;
14897
  case 'gurmukhi':
14898
  $cp = 0x0A66;
14899
  $rnum = $this->dec2other($num, $cp);
14900
+ $list_item_marker = $rnum . $this->list_number_suffix;
14901
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14902
  break;
14903
  case 'kannada':
14904
  $cp = 0x0CE6;
14905
  $rnum = $this->dec2other($num, $cp);
14906
+ $list_item_marker = $rnum . $this->list_number_suffix;
14907
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14908
  break;
14909
  case 'malayalam':
14910
  $cp = 0x0D66;
14911
  $rnum = $this->dec2other($num, $cp);
14912
+ $list_item_marker = $rnum . $this->list_number_suffix;
14913
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(6, $cp),strlen($maxnum)).$this->list_number_suffix);
14914
  break;
14915
  case 'oriya':
14916
  $cp = 0x0B66;
14917
  $rnum = $this->dec2other($num, $cp);
14918
+ $list_item_marker = $rnum . $this->list_number_suffix;
14919
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14920
  break;
14921
  case 'telugu':
14922
  $cp = 0x0C66;
14923
  $rnum = $this->dec2other($num, $cp);
14924
+ $list_item_marker = $rnum . $this->list_number_suffix;
14925
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(3, $cp),strlen($maxnum)).$this->list_number_suffix);
14926
  break;
14927
  case 'tamil':
14928
  $cp = 0x0BE6;
14929
  $rnum = $this->dec2other($num, $cp);
14930
+ $list_item_marker = $rnum . $this->list_number_suffix;
14931
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(9, $cp),strlen($maxnum)).$this->list_number_suffix);
14932
  break;
14933
  case 'thai':
14934
  $cp = 0x0E50;
14935
  $rnum = $this->dec2other($num, $cp);
14936
+ $list_item_marker = $rnum . $this->list_number_suffix;
14937
  $blt_width = $this->GetStringWidth(str_repeat($this->dec2other(5, $cp),strlen($maxnum)).$this->list_number_suffix);
14938
  break;
14939
  default:
14947
  if (isset($item[5]) && $item[5]) { $list_item_marker = ''; }
14948
 
14949
  if ($currIndentLvl < $lvl) {
14950
+ if ($lvl > 1 || $this->list_indent_first_level) {
14951
+ $indent += $this->list_indent[$lvl][$occur];
14952
  $lastIndent[$lvl] = $this->list_indent[$lvl][$occur];
14953
  }
14954
  }
14965
  if ($this->list_align_style == 'L') { $lalign = 'L'; }
14966
  else { $lalign = 'R'; }
14967
  $this->divwidth = $this->blk[$this->blklvl]['width'] - ($indent + $blt_width + $space_width) ;
14968
+ $xb = $this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] - $blt_width - $space_width;
14969
  //Output bullet
14970
  $this->bulletarray = array('w'=>$blt_width,'h'=>$clh,'txt'=>$list_item_marker,'x'=>$xb,'align'=>$lalign,'font'=>$typefont,'level'=>$lvl, 'occur'=>$occur, 'num'=>$num, 'fontsize'=>$bullfs, 'col'=>$list_item_color );
14971
  $this->x = $x + $indent + $blt_width + $space_width;
14998
  }
14999
 
15000
  function _saveTextBuffer($t, $link = '', $intlink = '') {
15001
+ $this->textbuffer[] = array($t,$link,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,$intlink,$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle,$this->kerning,$this->lSpacingCSS,$this->wSpacingCSS,$this->spanborddet, $this->textshadow);
15002
  }
15003
 
15004
  function _saveCellTextBuffer($t, $link = '', $intlink = '') {
15037
  $oldpage = $this->page;
15038
 
15039
  // ADDED for Out of Block now done as Flowing Block
15040
+ if ($this->divwidth == 0) {
15041
+ $this->divwidth = $this->pgwidth;
15042
  }
15043
 
15044
  if (!$is_table && !$is_list) { $this->SetLineHeight($this->FontSizePt,$this->blk[$this->blklvl]['line_height']); }
15064
  $vetor[0] = ltrim($vetor[0]);
15065
  }
15066
 
15067
+ // FIXED TO ALLOW IT TO SHOW '0'
15068
  if (empty($vetor[0]) && !($vetor[0]==='0') && empty($vetor[7])) { //Ignore empty text and not carrying an internal link
15069
  //Check if it is the last element. If so then finish printing the block
15070
  if ($i == ($array_size-1)) { $this->finishFlowingBlock(true); } // true = END of flowing block
15075
  //Activating buffer properties
15076
  if(isset($vetor[11]) and $vetor[11] != '') { // Font Size
15077
  if ($is_table && $this->shrin_k) {
15078
+ $this->SetFontSize($vetor[11]/$this->shrin_k,false);
15079
  }
15080
  else {
15081
+ $this->SetFontSize($vetor[11],false);
15082
  }
15083
  }
15084
 
15091
  }
15092
 
15093
  if(isset($vetor[15])) { // Word spacing
15094
+ $this->wSpacingCSS = $vetor[15];
15095
+ if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
15096
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
15097
  }
15098
  }
15099
  if(isset($vetor[14])) { // Letter spacing
15100
+ $this->lSpacingCSS = $vetor[14];
15101
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
15102
+ $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
15103
  }
15104
  }
15105
  if(isset($vetor[13])) { // Font Kerning
15106
+ $this->kerning = $vetor[13];
15107
  }
15108
 
15109
 
15125
  }
15126
  if(isset($vetor[7]) and $vetor[7] != '') // internal link: <a name="anyvalue">
15127
  {
15128
+ $ily = $this->y;
15129
  if ($this->keep_block_together) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "kt"=>true ); }
15130
  else if ($this->table_rotate) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "tbrot"=>true ); }
15131
  else if ($this->kwt) { $this->internallink[$vetor[7]] = array("Y"=>$ily,"PAGE"=>$this->page, "kwt"=>true ); }
15138
  continue;
15139
  }
15140
  }
15141
+ if(isset($vetor[6]) and $vetor[6] === true) // Subscript
15142
  {
15143
  $this->SUB = true;
15144
  }
15147
  $this->SUP = true;
15148
  }
15149
  if(isset($vetor[4]) and $vetor[4] != '') { // Font Family
15150
+ $font = $this->SetFont($vetor[4],$this->FontStyle,0,false);
15151
  }
15152
  if (!empty($vetor[3])) //Font Color
15153
  {
15154
  $cor = $vetor[3];
15155
+ $this->SetTColor($cor);
15156
  }
15157
  if(isset($vetor[2]) and $vetor[2] != '') //Bold,Italic,Underline styles
15158
  {
15165
  if(isset($vetor[1]) and $vetor[1] != '') //LINK
15166
  {
15167
 
15168
+ if (strpos($vetor[1],".") === false && strpos($vetor[1],"@") !== 0) //assuming every external link has a dot indicating extension (e.g: .html .txt .zip www.somewhere.com etc.)
15169
  {
15170
  //Repeated reference to same anchor?
15171
  while(array_key_exists($vetor[1],$this->internallink)) $vetor[1]="#".$vetor[1];
15186
  if ($objattr['nestedcontent']) {
15187
  $level = $objattr['level'];
15188
  $table = &$this->table[$level][$objattr['table']];
15189
+ if ($this->cacheTables) {
15190
  $fh = fopen($table['cache'], "r+b");
15191
  $cell = $this->_uncacheCell($table['cells'][$objattr['row']][$objattr['col']], '', $fh);
15192
  }
15205
  if ($this->packTableData) {
15206
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($cell['borderbin']);
15207
  }
15208
+ else {
15209
  $br = $cell['border_details']['R']['w'];
15210
  $bl = $cell['border_details']['L']['w'];
15211
  }
15212
+ if ($table['borders_separate']) {
15213
  $innerw = $w - $bl - $br - $cell['padding']['L'] - $cell['padding']['R'] - $table['border_spacing_H'];
15214
  }
15215
  else {
15217
  }
15218
  }
15219
  else if ($this->simpleTables){
15220
+ if ($table['borders_separate']) {
15221
  $innerw = $w - $table['simple']['border_details']['L']['w'] - $table['simple']['border_details']['R']['w'] - $cell['padding']['L'] - $cell['padding']['R'] - $table['border_spacing_H'];
15222
  }
15223
  else {
15224
  $innerw = $w - $table['simple']['border_details']['L']['w']/2 - $table['simple']['border_details']['R']['w']/2 - $cell['padding']['L'] - $cell['padding']['R'];
15225
  }
15226
  }
15227
+ if ($cell['a']=='C' || $this->table[($level+1)][$objattr['nestedcontent']]['a']=='C') {
15228
+ $ncx += ($innerw-$ntw)/2;
15229
  }
15230
  elseif ($cell['a']=='R' || $this->table[($level+1)][$objattr['nestedcontent']]['a']=='R') {
15231
+ $ncx += $innerw- $ntw;
15232
+ }
15233
  $this->x = $ncx ;
15234
  if ($this->cacheTables) { fclose($fh); }
15235
 
15245
  $maxWidth = $this->divwidth; // *TABLES*
15246
  } // *TABLES*
15247
  else { // *TABLES*
15248
+ $maxWidth = $this->divwidth - ($this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_right'] + $this->blk[$this->blklvl]['border_right']['w']);
15249
  } // *TABLES*
15250
 
15251
 
15261
  $this->newFlowingBlock( $this->divwidth,$this->divheight,$align,$is_table,$is_list,$blockstate,false,$blockdir);
15262
  }
15263
  $thispage = $this->page;
15264
+ if ($this->CurrCol!=$oldcol) { $changedcol = true; }
15265
  else { $changedcol=false; }
15266
 
15267
  // the previous lines can already have triggered page break or column change
15268
  if (!$changedcol && $skipln <0 && $this->AcceptPageBreak() && $thispage==$oldpage) {
15269
 
15270
+ $this->AddPage($this->CurOrientation);
15271
 
15272
  // Added to correct Images already set on line before page advanced
15273
  // i.e. if second inline image on line is higher than first and forces new page
15283
 
15284
  // Added to correct for OddEven Margins
15285
  if ($this->page != $oldpage) {
15286
+ if (($this->page-$oldpage) % 2 == 1) {
15287
  $bak_x += $this->MarginCorrection;
15288
  }
15289
  $oldpage = $this->page;
15293
  }
15294
  $this->x = $bak_x;
15295
 
15296
+ $this->WriteFlowingBlock($vetor[0]);
15297
  } // *TABLES*
15298
 
15299
  } // END If special content
15309
  $this->y+= $this->_computeLineheight($this->table_lineheight);
15310
  }
15311
  else if (!$is_table) {
15312
+ $this->DivLn($this->lineheight);
15313
  }
15314
  // Added to correct for OddEven Margins
15315
  if ($this->page != $oldpage) {
15365
  $this->SetTColor($this->ConvertColor(0));
15366
  $this->SetDColor($this->ConvertColor(0));
15367
  $this->SetFColor($this->ConvertColor(255));
15368
+ $this->colorarray = '';
15369
  $this->spanbgcolorarray = '';
15370
  $this->spanbgcolor = false;
15371
  $this->spanborder = false;
15380
  $this->strike = false;
15381
  $this->textshadow = '';
15382
 
15383
+ $this->currentfontfamily = '';
15384
+ $this->currentfontsize = '';
15385
+ $this->currentfontstyle = '';
15386
  if ($this->tableLevel) {
15387
  $this->SetLineHeight('',$this->table_lineheight); // *TABLES*
15388
  }
15398
  $this->toupper = false;
15399
  $this->tolower = false;
15400
  $this->capitalize = false;
15401
+ $this->kerning = false;
15402
  $this->lSpacingCSS = '';
15403
  $this->wSpacingCSS = '';
15404
  $this->fixedlSpacing = false;
15405
  $this->minwSpacing = 0;
15406
+ $this->SetDash();
15407
  $this->dash_on = false;
15408
  $this->dotted_on = false;
15409
 
15420
  else if ($blockstate != 1) {
15421
  $this->PaintDivBB('',$blockstate);
15422
  }
15423
+ $this->y = $bottom_y;
15424
  $this->x = $bak_x;
15425
  }
15426
 
15427
  // Reset Font
15428
+ $this->SetFontSize($this->default_font_size,false);
15429
 
15430
 
15431
  }
15459
  // Borders & backgrounds are done elsewhere for columns - messes up the repositioning in printcolumnbuffer
15460
  $save_y = $this->y;
15461
  if (!$blvl) { $blvl = $this->blklvl; }
15462
+ $x0 = $x1 = $y0 = $y1 = 0;
15463
 
15464
  // Added mPDF 3.0 Float DIV
15465
 
15467
  if (isset($this->blk[$blvl]['y1'])) { $y1 = $this->blk[$blvl]['y1']; } // bottom
15468
 
15469
  // Added mPDF 3.0 Float DIV - ensures backgrounds/borders are drawn to bottom of page
15470
+ if ($y1==0) {
15471
  if ($divider=='pagebottom') { $y1 = $this->h-$this->bMargin; }
15472
  else { $y1 = $this->y; }
15473
  }
15474
 
15475
+ if (isset($this->blk[$blvl]['startpage']) && $this->blk[$blvl]['startpage'] != $this->page) { $continuingpage = true; } else { $continuingpage = false; }
15476
 
15477
  if (isset($this->blk[$blvl]['y0'])) { $y0 = $this->blk[$blvl]['y0']; }
15478
  $h = $y1 - $y0;
15487
  if (!$this->blk[$blvl]['border_top'] || $divider == 'pagetop' || $continuingpage) {
15488
  $border_top = 0;
15489
  }
15490
+ if (!$this->blk[$blvl]['border_bottom'] || $blockstate == 1 || $divider == 'pagebottom') {
15491
  $border_bottom = 0;
15492
  }
15493
 
15500
  $brBR_H = 0;
15501
  $brBR_V = 0;
15502
 
15503
+ $brset = false;
15504
 
15505
  // BORDERS
15506
  if (isset($this->blk[$blvl]['y0']) && $this->blk[$blvl]['y0']) { $y0 = $this->blk[$blvl]['y0']; }
15514
 
15515
  // mPDF 5.4.18
15516
  $legend = '';
15517
+ if (isset($this->blk[$blvl]['border_legend']) && $this->blk[$blvl]['border_legend']) {
15518
  $legend = $this->blk[$blvl]['border_legend']; // Same structure array as textbuffer
15519
  $txt = ltrim($legend[0]);
15520
 
15521
  //Set font, size, style, color
15522
  $this->SetFont($legend[4],$legend[2],$legend[11]);
15523
+ if ($legend[3]) {
15524
  $cor = $legend[3];
15525
  $this->SetTColor($cor);
15526
  }
15540
  $legbreakR = $this->x + $stringWidth + $gap;
15541
 
15542
  $this->Cell( $stringWidth, $this->FontSize, $txt , '', 0, 'C', $fill, '', 0, 0,0,'M', $fill);
15543
+ // Reset
15544
  $this->x = $save_x;
15545
  $this->y = $save_y;
15546
  $this->SetFont($save_currentfontfamily,$save_currentfontstyle,$save_currentfontsize);
15574
  // Reset Corners and Dash off
15575
  $this->SetLineJoin(2);
15576
  $this->SetLineCap(2);
15577
+ $this->SetDash();
15578
  }
15579
  }
15580
+ //if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1) {
15581
  // Reinstate line above for dotted line divider when block border crosses a page
15582
+ if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1 && $divider != 'pagebottom') {
15583
  $tbd = $this->blk[$blvl]['border_bottom'];
15584
  if (isset($tbd['s']) && $tbd['s']) {
15585
  $this->_setBorderLine($tbd);
15591
  // Reset Corners and Dash off
15592
  $this->SetLineJoin(2);
15593
  $this->SetLineCap(2);
15594
+ $this->SetDash();
15595
  }
15596
  }
15597
+ if ($this->blk[$blvl]['border_left']) {
15598
  $tbd = $this->blk[$blvl]['border_left'];
15599
  if (isset($tbd['s']) && $tbd['s']) {
15600
  $this->_setBorderLine($tbd);
15606
  // Reset Corners and Dash off
15607
  $this->SetLineJoin(2);
15608
  $this->SetLineCap(2);
15609
+ $this->SetDash();
15610
  }
15611
  }
15612
+ if ($this->blk[$blvl]['border_right']) {
15613
  $tbd = $this->blk[$blvl]['border_right'];
15614
  if (isset($tbd['s']) && $tbd['s']) {
15615
  $this->_setBorderLine($tbd);
15621
  // Reset Corners and Dash off
15622
  $this->SetLineJoin(2);
15623
  $this->SetLineCap(2);
15624
+ $this->SetDash();
15625
  }
15626
  }
15627
 
15643
  }
15644
  }
15645
  }
15646
+ if ($this->blk[$blvl]['border_bottom'] && $blockstate != 1 && $divider != 'pagebottom') {
15647
  $tbd = $this->blk[$blvl]['border_bottom'];
15648
  if (isset($tbd['s']) && $tbd['s']) {
15649
  if (!$brset && $tbd['style']=='double') {
15653
  }
15654
  }
15655
  }
15656
+ if ($this->blk[$blvl]['border_left']) {
15657
  $tbd = $this->blk[$blvl]['border_left'];
15658
  if (isset($tbd['s']) && $tbd['s']) {
15659
  if (!$brset && $tbd['style']=='double') {
15663
  }
15664
  }
15665
  }
15666
+ if ($this->blk[$blvl]['border_right']) {
15667
  $tbd = $this->blk[$blvl]['border_right'];
15668
  if (isset($tbd['s']) && $tbd['s']) {
15669
  if (!$brset && $tbd['style']=='double') {
15674
  }
15675
  }
15676
 
15677
+ $this->SetDash();
15678
+ $this->y = $save_y;
15679
 
15680
 
15681
  // BACKGROUNDS are disabled in columns/kbt/headers - messes up the repositioning in printcolumnbuffer
15741
  $shadow .= $s; // Use the clipping path with W*
15742
  $shadow .= sprintf('0 %.3F m %.3F %.3F l ', $this->h*_MPDFK, $this->w*_MPDFK, $this->h*_MPDFK);
15743
  $shadow .= sprintf('%.3F 0 l 0 0 l 0 %.3F l ', $this->w*_MPDFK, $this->h*_MPDFK);
15744
+ $shadow .= 'W n'."\n";
15745
 
15746
  $sh['blur'] = abs($sh['blur']); // cannot have negative blur value
15747
  // Ensure spread/blur do not make effective shadow width/height < 0
15748
  // Could do more complex things but this just adjusts spread value
15749
+ if (-$sh['spread'] + $sh['blur']/2 > min($w/2, $h/2)) {
15750
  $sh['spread'] = $sh['blur']/2 - min($w/2, $h/2) + 0.01;
15751
  }
15752
  // Shadow Offset
15756
  $shadow .= ' q 0 w ';
15757
  $shadow .= $this->SetFColor($col1, true)."\n";
15758
  if ($col1{0}==5 && ord($col1{4})<100) { // RGBa
15759
+ $shadow .= $this->SetAlpha(ord($col1{4})/100, 'Normal', true, 'F')."\n";
15760
  }
15761
  else if ($col1{0}==6 && ord($col1{5})<100) { // CMYKa
15762
+ $shadow .= $this->SetAlpha(ord($col1{5})/100, 'Normal', true, 'F')."\n";
15763
  }
15764
  else if ($col1{0}==1 && $col1{2}==1 && ord($col1{3})<100) { // Gray
15765
+ $shadow .= $this->SetAlpha(ord($col1{3})/100, 'Normal', true, 'F')."\n";
15766
  }
15767
 
15768
  // Blur edges
15829
 
15830
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15831
  $patch_array[1]['f']=2;
15832
+ $patch_array[1]['points']=array($p2x,$p2y,
15833
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15834
  $p4c1x,$p4y, $p4x,$p4y, $p4x,$p4y,
15835
  $p1x,$p1y);
15844
  $p3x = $x00+$w00-$d1-$brbgBR_H; $p3c1x = $p3x + ($d1+$brbgBR_H)*$mag;
15845
  $p3y = $y00+$h00; $p3c2y = $p3y - $bl/2;
15846
  $p4x = $x00+$w00-$d1-$brbgBR_H; $p4c2x = $p4x + ($d2+$brbgBR_H)*$mag;
15847
+ $p4y = $y00+$h00-$bl;
15848
 
15849
  if (-$d2 > min($brbgBR_H, $brbgBR_V) || $flatten) {
15850
  $p1y = $y00+$h00-$bl; $p1c2y = $p1y;
15869
  $p2x = $x00+$w00-$d1-$brbgBR_H; // control point only matches p4 preceding
15870
  $p2y = $y00+$h00-$bl;
15871
  $p3x = $x00+$d1+$brbgBL_H;
15872
+ $p3y = $y00+$h00-$bl;
15873
  $p4x = $x00+$d1+$brbgBL_H;
15874
  $p4y = $y00+$h00; $p4c1y = $p4y - $bl/2;
15875
 
15884
 
15885
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15886
  $patch_array[3]['f']=2;
15887
+ $patch_array[3]['points']=array($p2x,$p2y,
15888
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15889
  $p4x,$p4c1y, $p4x,$p4y, $p4x,$p4y,
15890
  $p1x,$p1y);
15921
  $p2x = $x00+$bl; // control point only matches p4 preceding
15922
  $p2y = $y00+$h00-$d1-$brbgBL_V;
15923
  $p3x = $x00+$bl;
15924
+ $p3y = $y00+$d1+$brbgTL_V;
15925
  $p4x = $x00; $p4c1x = $p4x + $bl/2;
15926
+ $p4y = $y00+$d1+$brbgTL_V;
15927
  if (-$d2 > min($brbgBL_H, $brbgBL_V) || $flatten) {
15928
  $p1y = $y00+$h00-$bl;
15929
  $p2y = $y00+$h00-$bl;
15930
  }
15931
  if (-$d2 > min($brbgTL_H, $brbgTL_V) || $flatten) {
15932
+ $p3y = $y00+$bl;
15933
+ $p4y = $y00+$bl;
15934
  }
15935
 
15936
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15937
  $patch_array[5]['f']=2;
15938
+ $patch_array[5]['points']=array($p2x,$p2y,
15939
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15940
  $p4c1x,$p4y, $p4x,$p4y, $p4x,$p4y,
15941
  $p1x,$p1y);
15973
  $p2x = $x00+$d1+$brbgTL_H; // control point only matches p4 preceding
15974
  $p2y = $y00+$bl;
15975
  $p3x = $x00+$w00-$d1-$brbgTR_H;
15976
+ $p3y = $y00+$bl;
15977
  $p4x = $x00+$w00-$d1-$brbgTR_H;
15978
  $p4y = $y00; $p4c1y = $p4y + $bl/2;
15979
  if (-$d2 > min($brbgTL_H, $brbgTL_V) || $flatten) {
15987
 
15988
  $shadow .= sprintf('%.3F %.3F l ', ($p3x )*_MPDFK, ($this->h-($p3y ))*_MPDFK);
15989
  $patch_array[7]['f']=2;
15990
+ $patch_array[7]['points']=array($p2x,$p2y,
15991
  $p3x,$p3y, $p3x,$p3y, $p3x,$p3y,
15992
  $p4x,$p4c1y, $p4x,$p4y, $p4x,$p4y,
15993
  $p1x,$p1y);
16024
  function PaintDivLnBorder($state=0,$blvl=0,$h) {
16025
  // $state = 0 normal; 1 top; 2 bottom; 3 top and bottom
16026
 
16027
+ $this->ColDetails[$this->CurrCol]['bottom_margin'] = $this->y + $h;
16028
 
16029
  $save_y = $this->y;
16030
 
16045
  // Reset Corners and Dash off
16046
  $this->SetLineJoin(2);
16047
  $this->SetLineCap(2);
16048
+ $this->SetDash();
16049
  }
16050
  }
16051
+ if ($this->blk[$blvl]['border_left']) {
16052
  $tbd = $this->blk[$blvl]['border_left'];
16053
  if (isset($tbd['s']) && $tbd['s']) {
16054
  $this->_setBorderLine($tbd);
16059
  // Reset Corners and Dash off
16060
  $this->SetLineJoin(2);
16061
  $this->SetLineCap(2);
16062
+ $this->SetDash();
16063
  }
16064
  }
16065
+ if ($this->blk[$blvl]['border_right']) {
16066
  $tbd = $this->blk[$blvl]['border_right'];
16067
  if (isset($tbd['s']) && $tbd['s']) {
16068
  $this->_setBorderLine($tbd);
16073
  // Reset Corners and Dash off
16074
  $this->SetLineJoin(2);
16075
  $this->SetLineCap(2);
16076
+ $this->SetDash();
16077
  }
16078
  }
16079
+ if ($this->blk[$blvl]['border_bottom'] && $state > 1) {
16080
  $tbd = $this->blk[$blvl]['border_bottom'];
16081
  if (isset($tbd['s']) && $tbd['s']) {
16082
  $this->_setBorderLine($tbd);
16087
  // Reset Corners and Dash off
16088
  $this->SetLineJoin(2);
16089
  $this->SetLineCap(2);
16090
+ $this->SetDash();
16091
  }
16092
  }
16093
+ $this->SetDash();
16094
+ $this->y = $save_y;
16095
  }
16096
 
16097
 
16104
  $y0 = (isset($objattr['BORDER-Y']) ? $objattr['BORDER-Y'] : 0);
16105
 
16106
  // BORDERS
16107
+ if ($objattr['border_top']) {
16108
  $tbd = $objattr['border_top'];
16109
  if (!empty($tbd['s'])) {
16110
  $this->_setBorderLine($tbd,$k);
16113
  // Reset Corners and Dash off
16114
  $this->SetLineJoin(2);
16115
  $this->SetLineCap(2);
16116
+ $this->SetDash();
16117
  }
16118
  }
16119
+ if ($objattr['border_left']) {
16120
  $tbd = $objattr['border_left'];
16121
  if (!empty($tbd['s'])) {
16122
  $this->_setBorderLine($tbd,$k);
16125
  // Reset Corners and Dash off
16126
  $this->SetLineJoin(2);
16127
  $this->SetLineCap(2);
16128
+ $this->SetDash();
16129
  }
16130
  }
16131
+ if ($objattr['border_right']) {
16132
  $tbd = $objattr['border_right'];
16133
  if (!empty($tbd['s'])) {
16134
  $this->_setBorderLine($tbd,$k);
16137
  // Reset Corners and Dash off
16138
  $this->SetLineJoin(2);
16139
  $this->SetLineCap(2);
16140
+ $this->SetDash();
16141
  }
16142
  }
16143
+ if ($objattr['border_bottom']) {
16144
  $tbd = $objattr['border_bottom'];
16145
  if (!empty($tbd['s'])) {
16146
  $this->_setBorderLine($tbd,$k);
16149
  // Reset Corners and Dash off
16150
  $this->SetLineJoin(2);
16151
  $this->SetLineCap(2);
16152
+ $this->SetDash();
16153
  }
16154
  }
16155
+ $this->SetDash();
16156
  $this->SetAlpha(1);
16157
  }
16158
 
16165
  $this->SetDColor($this->ConvertColor(0));
16166
  $this->SetFColor($this->ConvertColor(255));
16167
  $this->SetAlpha(1);
16168
+ $this->colorarray = '';
16169
 
16170
  $this->spanbgcolorarray = '';
16171
  $this->spanbgcolor = false;
16187
  $this->SetFont($this->default_font,'',0,false);
16188
  $this->SetFontSize($this->default_font_size,false);
16189
 
16190
+ $this->currentfontfamily = '';
16191
+ $this->currentfontsize = '';
16192
 
16193
  if ($this->tableLevel) {
16194
  $this->SetLineHeight('',$this->table_lineheight); // *TABLES*
16205
 
16206
  $this->toupper = false;
16207
  $this->tolower = false;
16208
+ $this->kerning = false;
16209
  $this->lSpacingCSS = '';
16210
  $this->wSpacingCSS = '';
16211
+ $this->fixedlSpacing = false;
16212
  $this->minwSpacing = 0;
16213
  $this->capitalize = false;
16214
  $this->SetDash(); //restore to no dash
16230
 
16231
  function ReadMetaTags($html) {
16232
  // changes anykey=anyvalue to anykey="anyvalue" (only do this when this happens inside tags)
16233
+ $regexp = '/ (\\w+?)=([^\\s>"]+)/si';
16234
  $html = preg_replace($regexp," \$1=\"\$2\"",$html);
16235
  if (preg_match('/<title>(.*?)<\/title>/si',$html,$m)) {
16236
+ $this->SetTitle($m[1]);
16237
  }
16238
  preg_match_all('/<meta [^>]*?(name|content)="([^>]*?)" [^>]*?(name|content)="([^>]*?)".*?>/si',$html,$aux);
16239
  $firstattr = $aux[1];
16256
  if ($this->allow_charset_conversion) {
16257
  if (preg_match('/<head.*charset=([^\'\"\s]*).*<\/head>/si',$html,$m)) {
16258
  if (strtoupper($m[1]) != 'UTF-8') {
16259
+ $this->charset_in = strtoupper($m[1]);
16260
  }
16261
  }
16262
  }
16325
  function ReadCSS($html) {
16326
  preg_match_all('/<style[^>]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m);
16327
  for($i=0; $i<count($m[0]); $i++) {
16328
+ if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16329
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
16330
  }
16331
  }
16332
  preg_match_all('/<link[^>]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m);
16333
  for($i=0; $i<count($m[0]); $i++) {
16334
+ if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16335
  $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html);
16336
  }
16337
  }
16343
  // case so we can use str_replace later.
16344
  preg_replace('/<\/style>/i', '</style>', $html);
16345
  preg_match_all('/<style.*?>(.*?)<\/style>/si',$html,$m);
16346
+ if (count($m[1])) {
16347
  for($i=0;$i<count($m[1]);$i++) {
16348
+ // Remove comment tags
16349
  $sub = preg_replace('/(<\!\-\-|\-\->)/s',' ',$m[1][$i]);
16350
  $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).'</style>';
16351
  $html = str_replace('>'.$m[1][$i].'</style>', $sub, $html);
16359
 
16360
  $match = 0; // no match for instance
16361
  $regexp = ''; // This helps debugging: showing what is the REAL string being processed
16362
+ $CSSext = array();
16363
 
16364
  //CSS inside external files
16365
  $regexp = '/<link[^>]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si';
16366
  $x = preg_match_all($regexp,$html,$cxt);
16367
+ if ($x) {
16368
+ $match += $x;
16369
  $CSSext = $cxt[1];
16370
  }
16371
 
16372
  $regexp = '/<link[^>]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si';
16373
  $x = preg_match_all($regexp,$html,$cxt);
16374
+ if ($x) {
16375
+ $match += $x;
16376
  $CSSext = array_merge($CSSext,$cxt[1]);
16377
  }
16378
 
16380
  //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si';
16381
  $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
16382
  $x = preg_match_all($regexp,$html,$cxt);
16383
+ if ($x) {
16384
+ $match += $x;
16385
  $CSSext = array_merge($CSSext,$cxt[1]);
16386
  }
16387
 
16389
  //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si';
16390
  $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si';
16391
  $x = preg_match_all($regexp,$html,$cxt);
16392
+ if ($x) {
16393
+ $match += $x;
16394
  $CSSext = array_merge($CSSext,$cxt[1]);
16395
  }
16396
 
16401
 
16402
  while($match){
16403
  $path = $CSSext[$ind];
16404
+ $this->GetFullPath($path);
16405
  $CSSextblock = $this->_get_file($path);
16406
  if ($CSSextblock) {
16407
  // look for embedded @import stylesheets in other stylesheets
16410
  $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si';
16411
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
16412
  $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/';
16413
+ if ($xem) {
16414
  foreach($cxtem[1] AS $cxtembedded) {
16415
  // path is relative to original stlyesheet!!
16416
  $this->GetFullPath($cxtembedded, $cssBasePath );
16417
+ $match++;
16418
  $CSSext[] = $cxtembedded;
16419
  }
16420
  }
16421
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
16422
  $xem = preg_match_all($regexpem,$CSSextblock,$cxtem);
16423
+ if ($xem) {
16424
  for ($i=0;$i<count($cxtem[0]);$i++) {
16425
  // path is relative to original stlyesheet!!
16426
  $embedded = $cxtem[2][$i];
16438
 
16439
  $match = 0; // reset value, if needed
16440
  // CSS as <style> in HTML document
16441
+ $regexp = '/<style.*?>(.*?)<\/style>/si';
16442
  $match = preg_match_all($regexp,$html,$CSSblock);
16443
  if ($match) {
16444
  $tmpCSSstr = implode(' ',$CSSblock[1]);
16445
  $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si';
16446
  $xem = preg_match_all($regexpem,$tmpCSSstr ,$cxtem);
16447
+ if ($xem) {
16448
  for ($i=0;$i<count($cxtem[0]);$i++) {
16449
  $embedded = $cxtem[2][$i];
16450
  if (!preg_match('/^data:image/i', $embedded)) { // mPDF 5.5.13
16459
  $CSSstr = preg_replace('|/\*.*?\*/|s',' ',$CSSstr);
16460
  $CSSstr = preg_replace('/[\s\n\r\t\f]/s',' ',$CSSstr);
16461
 
16462
+ if (preg_match('/@media/',$CSSstr)) {
16463
  preg_match_all('/@media(.*?)\{(([^\{\}]*\{[^\{\}]*\})+)\s*\}/is',$CSSstr,$m);
16464
  for($i=0; $i<count($m[0]); $i++) {
16465
+ if ($this->CSSselectMedia && !preg_match('/('.trim($this->CSSselectMedia).'|all)/i',$m[1][$i])) {
16466
  $CSSstr = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$CSSstr);
16467
  }
16468
  else {
16474
  // mPDF 5.5.13
16475
  // Replace any background: url(data:image... with temporary image file reference
16476
  preg_match_all("/(url\(data:image\/(jpeg|gif|png);base64,(.*)\))/si", $CSSstr, $idata);
16477
+ if (count($idata[0])) {
16478
  for($i=0;$i<count($idata[0]);$i++) {
16479
  $file = _MPDF_TEMP_PATH.'_tempCSSidata'.RAND(1,10000).'_'.$i.'.'.$idata[2][$i];
16480
  //Save to local file
16492
  $stylestr= trim($styles[2][$i]);
16493
  $stylearr = explode(';',$stylestr);
16494
  foreach($stylearr AS $sta) {
16495
+ if (trim($sta)) {
16496
  // Changed to allow style="background: url('http://www.bpm1.com/bg.jpg')"
16497
  list($property,$value) = explode(':',$sta,2);
16498
  $property = trim($property);
16500
  $value = trim($value);
16501
  if ($property && ($value || $value==='0')) {
16502
  // Ignores -webkit-gradient so doesn't override -moz-
16503
+ if ((strtoupper($property)=='BACKGROUND-IMAGE' || strtoupper($property)=='BACKGROUND') && preg_match('/-webkit-gradient/i',$value)) {
16504
+ continue;
16505
  }
16506
  $classproperties[strtoupper($property)] = $value;
16507
  }
16523
  if (isset($tags[2])) { $t3 = trim($tags[2]); }
16524
  $tag = '';
16525
  if ($level==1) { $tag = $t; }
16526
+ else if ($level==2 && preg_match('/^[:](.*)$/',$t2,$m)) {
16527
+ $tag = $t.'>>PSEUDO>>'.$m[1];
16528
+ if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mirrorMargins
16529
  }
16530
  else if ($level==2) { $tag = $t.'>>NAMED>>'.$t2; }
16531
+ else if ($level==3 && preg_match('/^[:](.*)$/',$t3,$m)) {
16532
+ $tag = $t.'>>NAMED>>'.$t2.'>>PSEUDO>>'.$m[1];
16533
  if ($m[1]=='LEFT' || $m[1]=='RIGHT') { $pageselectors = true; } // used to turn on $this->mirrorMargins
16534
  }
16535
  if (isset($this->CSS[$tag]) && $tag) { $this->CSS[$tag] = $this->array_merge_recursive_unique($this->CSS[$tag], $classproperties); }
16570
  }
16571
 
16572
  if ($tag) {
16573
+ $x = &$this->cascadeCSS;
16574
  foreach($tmp AS $tp) { $x = &$x[$tp]; }
16575
+ $x = $this->array_merge_recursive_unique($x, $classproperties);
16576
  $x['depth'] = $level;
16577
  }
16578
  }
16584
  }
16585
  } // end of if
16586
  //Remove CSS (tags and content), if any
16587
+ $regexp = '/<style.*?>(.*?)<\/style>/si'; // it can be <style> or <style type="txt/css">
16588
  $html = preg_replace($regexp,'',$html);
16589
  //print_r($this->CSS); exit;
16590
  //print_r($this->cascadeCSS); exit;
16604
  $classproperties = array();
16605
  for($i = 0; $i < count($properties) ; $i++) {
16606
  // Ignores -webkit-gradient so doesn't override -moz-
16607
+ if ((strtoupper($properties[$i])=='BACKGROUND-IMAGE' || strtoupper($properties[$i])=='BACKGROUND') && preg_match('/-webkit-gradient/i',$values[$i])) {
16608
+ continue;
16609
  }
16610
  $classproperties[strtoupper($properties[$i])] = trim($values[$i]);
16611
  }
16630
  }
16631
  else{
16632
  $v = strtoupper($v);
16633
+ if (isset($this->fontsizes[$v])) {
16634
  $this->SetFontSize( $this->fontsizes[$v]* $this->default_font_size,false);
16635
  }
16636
  }
16638
  }
16639
 
16640
 
16641
+ if ($this->useLang && !$this->usingCoreFont) {
16642
  if (isset($arrayaux['LANG']) && $arrayaux['LANG'] && $arrayaux['LANG'] != $this->default_lang && ((strlen($arrayaux['LANG']) == 5 && $arrayaux['LANG'] != 'UTF-8') || strlen($arrayaux['LANG']) == 2)) {
16643
  list ($coreSuitable,$mpdf_pdf_unifonts) = GetLangOpts($arrayaux['LANG'], $this->useAdobeCJK);
16644
  if ($mpdf_pdf_unifonts) { $this->RestrictUnicodeFonts($mpdf_pdf_unifonts); }
16649
  if ($mpdf_pdf_unifonts) { $this->default_available_fonts = $mpdf_pdf_unifonts; }
16650
  }
16651
  }
16652
+ else {
16653
+ $this->RestrictUnicodeFonts($this->default_available_fonts );
16654
  }
16655
  }
16656
 
16666
  $fonttype = preg_replace('/ /','',$fonttype);
16667
  $v = strtolower(trim($fonttype));
16668
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
16669
+ if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) ||
16670
  in_array($v,array('ccourier','ctimes','chelvetica')) ||
16671
+ ($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
16672
+ in_array($v, array('sjis','uhc','big5','gb'))) {
16673
+ $fonttype = $v;
16674
  $found = 1;
16675
  break;
16676
  }
16682
  $fonttype = preg_replace('/ /','',$fonttype);
16683
  $v = strtolower(trim($fonttype));
16684
  if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
16685
+ if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
16686
+ $fonttype = $v;
16687
  break;
16688
  }
16689
  }
16690
  }
16691
 
16692
+ if ($tag == 'BODY') {
16693
+ $this->SetDefaultFont($fonttype);
16694
  }
16695
  $this->SetFont($fonttype,$this->currentfontstyle,0,false);
16696
  }
16697
+ else {
16698
+ $this->SetFont($this->currentfontfamily,$this->currentfontstyle,0,false);
16699
  }
16700
 
16701
  foreach($arrayaux as $k => $v) {
16740
  if ($tmp > $this->blk[$this->blklvl]['lastbottommargin']) {
16741
  $tmp -= $this->blk[$this->blklvl]['lastbottommargin'];
16742
  }
16743
+ else {
16744
  $tmp = 0;
16745
  }
16746
  }
16772
  break;
16773
 
16774
  case 'WIDTH':
16775
+ if (strtoupper($v) != 'AUTO') {
16776
+ $this->blk[$this->blklvl]['css_set_width'] = $this->ConvertSize($v,$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
16777
  }
16778
  break;
16779
 
16800
 
16801
  case 'TEXT-ALIGN': //left right center justify
16802
  switch (strtoupper($v)) {
16803
+ case 'LEFT':
16804
  $this->blk[$this->blklvl]['align']="L";
16805
  break;
16806
+ case 'CENTER':
16807
  $this->blk[$this->blklvl]['align']="C";
16808
  break;
16809
+ case 'RIGHT':
16810
  $this->blk[$this->blklvl]['align']="R";
16811
  break;
16812
+ case 'JUSTIFY':
16813
  $this->blk[$this->blklvl]['align']="J";
16814
  break;
16815
  }
16816
  break;
16817
 
16818
 
16819
+ case 'DIRECTION':
16820
  if ($v) { $this->blk[$this->blklvl]['direction'] = strtolower($v); }
16821
  break;
16822
 
16829
  case 'DISPLAY': // Custom tag to collapse margins at top and bottom of page
16830
  if (strtoupper($v) == 'NONE') { $this->inlineDisplayOff = true; }
16831
  break;
16832
+ case 'DIRECTION':
16833
  break;
16834
  }//end of switch($k)
16835
  }
16865
  }
16866
  break;
16867
  // bgcolor only - to stay consistent with original html2fpdf
16868
+ case 'BACKGROUND':
16869
+ case 'BACKGROUND-COLOR':
16870
  $cor = $this->ConvertColor($v);
16871
+ if ($cor) {
16872
  if ($tag == 'BODY') {
16873
  $this->bodyBackgroundColor = $cor;
16874
  }
16882
  }
16883
  }
16884
  else if ($type != 'INLINE' && $type != 'LIST') {
16885
+ if ($this->ColActive || $this->keep_block_together) {
16886
  $this->blk[$this->blklvl]['bgcolorarray'] = $this->blk[$this->blklvl-1]['bgcolorarray'] ;
16887
  $this->blk[$this->blklvl]['bgcolor'] = $this->blk[$this->blklvl-1]['bgcolor'] ;
16888
  }
16890
  break;
16891
 
16892
  // auto | normal | none
16893
+ case 'FONT-KERNING':
16894
  if ((strtoupper($v) == 'NORMAL' || strtoupper($v) == 'AUTO') && $this->useKerning) { $this->kerning = true; }
16895
  else if (strtoupper($v) == 'NONE') { $this->kerning = false; }
16896
  break;
16897
 
16898
 
16899
  // normal | <length>
16900
+ case 'LETTER-SPACING':
16901
  $this->lSpacingCSS = $v;
16902
+ if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
16903
  $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
16904
  }
16905
  break;
16906
 
16907
  // normal | <length>
16908
+ case 'WORD-SPACING':
16909
  $this->wSpacingCSS = $v;
16910
  if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
16911
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
16914
 
16915
  case 'FONT-STYLE': // italic normal oblique
16916
  switch (strtoupper($v)) {
16917
+ case 'ITALIC':
16918
+ case 'OBLIQUE':
16919
  $this->SetStyle('I',true);
16920
  break;
16921
+ case 'NORMAL':
16922
  $this->SetStyle('I',false);
16923
  break;
16924
  }
16926
 
16927
  case 'FONT-WEIGHT': // normal bold //Does not support: bolder, lighter, 100..900(step value=100)
16928
  switch (strtoupper($v)) {
16929
+ case 'BOLD':
16930
  $this->SetStyle('B',true);
16931
  break;
16932
+ case 'NORMAL':
16933
  $this->SetStyle('B',false);
16934
  break;
16935
  }
16937
 
16938
  case 'VERTICAL-ALIGN': //super and sub only dealt with here e.g. <SUB> and <SUP>
16939
  switch (strtoupper($v)) {
16940
+ case 'SUPER':
16941
  $this->SUP=true;
16942
  break;
16943
+ case 'SUB':
16944
  $this->SUB=true;
16945
  break;
16946
  }
16955
  }
16956
  break;
16957
 
16958
+ case 'FONT-VARIANT':
16959
  switch (strtoupper($v)) {
16960
+ case 'SMALL-CAPS':
16961
  $this->SetStyle('S',true);
16962
  break;
16963
+ case 'NORMAL':
16964
  $this->SetStyle('S',false);
16965
  break;
16966
  }
16969
  case 'TEXT-TRANSFORM': // none uppercase lowercase //Does support: capitalize
16970
  switch (strtoupper($v)) { //Not working 100%
16971
  case 'CAPITALIZE':
16972
+ $this->capitalize=true;
16973
  break;
16974
  case 'UPPERCASE':
16975
  $this->toupper=true;
16986
  if ($ts) { $this->textshadow = $ts; }
16987
  break;
16988
 
16989
+ case 'OUTLINE-WIDTH':
16990
  switch(strtoupper($v)) {
16991
  case 'THIN': $v = '0.03em'; break;
16992
  case 'MEDIUM': $v = '0.05em'; break;
16995
  $this->outlineparam['WIDTH'] = $this->ConvertSize($v,$this->blk[$this->blklvl]['inner_width'],$this->FontSize);
16996
  break;
16997
 
16998
+ case 'OUTLINE-COLOR':
16999
  if (strtoupper($v) == 'INVERT') {
17000
  if ($this->colorarray) {
17001
  $cor = $this->colorarray;
17005
  $this->outlineparam['COLOR'] = $this->ConvertColor(255);
17006
  }
17007
  }
17008
+ else {
17009
  $cor = $this->ConvertColor($v);
17010
+ if ($cor) { $this->outlineparam['COLOR'] = $cor ; }
17011
  }
17012
  break;
17013
 
17014
  case 'COLOR': // font color
17015
  $cor = $this->ConvertColor($v);
17016
+ if ($cor) {
17017
  $this->colorarray = $cor;
17018
+ $this->SetTColor($cor);
17019
  }
17020
  break;
17021
 
17098
  function finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight) {
17099
  $af = 0; // Above font
17100
  $bf = 0; // Below font
17101
+ $mta = 0; // Maximum top-aligned
17102
+ $mba = 0; // Maximum bottom-aligned
17103
  if ($lhxt['BS']) {
17104
  $af = max($af, ($lhxt['BS'] - ($maxfontsize * (0.5 + $this->baselineC))));
17105
  }
17106
+ if ($lhxt['M']) {
17107
  $af = max($af, ($lhxt['M'] - $maxfontsize)/2);
17108
  $bf = max($bf, ($lhxt['M'] - $maxfontsize)/2);
17109
  }
17110
+ if ($lhxt['TT']) {
17111
  $bf = max($bf, ($lhxt['TT'] - $maxfontsize));
17112
  }
17113
+ if ($lhxt['TB']) {
17114
  $af = max($af, ($lhxt['TB'] - $maxfontsize));
17115
  }
17116
+ if ($lhxt['T']) {
17117
  $mta = max($mta, $lhxt['T']);
17118
  }
17119
+ if ($lhxt['B']) {
17120
  $mba = max($mba, $lhxt['B']);
17121
  }
17122
  if ((!$lhfixed || !$forceExactLineheight) && ($af > (($maxlineHeight - $maxfontsize)/2) || $bf > (($maxlineHeight - $maxfontsize)/2))) {
17123
  $maxlineHeight = $maxfontsize + $af + $bf;
17124
  }
17125
  else if (!$lhfixed) { $af = $bf = ($maxlineHeight - $maxfontsize)/2; }
17126
+ if ($mta > $maxlineHeight) {
17127
  $bf += ($mta - $maxlineHeight);
17128
  $maxlineHeight = $mta;
17129
  }
17130
+ if ($mba > $maxlineHeight) {
17131
  $af += ($mba - $maxlineHeight);
17132
  $maxlineHeight = $mba;
17133
  }
17134
+ return $maxlineHeight;
17135
  }
17136
 
17137
  function TableWordWrap($maxwidth, $forcewrap = 0, $textbuffer = '', $def_fontsize, $returnarray=false) { // NB ** returnarray used in flowchart
17152
  if ((count($textbuffer) == 0) or ((count($textbuffer) == 1) && ($textbuffer[0][0] == ''))) { return 0; }
17153
 
17154
  $text = '';
17155
+ $lhfixed = false;
17156
  if (preg_match('/([0-9.,]+)mm/',$this->table_lineheight)) { $lhfixed = true; }
17157
  if ($lhfixed) { $def_lineheight = $this->_computeLineheight($this->table_lineheight, $def_fontsize);}
17158
  else { $def_lineheight = 0; }
17194
  list($skipln,$iw,$ih) = $this->inlineObject((isset($specialcontent['type']) ? $specialcontent['type'] : null),0,0, $objattr, $this->lMargin,$width,$maxwidth,$maxlineHeight,false,true);
17195
  if ($objattr['type'] == 'hr') {
17196
  // END OF LINE
17197
+ // Finalise & add lineheight
17198
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17199
  // Add HR height
17200
  $ch += $ih;
17213
  if ($skipln==1 || $skipln==-2) {
17214
  // Finish last line
17215
  // END OF LINE
17216
+ // Finalise & add lineheight
17217
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17218
  // START OF NEW LINE
17219
  // Initialise lineheight variables
17225
  $width = 0;
17226
  $text = "";
17227
  }
17228
+ $va = (isset($objattr['vertical-align']) ? $objattr['vertical-align'] : null);
17229
  if ($va) {
17230
  $lhxt[$va] = max($lhxt[$va], $ih);
17231
  }
17237
 
17238
  // SET FONT SIZE/STYLE from $chunk[n]
17239
  // FONTSIZE
17240
+ if(isset($chunk[11]) and $chunk[11] != '') {
17241
  if ($this->shrin_k) {
17242
+ $this->SetFontSize($chunk[11]/$this->shrin_k,false);
17243
  }
17244
  else {
17245
+ $this->SetFontSize($chunk[11],false);
17246
  }
17247
  }
17248
  if ($line == "\n") {
17249
  // END OF LINE
17250
+ $maxfontsize = max($maxfontsize,$this->FontSize);
17251
  $fh = $this->_computeLineheight($this->table_lineheight);
17252
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17253
  $fh = $this->FontSize;
17254
+ $forceExactLineheight = false;
17255
  }
17256
+ $maxlineHeight = max($maxlineHeight,$fh);
17257
 
17258
+ // Finalise & add lineheight
17259
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17260
  // START OF NEW LINE
17261
  // Initialise lineheight variables
17266
  $ln++;
17267
  $text = "";
17268
  $width = 0;
17269
+ if(isset($chunk[11]) and $chunk[11] != '') {
17270
  $this->SetFontSize($this->default_font_size,false);
17271
  }
17272
  continue;
17279
  if (isset($this->spanborddet['R'])) $rbw = $this->spanborddet['R']['w'];
17280
  }
17281
  if(isset($chunk[15])) { // Word spacing
17282
+ $this->wSpacingCSS = $chunk[15];
17283
+ if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
17284
+ $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
17285
  }
17286
  }
17287
  if(isset($chunk[14])) { // Letter spacing
17288
+ $this->lSpacingCSS = $chunk[14];
17289
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
17290
  $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
17291
  }
17292
  }
17293
  if(isset($chunk[13])) { // Font Kerning
17294
+ $this->kerning = $chunk[13];
17295
  }
17296
  // FONTFAMILY
17297
  if(isset($chunk[4]) and $chunk[4] != '') { $font = $this->SetFont($chunk[4],$this->FontStyle,0,false); }
17345
  }
17346
  if (!$oneCJKorphan && (preg_match('/[\.\]),;:!?"'.$curlyquote . $curlylowquote . $raquote.$rsquo.$sbquo.$bdquo.']$/'.$matchsuff,mb_substr($word,0,$i+1,$this->mb_enc )) || (!$this->usingCoreFont && preg_match('/['.$this->CJKoverflow.']$/u',mb_substr($word,0,$i+1,$this->mb_enc ))))) { // mPDF.5.5.01 mPDF.5.5.05 mPDF 5.5.07 // mPDF 5.5.20
17347
  $wordwidth = $maxwidth - 0.0001;
17348
+ $oneCJKorphan = true;
17349
  continue;
17350
  }
17351
  if ($text && $firstchunk) {
17352
  // END OF LINE
17353
+ // Finalise & add lineheight
17354
+ $maxfontsize = max($maxfontsize,$this->FontSize);
17355
  $fh = $this->_computeLineheight($this->table_lineheight);
17356
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17357
  $fh = $this->FontSize;
17358
+ $forceExactLineheight = false;
17359
  }
17360
+ $maxlineHeight = max($maxlineHeight,$fh);
17361
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17362
  // START OF NEW LINE
17363
  // Initialise lineheight variables
17368
  $ln++;
17369
  }
17370
  // END OF LINE
17371
+ // Finalise & add lineheight
17372
+ $maxfontsize = max($maxfontsize,$this->FontSize);
17373
  $fh = $this->_computeLineheight($this->table_lineheight);
17374
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17375
  $fh = $this->FontSize;
17376
+ $forceExactLineheight = false;
17377
  }
17378
+ $maxlineHeight = max($maxlineHeight,$fh);
17379
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17380
  // START OF NEW LINE
17381
  // Initialise lineheight variables
17388
  $text = mb_substr($word,0,$i,$this->mb_enc );
17389
  $word = mb_substr($word,$i,mb_strlen($word, $this->mb_enc )-$i,$this->mb_enc );
17390
  $wordwidth = $this->GetStringWidth($word);
17391
+ $width = 0;
17392
  $firstchunk=false;
17393
  break;
17394
  }
17418
  if ($k==(count($words)-1)) { $tmpwidth += $rbw; }
17419
  if ($width + $tmpwidth < $maxwidth + 0.0001) { $alloworphans = true; }
17420
  }
17421
+ // If line = SUB/SUP to max of orphansallowed ( $this->SUP || $this->SUB )
17422
  if(( (isset($chunk[5]) and $chunk[5]) || (isset($chunk[6]) and $chunk[6])) && strlen($word) <= $this->orphansAllowed) {
17423
  $alloworphans = true;
17424
  if ($k==1) { echo $word; exit; }
17433
  }
17434
  else {
17435
  // END OF LINE
17436
+ // Finalise & add lineheight
17437
+ $maxfontsize = max($maxfontsize,$this->FontSize);
17438
  $fh = $this->_computeLineheight($this->table_lineheight);
17439
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17440
  $fh = $this->FontSize;
17441
+ $forceExactLineheight = false;
17442
  }
17443
+ $maxlineHeight = max($maxlineHeight,$fh);
17444
  $ch += $this->finaliseCellLineHeight($lhxt, $maxfontsize, $maxlineHeight, $lhfixed, $forceExactLineheight);
17445
  $mxw = $maxwidth;
17446
  // START OF NEW LINE
17454
  $text = $word.' ';
17455
  }
17456
  }
17457
+ $maxfontsize = max($maxfontsize,$this->FontSize);
17458
  $fh = $this->_computeLineheight($this->table_lineheight);
17459
  if ($lhfixed && $this->FontSize > $def_fontsize) {
17460
  $fh = $this->FontSize;
17461
+ $forceExactLineheight = false;
17462
  }
17463
+ $maxlineHeight = max($maxlineHeight,$fh);
17464
  }
17465
 
17466
  // End of textbuffer chunk
17478
  if(isset($chunk[4]) and $chunk[4] != '') {
17479
  $this->SetFont($this->default_font,$this->FontStyle,0,false);
17480
  }
17481
+ if(isset($chunk[11]) and $chunk[11] != '') {
17482
  $this->SetFontSize($this->default_font_size,false);
17483
  }
17484
  $this->spanborddet = array();
17485
+ $this->kerning = false;
17486
  $this->lSpacingCSS = '';
17487
  $this->wSpacingCSS = '';
17488
  $this->fixedlSpacing = false;
17489
+ $this->minwSpacing = 0;
17490
  }
17491
  // Finalise lineheight if something output on line and add
17492
  if ($width) {
17512
  // IMAGES & FORM ELEMENTS
17513
  if (substr($line,0,3) == "\xbb\xa4\xac") { //inline object - FORM element or IMAGE!
17514
  $objattr = $this->_getObjAttr($line);
17515
+ if ($objattr['type']!='hr' && isset($objattr['width']) && ($objattr['width']/$this->shrin_k) > ($maxwidth + 0.0001) ) {
17516
  if (($objattr['width']/$this->shrin_k) > $biggestword) { $biggestword = ($objattr['width']/$this->shrin_k); }
17517
  $toonarrow=true;
17518
  }
17526
  // SET FONT SIZE/STYLE from $chunk[n]
17527
 
17528
  // FONTSIZE
17529
+ if(isset($chunk[11]) and $chunk[11] != '') {
17530
  if ($this->shrin_k) {
17531
+ $this->SetFontSize($chunk[11]/$this->shrin_k,false);
17532
  }
17533
  else {
17534
+ $this->SetFontSize($chunk[11],false);
17535
  }
17536
  }
17537
  // FONTFAMILY
17548
  $rbw = $this->spanborddet['R']['w'];
17549
  }
17550
  if(isset($chunk[15])) { // Word spacing
17551
+ $this->wSpacingCSS = $chunk[15];
17552
+ if ($this->wSpacingCSS && strtoupper($this->wSpacingCSS) != 'NORMAL') {
17553
  $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
17554
  }
17555
  }
17556
  if(isset($chunk[14])) { // Letter spacing
17557
+ $this->lSpacingCSS = $chunk[14];
17558
  if (($this->lSpacingCSS || $this->lSpacingCSS==='0') && strtoupper($this->lSpacingCSS) != 'NORMAL') {
17559
+ $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
17560
  }
17561
  }
17562
  if(isset($chunk[13])) { // Font Kerning
17563
+ $this->kerning = $chunk[13];
17564
  }
17565
 
17566
  $words = explode(' ', $line);
17586
  if(isset($chunk[4]) and $chunk[4] != '') {
17587
  $this->SetFont($this->default_font,$this->FontStyle,0,false);
17588
  }
17589
+ if(isset($chunk[11]) and $chunk[11] != '') {
17590
  $this->SetFontSize($this->default_font_size,false);
17591
  }
17592
  $this->spanborddet = array();
17597
  $this->minwSpacing = 0;
17598
  }
17599
 
17600
+ //Return -(wordsize) if word is bigger than maxwidth
17601
  // ADDED
17602
  if (($toonarrow) && ($this->table_error_report)) {
17603
+ $this->Error("Word is too long to fit in table - ".$this->table_error_report_param);
17604
  }
17605
  if ($toonarrow) return -$biggestword;
17606
  else return 1;
17653
  if ($this->cacheTables) {
17654
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
17655
  }
17656
+ else
17657
  $c = &$table['cells'][$i][$j];
17658
  if (isset($c) && $c) {
17659
  if (!$this->simpleTables){
17702
  if (isset($c['nestedmiw'])) $c['nestedmiw'] /= $k;
17703
  if (isset($c['textbuffer'])) {
17704
  foreach($c['textbuffer'] AS $n=>$tb) {
17705
+ if (!empty($tb[16])) {
17706
  $c['textbuffer'][$n][16]['T']['w'] /= $k;
17707
  $c['textbuffer'][$n][16]['B']['w'] /= $k;
17708
  $c['textbuffer'][$n][16]['L']['w'] /= $k;
17759
  $c['gradient'] /* A128 (128 bytes) [pos 44 + 19*D] */
17760
  );
17761
 
17762
+ if ($c['background-image']) {
17763
  $data .= pack("n2d2A6A6n3dA4A128",
17764
  strlen($data), /* offset in main data to start of bgimage data */
17765
  $c['background-image']['image_id'], /* n */
17781
  $lentb = strlen($stb);
17782
  $data2 = pack("nA".$lentb, $lentb, $stb);
17783
 
17784
+ $tempfh = true;
17785
  if ($mode=="W" && $offset) {
17786
  if (!$fh) { $fh = fopen($file, "r+b"); } // Overwrite (but not truncate)
17787
  else $tempfh = false;
17805
  fseek($fh, ($tb_offset-2), SEEK_CUR);
17806
  $lentb = $this->read_short($fh); // First entry in textbuffer = Length of serialized textbuffer - do not update
17807
  $stb = serialize($c['textbuffer']);
17808
+ fwrite($fh, pack("A".$lentb, $stb));
17809
  }
17810
 
17811
  function _cacheUpdateBorder($c, $fh, $offset) {
17812
  $offset += 2;
17813
  fseek($fh, $offset);
17814
+ fwrite($fh, $c['borderbin']);
17815
  }
17816
 
17817
  function _cacheUpdateMtx($c, $fh, $offset, $var) {
17828
  // Requires either $file or $fh (file_handle)
17829
  if ($ptr==0) { return null; }
17830
  if (is_array($ptr)) { $this->Error("Probable cause - missing end tag &lt;/td&gt;. You may be able to change the configurable variable: allow_html_optional_endtags "); }
17831
+ $tempfh = true;
17832
  if (!$fh) { $fh = fopen($file, "rb"); }
17833
  else $tempfh = false;
17834
  fseek($fh, $ptr);
17863
  $c['a'] = trim($data['a']); /* A1 */
17864
  $c['va'] = trim($data['va']); /* A1 */
17865
  if ($data['nowrap']) $c['nowrap'] = $data['nowrap']; /* 1 or blank n */
17866
+ else $c['nowrap'] = false;
17867
  if ($data['wpercent']>0) $c['wpercent'] = $data['wpercent']; /* 0 - 100 n */
17868
  if ($data['R']<>0) $c['R'] = $data['R']; /* 90 or -90 s */
17869
  else $c['R'] = false;
17870
  $c['bgcolor'] = trim($data['bgcol']); /* A32 */
17871
+ if (trim($data['grad']))
17872
  $c['gradient'] = trim($data['grad']); /* A128 */
17873
  else $c['gradient'] = false;
17874
  if ($data['bgimage']>0) {
17887
  function read_short(&$fh) {
17888
  $s = fread($fh,2);
17889
  $a = (ord($s[0])<<8) + ord($s[1]);
17890
+ if ($a & (1 << 15) ) {
17891
+ $a = ($a - (1 << 16));
17892
  }
17893
  return $a;
17894
  }
18032
  $nr = $table['nr'];
18033
  $listspan = array();
18034
 
18035
+ if ($table['borders_separate']) {
18036
  $tblbw = $table['border_details']['L']['w'] + $table['border_details']['R']['w'] + $table['margin']['L'] + $table['margin']['R'] + $table['padding']['L'] + $table['padding']['R'] + $table['border_spacing_H'];
18037
  }
18038
  else { $tblbw = $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2 + $table['margin']['L'] + $table['margin']['R']; }
18040
  if ($this->cacheTables) { $fh = fopen($table['cache'], "r+b"); }
18041
  else { $fh = null; }
18042
 
18043
+ // ADDED table['l'][colno]
18044
  // = total length of text approx (using $c['s']) in that column - used to approximately distribute col widths in _tableWidth
18045
  //
18046
  for($j = 0 ; $j < $nc ; $j++ ) { //columns
18050
  if ($this->cacheTables) {
18051
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18052
  }
18053
+ else
18054
  $c = &$cs[$i][$j];
18055
 
18056
  if ($this->simpleTables){
18065
  if ($this->packTableData) {
18066
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18067
  }
18068
+ else {
18069
  $br = $c['border_details']['R']['w'];
18070
  $bl = $c['border_details']['L']['w'];
18071
  }
18091
  if ($wc['miw'] < $c['miw']) { $wc['miw'] = $c['miw']; }
18092
  if ($wc['maw'] < $c['maw']) { $wc['maw'] = $c['maw']; }
18093
 
18094
+ if ($firstpass) {
18095
+ if (isset($table['l'][$j]) ) {
18096
  $table['l'][$j] += $c['miw'] ;
18097
  }
18098
  else {
18100
  }
18101
  }
18102
  }
18103
+ if ($c['miw'] > $wc['miw']) { $wc['miw'] = $c['miw']; }
18104
  if ($wc['miw'] > $wc['maw']) { $wc['maw'] = $wc['miw']; }
18105
  continue;
18106
  }
18124
  else $c['maw'] = $c['s'];
18125
 
18126
  if (isset($table['overflow']) && $table['overflow']=='visible' && $table['level']==1) {
18127
+ if (($c['maw'] + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18128
  $c['maw'] = $this->blk[$this->blklvl]['inner_width'] - $tblbw;
18129
  }
18130
  }
18144
  }
18145
 
18146
  if (isset($table['overflow']) && $table['overflow']=='visible' && $table['level']==1) {
18147
+ if (($c['w'] + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18148
  $c['w'] = $this->blk[$this->blklvl]['inner_width'] - $tblbw;
18149
  }
18150
  }
18164
  if ($wc['maw'] < $c['maw']) { $wc['maw'] = $c['maw']; }
18165
  if ((isset($wc['absmiw']) && $wc['absmiw'] < $c['absmiw']) || !isset($wc['absmiw'])) { $wc['absmiw'] = $c['absmiw']; } // Update Col Minimum and maximum widths
18166
 
18167
+ if (isset($table['l'][$j]) ) {
18168
  $table['l'][$j] += $c['s'];
18169
  }
18170
  else {
18172
  }
18173
 
18174
  }
18175
+ else {
18176
  $listspan[] = array($i,$j);
18177
  }
18178
 
18181
  $minwidth = $this->TableCheckMinWidth($wc['miw']- $extrcw ,0,$c['textbuffer']);
18182
  }
18183
  else { $minwidth = 0; }
18184
+ if ($minwidth < 0) {
18185
  //increase minimum width
18186
  if (!isset($c['colspan'])) {
18187
+ $wc['miw'] = max($wc['miw'],((-$minwidth) + $extrcw) );
18188
  }
18189
  else {
18190
+ $c['miw'] = max($c['miw'],((-$minwidth) + $extrcw) );
18191
  }
18192
  }
18193
  if (!isset($c['colspan'])) {
18209
  if ($this->cacheTables) {
18210
  $c = $this->_uncacheCell($cs[$i][$j], '', $fh);
18211
  }
18212
+ else
18213
  $c = &$cs[$i][$j];
18214
  $lc = $j + $c['colspan'];
18215
  if ($lc > $nc) { $lc = $nc; }
18217
  $was = $wasa = 0;
18218
  $list = array();
18219
  for($k=$j;$k<$lc;$k++) {
18220
+ if (isset($table['l'][$k]) ) {
18221
  if ($c['R']) { $table['l'][$k] += $c['miw']/$c['colspan'] ; }
18222
  else { $table['l'][$k] += $c['s']/$c['colspan']; }
18223
  }
18321
  if ($miwleft && $sumnonpc > 0) { $miwnon = $miwleft * 100 / $sumnonpc; }
18322
  if ($mawleft && $sumnonpc > 0) { $mawnon = $mawleft * 100 / $sumnonpc; }
18323
  if (($miwnon > $checkminwidth || $maxcalcmiw > $checkminwidth) && $this->keep_table_proportions) {
18324
+ if ($miwnon > $maxcalcmiw) {
18325
+ $miwsurplusnonpc = round((($miwnon * $sumnonpc / 100) - $miwleft),3);
18326
+ $checkminwidth = $miwnon;
18327
  }
18328
  else { $checkminwidth = $maxcalcmiw; }
18329
  for( $i = 0 ; $i < $nc ; $i++ ) {
18340
  }
18341
  }
18342
  if (($mawnon > $checkmaxwidth || $maxcalcmaw > $checkmaxwidth )) {
18343
+ if ($mawnon > $maxcalcmaw) {
18344
+ $mawsurplusnonpc = round((($mawnon * $sumnonpc / 100) - $mawleft),3);
18345
+ $checkmaxwidth = $mawnon;
18346
  }
18347
  else { $checkmaxwidth = $maxcalcmaw; }
18348
  for( $i = 0 ; $i < $nc ; $i++ ) {
18386
  $mxw = $this->blk[$this->blklvl]['inner_width'];
18387
  }
18388
  if(!isset($table['overflow'])) { $table['overflow'] = null; }
18389
+ if ($table['overflow']=='visible') {
18390
+ return array(0,0);
18391
  }
18392
  else if ($table['overflow']=='hidden' && !$this->table_rotate && !$this->ColActive && $checkminwidth > $mxw) {
18393
+ $table['w'] = $table['miw'];
18394
  return array(0,0);
18395
  }
18396
  else if ($table['overflow']=='wrap') { return array(0,0); }
18398
  if (isset($table['w']) && $table['w'] ) {
18399
  if ($table['w'] >= $checkminwidth && $table['w'] <= $mxw) { $table['maw'] = $mxw = $table['w']; }
18400
  else if ($table['w'] >= $checkminwidth && $table['w'] > $mxw && $this->keep_table_proportions) { $checkminwidth = $table['w']; }
18401
+ else {
18402
+ unset($table['w']);
18403
  }
18404
  }
18405
  $ratio = $checkminwidth/$mxw;
18406
  if ($checkminwidth > $mxw) { return array(($ratio +0.001),$checkminwidth); } // 0.001 to allow for rounded numbers when resizing
18407
  }
18408
+ unset($cs);
18409
  return array(0,0);
18410
  }
18411
 
18415
  $widthcols = &$table['wc'];
18416
  $numcols = $table['nc'];
18417
  $tablewidth = 0;
18418
+ if ($table['borders_separate']) {
18419
  $tblbw = $table['border_details']['L']['w'] + $table['border_details']['R']['w'] + $table['margin']['L'] + $table['margin']['R'] + $table['padding']['L'] + $table['padding']['R'] + $table['border_spacing_H'];
18420
  }
18421
  else { $tblbw = $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2 + $table['margin']['L'] + $table['margin']['R']; }
18422
 
18423
+ if ($table['level']>1 && isset($table['w'])) {
18424
+ if (isset($table['wpercent']) && $table['wpercent']) {
18425
+ $table['w'] = $temppgwidth = (($table['w']-$tblbw) * $table['wpercent'] / 100) + $tblbw ;
18426
  }
18427
+ else {
18428
+ $temppgwidth = $table['w'] ;
18429
  }
18430
  }
18431
  else if ($this->table_rotate) {
18436
  if ($enddiv/$temppgwidth <0.05) { $temppgwidth -= $enddiv; }
18437
  }
18438
  else {
18439
+ if (isset($table['w']) && $table['w']< $this->blk[$this->blklvl]['inner_width']) {
18440
  $notfullwidth = 1;
18441
+ $temppgwidth = $table['w'] ;
18442
  }
18443
  else if ($table['overflow']=='visible' && $table['level'] ==1) {
18444
  $temppgwidth = null;
18445
  }
18446
  else if ($table['overflow']=='hidden' && !$this->ColActive && isset($table['w']) && $table['w'] > $this->blk[$this->blklvl]['inner_width'] && $table['w']==$table['miw']) {
18447
+ //$temppgwidth = $this->blk[$this->blklvl]['inner_width'];
18448
  $temppgwidth = $table['w'] ;
18449
  }
18450
  else { $temppgwidth = $this->blk[$this->blklvl]['inner_width']; }
18453
 
18454
  $totaltextlength = 0; // Added - to sum $table['l'][colno]
18455
  $totalatextlength = 0; // Added - to sum $table['l'][colno] for those columns where width not set
18456
+ $percentages_set = 0;
18457
  for ( $i = 0 ; $i < $numcols ; $i++ ) {
18458
  if (isset($widthcols[$i]['wpercent'])) { $tablewidth += $widthcols[$i]['maw']; $percentages_set = 1; }
18459
  else if (isset($widthcols[$i]['w'])) { $tablewidth += $widthcols[$i]['miw']; }
18463
  if (!$totaltextlength) { $totaltextlength =1; }
18464
  $tablewidth += $tblbw; // Outer half of table borders
18465
 
18466
+ if ($tablewidth > $temppgwidth) {
18467
+ $table['w'] = $temppgwidth;
18468
  }
18469
  // if any widths set as percentages and max width fits < page width
18470
  else if ($tablewidth < $temppgwidth && !isset($table['w']) && $percentages_set) {
18479
  $notsetlist = array();
18480
  for( $i = 0 ; $i < $numcols ; $i++ ) {
18481
  $wis += $widthcols[$i]['miw'];
18482
+ if (!isset($widthcols[$i]['w']) || ($widthcols[$i]['w'] && $table['w'] > $temppgwidth && !$this->keep_table_proportions && !$notfullwidth )){
18483
+ $list[] = $i;
18484
  $wisa += $widthcols[$i]['miw'];
18485
  $totalatextlength += $table['l'][$i];
18486
  }
18512
  $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']);
18513
  $widthcols[$k]['miw'] = $widthcols[$k]['maw'];
18514
  }
18515
+ else {
18516
+ $notsetlist[] = $k;
18517
  $ttl += $table['l'][$k];
18518
+ $widthcols[$k]['miw'] += ($wi * $spareratio);
18519
  }
18520
 
18521
  }
18529
  $surplus += ($wi * $spareratio) - ($widthcols[$k]['maw']-$widthcols[$k]['miw']);
18530
  $widthcols[$k]['miw'] = $widthcols[$k]['maw'];
18531
  }
18532
+ else {
18533
+ $notsetlist[] = $k;
18534
  $ttl += $table['l'][$k];
18535
+ $widthcols[$k]['miw'] += ($wi * $spareratio);
18536
  }
18537
  }
18538
  }
18539
  // If surplus still left over apportion it across columns
18540
+ if ($surplus) {
18541
  // if some are set only add to remaining - otherwise add to all of them
18542
  if (count($notsetlist) && count($notsetlist) < $numcols) {
18543
  foreach ($notsetlist AS $i) {
18571
  for ( $i = 0 ; $i < $numcols ; $i++ ) {
18572
  $checktablewidth += $widthcols[$i];
18573
  }
18574
+ if ($checktablewidth > ($temppgwidth + 0.001 - $tblbw)) {
18575
  $usedup = 0; $numleft = 0;
18576
  for ($i=0;$i<$numcols;$i++) {
18577
+ if ((isset($widthcols[$i]) && $widthcols[$i] > (($temppgwidth - $tblbw) / $numcols)) && (!isset($widthcols[$i]['w']))) {
18578
+ $numleft++;
18579
+ unset($widthcols[$i]);
18580
  }
18581
  else { $usedup += $widthcols[$i]; }
18582
  }
18583
  for ($i=0;$i<$numcols;$i++) {
18584
+ if (!isset($widthcols[$i]) || !$widthcols[$i]) {
18585
+ $widthcols[$i] = ((($temppgwidth - $tblbw) - $usedup)/ ($numleft));
18586
  }
18587
  }
18588
  }
18589
 
18590
  }
18591
  else { //table has no width defined
18592
+ $table['w'] = $tablewidth;
18593
  for ( $i = 0 ; $i < $numcols ; $i++) {
18594
  if (isset($widthcols[$i]['wpercent']) && $this->keep_table_proportions) { $colwidth = $widthcols[$i]['maw']; }
18595
  else if (isset($widthcols[$i]['w'])) { $colwidth = $widthcols[$i]['miw']; }
18610
  $cc = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18611
  $colspan = $cc['colspan'];
18612
  }
18613
+ else
18614
  $colspan = $table['cells'][$i][$j]['colspan'];
18615
  if ($colspan > 1) {
18616
  $w = 0;
18635
  $pgNo = 0;
18636
  $currWc = 0;
18637
  for ($i = 0 ; $i < $numcols; $i++) { //columns
18638
+ if (isset($table['csp'][$i])) {
18639
+ $w = $table['csp'][$i];
18640
  unset($table['csp'][$i]);
18641
  }
18642
  else { $w = $widthcols[$i]; }
18643
+ if (($currWc + $w + $tblbw) > $this->blk[$this->blklvl]['inner_width']) {
18644
  $pgNo++;
18645
  $currWc = $widthcols[$i] ;
18646
  }
18694
  if ($this->cacheTables) {
18695
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18696
  }
18697
+ else
18698
  $c = &$cells[$i][$j];
18699
 
18700
  if ($this->simpleTables){
18711
  if ($this->packTableData) {
18712
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18713
  }
18714
+ else {
18715
  $bt = $c['border_details']['T']['w'];
18716
  $bb = $c['border_details']['B']['w'];
18717
  $br = $c['border_details']['R']['w'];
18727
  }
18728
  }
18729
 
18730
+ if ($table['overflow']=='visible' && $level==1)
18731
  list($x,$cw) = $this->_splitTableGetWidth($table, $i,$j, $fh);
18732
+ else
18733
  list($x,$cw) = $this->_tableGetWidth($table, $i,$j, $fh);
18734
 
18735
+ // Get CELL HEIGHT
18736
  // ++ extra parameter forces wrap to break word
18737
  if ($c['R'] && isset($c['textbuffer'])) { // mPDF 5.4.01
18738
  $str = '';
18745
  $tempch = $this->GetStringWidth($str);
18746
  if ($c['R'] >= 45 && $c['R'] < 90) {
18747
  $tempch = ((sin(deg2rad($c['R']))) * $tempch ) + ((sin(deg2rad($c['R']))) * (($c['textbuffer'][0][11]/_MPDFK) / $this->shrin_k));
18748
+ }
18749
  $this->SetFont($s_f,$s_st,$s_fs,true,true);
18750
+ $ch = ($tempch ) + $extrh ;
18751
  }
18752
  else {
18753
  if (isset($c['textbuffer'])) {
18771
  elseif ($heightrow < $ch) $heightrow = $ch;
18772
 
18773
  // this is the extra used in _tableWrite to determine whether to trigger a page change
18774
+ if ($table['borders_separate']) {
18775
  if ($i == ($numrows-1) || (isset($c['rowspan']) && ($i+$c['rowspan']) == ($numrows)) ) {
18776
+ $extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
18777
  }
18778
  else {
18779
+ $extra = $table['border_spacing_V']/2;
18780
  }
18781
  }
18782
+ else {
18783
  if (!$this->simpleTables){
18784
+ $extra = $bb/2;
18785
  }
18786
  else if ($this->simpleTables){
18787
+ $extra = $table['simple']['border_details']['B']['w'] /2;
18788
  }
18789
  }
18790
  if (isset($table['is_thead'][$i]) && $table['is_thead'][$i]) {
18815
  if ($this->cacheTables) {
18816
  $c = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18817
  }
18818
+ else
18819
  $c = &$cells[$i][$j];
18820
  $lr = $i + $c['rowspan'];
18821
  if ($lr > $numrows) $lr = $numrows;
18829
  }
18830
  }
18831
 
18832
+ if ($table['borders_separate']) {
18833
  if ($i == ($numrows-1) || ($i+$c['rowspan']) == ($numrows) ) {
18834
+ $extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
18835
  }
18836
  else {
18837
+ $extra = $table['border_spacing_V']/2;
18838
  }
18839
  }
18840
+ else {
18841
  if (!$this->simpleTables){
18842
  if ($this->packTableData) {
18843
  list($bt,$br,$bb,$bl) = $this->_getBorderWidths($c['borderbin']);
18844
  }
18845
+ else {
18846
  $bb = $c['border_details']['B']['w'];
18847
  }
18848
+ $extra = $bb/2;
18849
  }
18850
  else if ($this->simpleTables){
18851
+ $extra = $table['simple']['border_details']['B']['w'] /2;
18852
  }
18853
  }
18854
  if (!empty($table['is_thead'][$i])) {
18891
  if ($this->cacheTables) {
18892
  $c = $this->_uncacheCell($table['cells'][$cki][$ckj], '', $fh);
18893
  }
18894
+ else
18895
  $c = &$cells[$cki][$ckj];
18896
  if (isset($c['rowspan']) && $c['rowspan']>1) {
18897
  if (($cki + $c['rowspan']-1) >= $i) { $top = min($top, $cki); }
18907
  // ???? take account of colspan as well???
18908
  for( $m = 0 ; $m < $numcols ; $m++ ) { //columns
18909
  if (!isset($cells[$k][$m]) || $cells[$k][$m]==0) {
18910
+ break(2);
18911
  }
18912
  }
18913
  }
18917
  if ($this->cacheTables) {
18918
  $c = $this->_uncacheCell($table['cells'][$k][$m], '', $fh);
18919
  }
18920
+ else
18921
  $c = &$cells[$k][$m];
18922
  if (isset($c['rowspan']) && $c['rowspan']>1) {
18923
+ break(2);
18924
  }
18925
  }
18926
  }
18932
  $newhr = array();
18933
  for( $m = 0 ; $m < $numcols ; $m++ ) { //columns
18934
  for ($k=$top; $k<=$bottom; $k++) {
18935
+ if (isset($cells[$k][$m]) && $cells[$k][$m]!=0) {
18936
  if ($this->cacheTables) {
18937
  $c = $this->_uncacheCell($table['cells'][$k][$m], '', $fh);
18938
  }
18939
+ else
18940
  $c = &$cells[$k][$m];
18941
+ if (isset($c['h']) && $c['h']) {
18942
  $useh = $c['h'];
18943
  }
18944
  // ???? take account of colspan as well???
18945
+ else {
18946
+ $useh = $c['mih'];
18947
  }
18948
+ $colH[$m] += $useh;
18949
  if (!isset($c['rowspan']) || $c['rowspan']<2) { $newhr[$k] = max($newhr[$k], $useh); }
18950
  }
18951
  }
18964
 
18965
  if ($this->cacheTables) { fclose($fh); }
18966
 
18967
+ if ($table['borders_separate']) {
18968
  $table['h'] += $table['margin']['T'] + $table['margin']['B'] + $table['border_details']['T']['w'] + $table['border_details']['B']['w'] + $table['border_spacing_V'] + $table['padding']['T'] + $table['padding']['B'];
18969
  }
18970
+ else {
18971
  $table['h'] += $table['margin']['T'] + $table['margin']['B'] + $table['max_cell_border_width']['T']/2 + $table['max_cell_border_width']['B']/2;
18972
  }
18973
 
18980
  if ($this->cacheTables) {
18981
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
18982
  }
18983
+ else
18984
  $cell = &$table['cells'][$i][$j];
18985
  if ($cell) {
18986
  if (isset($cell['x0'])) { return array($cell['x0'], $cell['w0']); }
19005
  if ($this->cacheTables) {
19006
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19007
  }
19008
+ else
19009
  $cell = &$table['cells'][$i][$j];
19010
  if ($cell) {
19011
  if (isset($cell['x0'])) return array($cell['x0'], $cell['w0']);
19034
  if ($this->cacheTables) {
19035
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19036
  }
19037
+ else
19038
  $cell = &$table['cells'][$i][$j];
19039
  if ($cell){
19040
  if (isset($cell['y0'])) return array($cell['y0'], $cell['h0']);
19066
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19067
  if ($cell) {
19068
  if (isset($cell['colspan'])) { $cellsset += $cell['colspan']; }
19069
+ else $cellsset += 1;
19070
  }
19071
  }
19072
  else {
19073
+ if ($table['cells'][$i][$j]) {
19074
  if (isset($table['cells'][$i][$j]['colspan'])) { $cellsset += $table['cells'][$i][$j]['colspan']; }
19075
+ else $cellsset += 1;
19076
  }
19077
  }
19078
  }
19091
  if ($bord==-1) { $this->Rect($x, $y, $w, $h); }
19092
  else if ($this->simpleTables && ($cort=='cell')) {
19093
  $this->SetLineWidth($details['L']['w']);
19094
+ if ($details['L']['c']) {
19095
  $this->SetDColor($details['L']['c']);
19096
  }
19097
  else { $this->SetDColor($this->ConvertColor(0)); }
19098
  $this->SetLineJoin(0);
19099
+ $this->Rect($x, $y, $w, $h);
19100
  }
19101
  else if ($bord){
19102
  if (!$bSeparate && $buffer) {
19112
 
19113
  // Precedence to darker colours at joins
19114
  $coldom = 0;
19115
+ if (isset($details[$side]['c']) && is_array($details[$side]['c'])) {
19116
  if ($details[$side]['c']{0}==3) { // RGB
19117
+ $coldom = 10-(((ord($details[$side]['c']{1})*1.00)+(ord($details[$side]['c']{2})*1.00)+(ord($details[$side]['c']{3})*1.00))/76.5);
19118
  }
19119
  } // 10 black - 0 white
19120
  if ($coldom) { $dom += $coldom; }
19121
  // Lastly precedence to RIGHT and BOTTOM cells at joins
19122
+ if (isset($details['cellposdom'])) { $dom += $details['cellposdom']; }
19123
 
19124
  $save = false;
19125
  if ($side == 'T' && $this->issetBorder($bord, _BORDER_TOP)) { $cbord = _BORDER_TOP; $save = true; }
19135
  $details[$side]['s'],
19136
  $details[$side]['w'],
19137
  $details[$side]['c'],
19138
+ $details[$side]['style'],
19139
  $x, $y, $w, $h,
19140
  $details['mbw']['BL'],
19141
  $details['mbw']['BR'],
19157
  $details[$side]['s'],
19158
  $details[$side]['w'],
19159
  $details[$side]['c'],
19160
+ $details[$side]['style'],
19161
  $x, $y, $w, $h,
19162
  $details['mbw']['BL'],
19163
  $details['mbw']['BR'],
19178
 
19179
  if (isset($details['p']) && strlen($details['p'])>1) { $priority = $details['p']; }
19180
  else { $priority='LTRB'; }
19181
+ $Tw = 0;
19182
+ $Rw = 0;
19183
+ $Bw = 0;
19184
+ $Lw = 0;
19185
  if (isset($details['T']['w'])) { $Tw = $details['T']['w']; }
19186
  if (isset($details['R']['w'])) { $Rw = $details['R']['w']; }
19187
  if (isset($details['B']['w'])) { $Bw = $details['B']['w']; }
19308
  $this->SetLineCap(1);
19309
  $this->SetDash(0.001,($this->LineWidth*2));
19310
  }
19311
+ if ($details[$side]['c']) {
19312
  $this->SetDColor($details[$side]['c']);
19313
  }
19314
  else { $this->SetDColor($this->ConvertColor(0)); }
19315
  $this->Line($lx1 + $xadj, $ly1 + $yadj, $lx2 - $xadj2, $ly2 - $yadj2);
19316
 
19317
  // Reset Corners
19318
+ $this->SetDash();
19319
  //BUTT style line cap
19320
  $this->SetLineCap(2);
19321
  }
19324
  if ($bSeparate && count($cellBorderOverlay)) {
19325
  foreach($cellBorderOverlay AS $cbo) {
19326
  $this->SetLineWidth($cbo['lw']);
19327
+ $this->SetDColor($cbo['col']);
19328
  $this->Line($cbo['x'], $cbo['y'], $cbo['x2'], $cbo['y2']);
19329
  }
19330
  }
19354
  function _table2cellBorder(&$tableb, &$cbdb, &$cellb, $bval) {
19355
  if ($tableb && $tableb['w'] > $cbdb['w']) {
19356
  $cbdb = $tableb;
19357
+ $this->setBorder($cellb, $bval);
19358
  }
19359
+ else if ($tableb && $tableb['w'] == $cbdb['w']
19360
  && array_search($tableb['style'],$this->borderstyles) > array_search($cbdb['style'],$this->borderstyles)) {
19361
  $cbdb = $tableb;
19362
+ $this->setBorder($cellb, $bval);
19363
  }
19364
  }
19365
 
19369
  else { $fh = null; }
19370
 
19371
  if (!$table['borders_separate'] && $table['border_details']['L']['w']) {
19372
+ $table['max_cell_border_width']['L'] = $table['border_details']['L']['w'];
19373
  }
19374
  if (!$table['borders_separate'] && $table['border_details']['R']['w']) {
19375
+ $table['max_cell_border_width']['R'] = $table['border_details']['R']['w'];
19376
  }
19377
  if (!$table['borders_separate'] && $table['border_details']['T']['w']) {
19378
+ $table['max_cell_border_width']['T'] = $table['border_details']['T']['w'];
19379
  }
19380
  if (!$table['borders_separate'] && $table['border_details']['B']['w']) {
19381
+ $table['max_cell_border_width']['B'] = $table['border_details']['B']['w'];
19382
  }
19383
  if ($this->simpleTables) { return; }
19384
  $cells = &$table['cells'];
19391
  if ($this->cacheTables) {
19392
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19393
  }
19394
+ else
19395
  $cell = &$cells[$i][$j];
19396
  if ($this->packTableData) { // includes $this->cacheTables
19397
  $cbord = $this->_unpackCellBorder($cell['borderbin']);
19456
  if ($this->cacheTables) {
19457
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19458
  }
19459
+ else
19460
  $cell = &$cells[$i][$j];
19461
  $col = $numcols - $j - 1;
19462
  if (isset($cell['colspan']) && $cell['colspan'] > 1) { $col -= ($cell['colspan']-1); }
19477
  unset($cell);
19478
  }
19479
  }
19480
+ for($f=0; $f < $numcols; $f++) {
19481
  if (!isset($row[$f])) { $row[$f] = 0; }
19482
  }
19483
  $table['cells'][$i] = $row;
19506
  }
19507
  }
19508
  // Advance down page by half width of top border
19509
+ if ($table['borders_separate']) {
19510
  if ($startrow>0 && (!isset($table['is_thead']) || count($table['is_thead'])==0))
19511
+ $adv = $table['border_spacing_V']/2;
19512
+ else
19513
+ $adv = $table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2;
19514
  }
19515
+ else {
19516
+ $adv = $table['max_cell_border_width']['T']/2;
19517
  }
19518
  if (!$this->table_rotate && $level==1) { $this->DivLn($adv); }
19519
  else { $this->y += $adv; }
19521
 
19522
  if ($level==1) {
19523
  $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'];
19524
+ $x0 = $this->x;
19525
  $y0 = $this->y;
19526
  $right = $x0 + $this->blk[$this->blklvl]['inner_width'];
19527
  $outerfilled = $this->y; // Keep track of how far down the outer DIV bgcolor is painted (NB rowspans)
19529
  $this->colsums = array();
19530
  }
19531
  else {
19532
+ $x0 = $this->x;
19533
  $y0 = $this->y;
19534
  $right = $x0 + $table['w'];
19535
  }
19575
  $lastCol = 0;
19576
  $tableheader = array();
19577
  $tablefooter = array();
19578
+ $tableheaderrowheight = 0;
19579
  $tablefooterrowheight = 0;
19580
  $footery = 0;
19581
 
19582
  // mPD 3.0 Set the Page & Column where table starts
19583
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
19584
+ $tablestartpage = 'EVEN';
19585
  }
19586
  else if (($this->mirrorMargins) && (($this->page)%2==1)) { // ODD
19587
+ $tablestartpage = 'ODD';
19588
  }
19589
  else { $tablestartpage = ''; }
19590
  if ($this->ColActive) { $tablestartcolumn = $this->CurrCol; }
19595
 
19596
  $y = $h = 0;
19597
  for( $i = 0; $i < $numrows ; $i++ ) { //Rows
19598
+ if (isset($table['is_tfoot'][$i]) && $table['is_tfoot'][$i] && $level==1) {
19599
+ $tablefooterrowheight += $table['hr'][$i];
19600
  $tablefooter[$i][0]['trbackground-images'] = $table['trbackground-images'][$i];
19601
  $tablefooter[$i][0]['trgradients'] = $table['trgradients'][$i];
19602
  $tablefooter[$i][0]['trbgcolor'] = $table['bgcolor'][$i];
19605
  if ($this->cacheTables) {
19606
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19607
  }
19608
+ else
19609
  $cell = &$cells[$i][$j];
19610
+ if ($split) {
19611
  if ($table['colPg'][$j] != $splitpg) { continue; }
19612
+ list($x,$w) = $this->_splitTableGetWidth($table, $i, $j, $fh);
19613
  $js = $j - $startcol;
19614
  }
19615
+ else {
19616
+ list($x,$w) = $this->_tableGetWidth($table, $i, $j, $fh);
19617
  $js = $j;
19618
  }
19619
 
19620
+ list($y,$h) = $this->_tableGetHeight($table, $i, $j, $fh);
19621
  $x += $x0;
19622
  $y += $y0;
19623
  //Get info of tfoot ==>> table footer
19664
 
19665
  //Draw Table Contents and Borders
19666
  for( $i = 0; $i < $numrows ; $i++ ) { //Rows
19667
+ if ($split && $startrow > 0) {
19668
  $thnr = (isset($table['is_thead']) ? count($table['is_thead']) : 0);
19669
  if ($i >= $thnr && $i < $startrow) { continue; }
19670
  if ($i == $startrow){ $returny = $rety - $tableheaderrowheight; }
19676
  $skippage = false;
19677
  $newpagestarted = false;
19678
  for( $j = $startcol ; $j < $numcols ; $j++ ) { //Columns
19679
+ if ($split) {
19680
  if ($table['colPg'][$j] > $splitpg) { break; }
19681
+ $lastCol = $j;
19682
  }
19683
  if (isset($cells[$i][$j]) && $cells[$i][$j]) {
19684
  if ($this->cacheTables) {
19685
  $cell = $this->_uncacheCell($table['cells'][$i][$j], '', $fh);
19686
  }
19687
+ else
19688
  $cell = &$cells[$i][$j];
19689
+ if ($split) {
19690
+ $lastCol = $j + (isset($cell['colspan']) ? ($cell['colspan']-1) : 0) ;
19691
+ list($x,$w) = $this->_splitTableGetWidth($table, $i, $j, $fh);
19692
  }
19693
  else { list($x,$w) = $this->_tableGetWidth($table, $i, $j, $fh); }
19694
 
19697
  $y += $y0;
19698
  $y -= $returny;
19699
 
19700
+ if ($table['borders_separate']) {
19701
  if (!empty($tablefooter) || $i == ($numrows-1) || (isset($cell['rowspan']) && ($i+$cell['rowspan']) == $numrows) || (!isset($cell['rowspan']) && ($i+1) == $numrows) ) {
19702
+ $extra = $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
19703
+ //$extra = $table['margin']['B'] + $table['padding']['B'] + $table['border_details']['B']['w'] + $table['border_spacing_V']/2;
19704
  }
19705
  else {
19706
+ $extra = $table['border_spacing_V']/2;
19707
  }
19708
  }
19709
  else { $extra = $table['max_cell_border_width']['B']/2; }
19712
 
19713
  if (!$skippage) {
19714
  $finalSpread = true;
19715
+ $firstSpread = true;
19716
  if ($split) {
19717
  for($t=$startcol; $t<$numcols; $t++) {
19718
  // Are there more columns to print on a next page?
19724
  if ($startcol>0) { $firstSpread = false; }
19725
  }
19726
 
19727
+ if (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && $i > 0 ) {
19728
  $this->y = $y;
19729
  $ya = $this->y;
19730
  $this->TableHeaderFooter($tablefooter,$tablestartpage,$tablestartcolumn,'F',$level, $firstSpread, $finalSpread);
19741
  $newpagestarted = true;
19742
  $this->y = $y + $y0;
19743
 
19744
+ // Move down to account for border-spacing or
19745
  // extra half border width in case page breaks in middle
19746
  if($i>0 && !$this->table_rotate && $level==1 && !$this->ColActive) {
19747
+ if ($table['borders_separate']) {
19748
+ $adv = $table['border_spacing_V']/2;
19749
  // If table footer
19750
+ if (($this->keepColumns || !$this->ColActive) && !empty($tablefooter) && $i > 0 ) {
19751
+ $adv += ($table['padding']['B'] + $table['border_details']['B']['w']);
19752
  }
19753
  }
19754
+ else {
19755
  $maxbwtop = 0;
19756
  $maxbwbottom = 0;
19757
  if (!$this->simpleTables){
19758
  if (!empty($tablefooter)) { $maxbwbottom = $table['max_cell_border_width']['B']; }
19759
+ else {
19760
+ $brow = $i-1;
19761
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19762
  if (isset($cells[$brow][$ctj]) && $cells[$brow][$ctj]) {
19763
  if ($this->cacheTables) {
19770
  else {
19771
  $bb = $cells[$brow][$ctj]['border_details']['B']['w'];
19772
  }
19773
+ $maxbwbottom = max($maxbwbottom , $bb);
19774
  }
19775
  }
19776
  }
19777
  if (!empty($tableheader)) { $maxbwtop = $table['max_cell_border_width']['T']; }
19778
+ else {
19779
+ $trow = $i-1;
19780
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19781
  if (isset($cells[$trow][$ctj]) && $cells[$trow][$ctj]) {
19782
  if ($this->cacheTables) {
19796
  }
19797
  else if ($this->simpleTables){
19798
  $maxbwtop = $table['simple']['border_details']['T']['w'];
19799
+ $maxbwbottom = $table['simple']['border_details']['B']['w'];
19800
  }
19801
  $adv = $maxbwbottom /2;
19802
  }
19813
  $bx = $x0;
19814
  $by = $y0;
19815
 
19816
+ if ($table['borders_separate']) {
19817
+ $bx -= ($table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H']/2);
19818
  if ($tablestartpageno != $this->page) { // IF already broken across a previous pagebreak
19819
+ $by += $table['max_cell_border_width']['T']/2;
19820
  if (empty($tableheader)) { $by -= ($table['border_spacing_V']/2); }
19821
  }
19822
+ else {
19823
+ $by -= ($table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2);
19824
  }
19825
  }
19826
 
19827
+ else if ($tablestartpageno != $this->page && !empty($tableheader)) { $by += $maxbwtop /2; }
19828
 
19829
  $by -= $tableheaderadj;
19830
  $bh = $this->y - $by + $tablefooteradj;
19831
  if (!$table['borders_separate']) { $bh -= $adv ; }
19832
+ if ($split) {
19833
  $bw = 0;
19834
  for($t=$startcol; $t<$numcols; $t++) {
19835
  if ($table['colPg'][$t] == $splitpg) { $bw += $table['wc'][$t]; }
19836
  if ($table['colPg'][$t] > $splitpg) { break; }
19837
  }
19838
+ if ($table['borders_separate']) {
19839
+ if ($firstSpread) {
19840
+ $bw += $table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H'];
19841
  }
19842
  else {
19843
+ $bx += ($table['padding']['L'] + $table['border_details']['L']['w']);
19844
+ $bw += $table['border_spacing_H'];
19845
  }
19846
+ if ($finalSpread) {
19847
+ $bw += $table['padding']['R'] + $table['border_details']['R']['w']/2 + $table['border_spacing_H'];
19848
  }
19849
  }
19850
  }
19857
  $prevDrawColor = $this->DrawColor;
19858
  $lw = $this->LineWidth;
19859
  $this->SetLineWidth($this->splitTableBorderWidth);
19860
+ $this->SetDColor($table['border_details']['B']['c']);
19861
  $this->SetLineJoin(0);
19862
  $this->SetLineCap(0);
19863
  $blx = $bx;
19864
  $blw = $bw;
19865
+ if (!$table['borders_separate']) {
19866
  $blx -= ($table['max_cell_border_width']['L']/2);
19867
  $blw += ($table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2);
19868
  }
19872
  $this->SetLineWidth($lw);
19873
  $this->SetLineJoin(2);
19874
  $this->SetLineCap(2);
19875
+ }
19876
 
19877
  if (!$this->ColActive && ($i > 0 || $j > 0)) {
19878
+ if (isset($table['bgcolor'][-1])) {
19879
  $color = $this->ConvertColor($table['bgcolor'][-1]);
19880
  if ($color) {
19881
  if (!$table['borders_separate']) { $bh -= $table['max_cell_border_width']['B']/2; }
19901
 
19902
  if ($split) {
19903
  if ($i == 0 && $j == 0) { $y0 = -1; }
19904
+ else if ($finalSpread) {
19905
  $splitpg = 0;
19906
  $startcol = 0;
19907
  $startrow = $i;
19930
  $prevDrawColor = $this->DrawColor;
19931
  $lw = $this->LineWidth;
19932
  $this->SetLineWidth($this->splitTableBorderWidth);
19933
+ $this->SetDColor($table['border_details']['T']['c']);
19934
  $this->SetLineJoin(0);
19935
  $this->SetLineCap(0);
19936
  $blx += $this->MarginCorrection;
19940
  $this->SetLineWidth($lw);
19941
  $this->SetLineJoin(2);
19942
  $this->SetLineCap(2);
19943
+ }
19944
 
19945
+ // Move down to account for half of top border-spacing or
19946
  // extra half border width in case page was broken in middle
19947
  if($i>0 && !$this->table_rotate && $level==1 && $table['headernrows']==0) {
19948
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2; }
19949
+ else {
19950
  $maxbwtop = 0;
19951
  for( $ctj = 0 ; $ctj < $numcols ; $ctj++ ) {
19952
  if (isset($cells[$i][$ctj]) && $cells[$i][$ctj]) {
19961
  else {
19962
  $bt = $cells[$i][$ctj]['border_details']['T']['w'];
19963
  }
19964
+ $maxbwtop = max($maxbwtop, $bt);
19965
  }
19966
  else if ($this->simpleTables){
19967
+ $maxbwtop = max($maxbwtop, $table['simple']['border_details']['T']['w']);
19968
  }
19969
  }
19970
  }
20004
  // Advance down page
20005
  if ($table['borders_separate']) { $adv = $table['border_spacing_V']/2 + $table['border_details']['T']['w'] + $table['padding']['T']; }
20006
  else { $adv = $table['max_cell_border_width']['T'] /2 ; }
20007
+ if ($adv) {
20008
  if ($this->table_rotate) {
20009
  $this->y += ($adv);
20010
  }
20011
  else {
20012
+ $this->DivLn($adv,$this->blklvl,true);
20013
  }
20014
  }
20015
  }
20022
  $skippage = true;
20023
  }
20024
 
20025
+ $this->x = $x;
20026
  $this->y = $y;
20027
 
20028
  if ($this->kwt_saved && $level==1) {
20029
  $this->printkwtbuffer();
20030
+ $x0 = $x = $this->x;
20031
  $y0 = $y = $this->y;
20032
  $this->kwt_moved = false;
20033
  $this->kwt_saved = false;
20037
  // Set the Page & Column where table actually starts
20038
  if ($i==0 && $j==0 && $level==1) {
20039
  if (($this->mirrorMargins) && (($this->page)%2==0)) { // EVEN
20040
+ $tablestartpage = 'EVEN';
20041
  }
20042
  else if (($this->mirrorMargins) && (($this->page)%2==1)) { // ODD
20043
+ $tablestartpage = 'ODD';
20044
  }
20045
  else { $tablestartpage = ''; }
20046
  $tablestartpageno = $this->page;
20053
 
20054
 
20055
  if ($table['empty_cells']!='hide' || !empty($cell['textbuffer']) || (isset($cell['nestedcontent']) && $cell['nestedcontent']) || !$table['borders_separate'] ) { $paintcell = true; }
20056
+ else { $paintcell = false; }
20057
 
20058
  //Set Borders
20059
+ $bord = 0;
20060
  $bord_det = array();
20061
 
20062
  if (!$this->simpleTables){
20081
 
20082
  //TABLE ROW OR CELL FILL BGCOLOR
20083
  $fill = 0;
20084
+ if (isset($cell['bgcolor']) && $cell['bgcolor'] && $cell['bgcolor']!='transparent') {
20085
  $fill = $cell['bgcolor'];
20086
  $leveladj = 6;
20087
  }
20092
  if ($fill && $paintcell) {
20093
  $color = $this->ConvertColor($fill);
20094
  if ($color) {
20095
+ if ($table['borders_separate']) {
20096
  if ($this->ColActive) {
20097
  $this->SetFColor($color);
20098
  $this->Rect($x+ ($table['border_spacing_H']/2), $y+ ($table['border_spacing_V']/2), $w- $table['border_spacing_H'], $h- $table['border_spacing_V'], 'F');
20101
  $this->tableBackgrounds[$level*9+$leveladj][] = array('gradient'=>false, 'x'=>($x + ($table['border_spacing_H']/2)), 'y'=>($y + ($table['border_spacing_V']/2)), 'w'=>($w - $table['border_spacing_H']), 'h'=>($h - $table['border_spacing_V']), 'col'=>$color);
20102
  }
20103
  }
20104
+ else {
20105
  if ($this->ColActive) {
20106
  $this->SetFColor($color);
20107
  $this->Rect($x, $y, $w, $h, 'F');
20125
  if (isset($table['topntail']) && $table['topntail']) {
20126
  $bord_det['T'] = $this->border_details($table['topntail']);
20127
  $bord_det['T']['w'] /= $this->shrin_k;
20128
+ $this->setBorder($bord, _BORDER_TOP);
20129
  }
20130
  if (isset($table['thead-underline']) && $table['thead-underline']) {
20131
  $bord_det['T'] = $this->border_details($table['thead-underline']);
20132
  $bord_det['T']['w'] /= $this->shrin_k;
20133
+ $this->setBorder($bord, _BORDER_TOP);
20134
  }
20135
  }
20136
 
20138
  //Get info of first row ==>> table header
20139
  //Use > 1 row if THEAD
20140
  if (isset($table['is_thead'][$i]) && $table['is_thead'][$i] && $level==1) {
20141
+ if ($j==0) $tableheaderrowheight += $table['hr'][$i];
20142
  $tableheader[$i][0]['trbackground-images'] = (isset($table['trbackground-images'][$i]) ? $table['trbackground-images'][$i] : null);
20143
  $tableheader[$i][0]['trgradients'] = (isset($table['trgradients'][$i]) ? $table['trgradients'][$i] : null);
20144
  $tableheader[$i][0]['trbgcolor'] = (isset($table['bgcolor'][$i]) ? $table['bgcolor'][$i] : null);
20169
  }
20170
 
20171
  // CELL BORDER
20172
+ if ($bord || $bord_det) {
20173
  if ($table['borders_separate'] && $paintcell) {
20174
  $this->_tableRect($x + ($table['border_spacing_H']/2)+($bord_det['L']['w'] /2), $y+ ($table['border_spacing_V']/2)+($bord_det['T']['w'] /2), $w-$table['border_spacing_H']-($bord_det['L']['w'] /2)-($bord_det['R']['w'] /2), $h- $table['border_spacing_V']-($bord_det['T']['w'] /2)-($bord_det['B']['w']/2), $bord, $bord_det, false, $table['borders_separate']);
20175
  }
20176
+ else if (!$table['borders_separate']) {
20177
  $this->_tableRect($x, $y, $w, $h, $bord, $bord_det, true, $table['borders_separate']); // true causes buffer
20178
  }
20179
 
20184
  if (!isset($cell['va']) || $cell['va']=='M') $this->y += ($h-$cell['mih'])/2;
20185
  elseif (isset($cell['va']) && $cell['va']=='B') $this->y += $h-$cell['mih'];
20186
 
20187
+ // NESTED CONTENT
20188
 
20189
  // TEXT (and nested tables)
20190
  $this->divalign=$align;
20225
  else if ($angle > 0 && $angle <45) { $angle = 45; }
20226
  else if ($angle < 0) { $angle = -90; }
20227
  $offset = ((sin(deg2rad($angle))) * 0.37 * $cellFontHeight);
20228
+ if (isset($cell['a']) && $cell['a']=='R') {
20229
+ $this->x += ($w) + ($offset) - ($cellFontHeight/3) - ($cell['padding']['R'] + ($table['border_spacing_H']/2));
20230
  }
20231
+ else if (!isset($cell['a']) || $cell['a']=='C') {
20232
+ $this->x += ($w/2) + ($offset);
20233
  }
20234
+ else {
20235
+ $this->x += ($offset) + ($cellFontHeight/3)+($cell['padding']['L'] +($table['border_spacing_H']/2));
20236
  }
20237
  $str = '';
20238
  foreach($cell['textbuffer'] AS $t) { $str .= $t[0].' '; }
20239
  $str = trim($str);
20240
+ if (!isset($cell['va']) || $cell['va']=='M') {
20241
  $this->y -= ($h-$cell['mih'])/2; //Undo what was added earlier VERTICAL ALIGN
20242
  if ($angle > 0) { $this->y += (($h-$cell['mih'])/2) + $cell['padding']['T'] + ($cell['mih']-($cell['padding']['T'] + $cell['padding']['B'])); }
20243
  else if ($angle < 0) { $this->y += (($h-$cell['mih'])/2)+ ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20244
  }
20245
+ elseif (isset($cell['va']) && $cell['va']=='B') {
20246
  $this->y -= $h-$cell['mih']; //Undo what was added earlier VERTICAL ALIGN
20247
  if ($angle > 0) { $this->y += $h-($cell['padding']['B'] + ($table['border_spacing_V']/2)); }
20248
  else if ($angle < 0) { $this->y += $h-$cell['mih'] + ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20249
  }
20250
+ elseif (isset($cell['va']) && $cell['va']=='T') {
20251
  if ($angle > 0) { $this->y += $cell['mih']-($cell['padding']['B'] + ($table['border_spacing_V']/2)); }
20252
  else if ($angle < 0) { $this->y += ($cell['padding']['T'] + ($table['border_spacing_V']/2)); }
20253
  }
20257
  $s_st = $this->FontStyle;
20258
  if (!empty($cell['textbuffer'][0][3])) { //Font Color
20259
  $cor = $cell['textbuffer'][0][3];
20260
+ $this->SetTColor($cor);
20261
  }
20262
  $s_str = $this->strike;
20263
  $this->strike = $cell['textbuffer'][0][8]; //Strikethrough
20272
  else {
20273
 
20274
  if (!$this->simpleTables){
20275
+ if ($bord_det) {
20276
+ $btlw = $bord_det['L']['w'];
20277
+ $btrw = $bord_det['R']['w'];
20278
+ $bttw = $bord_det['T']['w'];
20279
  }
20280
+ else {
20281
+ $btlw = 0;
20282
+ $btrw = 0;
20283
+ $bttw = 0;
20284
  }
20285
  if ($table['borders_separate']) {
20286
  $xadj = $btlw + $cell['padding']['L'] +($table['border_spacing_H']/2);
20317
 
20318
 
20319
  // TABLE BORDER - if separate
20320
+ if (($table['borders_separate'] || ($this->simpleTables && !$table['simple']['border'])) && $table['border']) {
20321
  $halfspaceL = $table['padding']['L'] + ($table['border_spacing_H']/2);
20322
  $halfspaceR = $table['padding']['R'] + ($table['border_spacing_H']/2);
20323
  $halfspaceT = $table['padding']['T'] + ($table['border_spacing_V']/2);
20332
  if ($i == 0) { // Top
20333
  $tby -= $halfspaceT + ($table['border_details']['T']['w']/2);
20334
  $tbh += $halfspaceT + ($table['border_details']['T']['w']/2);
20335
+ $this->setBorder($tab_bord , _BORDER_TOP);
20336
  $corner .= 'T';
20337
  }
20338
  if ($i == ($numrows-1) || (isset($cell['rowspan']) && ($i+$cell['rowspan']) == $numrows)) { // Bottom
20339
  $tbh += $halfspaceB + ($table['border_details']['B']['w']/2);
20340
+ $this->setBorder($tab_bord , _BORDER_BOTTOM);
20341
  $corner .= 'B';
20342
  }
20343
  if ($j == 0) { // Left
20344
  $tbx -= $halfspaceL + ($table['border_details']['L']['w']/2);
20345
  $tbw += $halfspaceL + ($table['border_details']['L']['w']/2);
20346
+ $this->setBorder($tab_bord , _BORDER_LEFT);
20347
  $corner .= 'L';
20348
  }
20349
  if ($j == ($numcols-1) || (isset($cell['colspan']) && ($j+$cell['colspan']) == $numcols)) { // Right
20350
  $tbw += $halfspaceR + ($table['border_details']['R']['w']/2);
20351
+ $this->setBorder($tab_bord , _BORDER_RIGHT);
20352
  $corner .= 'R';
20353
  }
20354
  $this->_tableRect($tbx, $tby, $tbw, $tbh, $tab_bord , $table['border_details'], false, $table['borders_separate'], 'table', $corner, $table['border_spacing_V'], $table['border_spacing_H'] );
20391
 
20392
  $bx = $x0;
20393
  $by = $y0;
20394
+ if ($table['borders_separate']) {
20395
+ $bx -= ($table['padding']['L'] + $table['border_details']['L']['w'] + $table['border_spacing_H']/2);
20396
  if ($tablestartpageno != $this->page) { // IF broken across page
20397
  $by += $table['max_cell_border_width']['T']/2;
20398
  if (empty($tableheader)) { $by -= ($table['border_spacing_V']/2); }
20399
  }
20400
+ else if ($split && $startrow > 0 && empty($tableheader)) {
20401
+ $by -= ($table['border_spacing_V']/2);
20402
  }
20403
  else {
20404
+ $by -= ($table['padding']['T'] + $table['border_details']['T']['w'] + $table['border_spacing_V']/2);
20405
  }
20406
  }
20407
+ else if ($tablestartpageno != $this->page && !empty($tableheader)) { $by += $maxbwtop /2; }
20408
  $by -= $tableheaderadj;
20409
  $bh = $this->y - $by;
20410
  if (!$table['borders_separate']) { $bh -= $table['max_cell_border_width']['B']/2; }
20419
  if ($startcol==0) { $firstSpread = true; }
20420
  else { $firstSpread = false; }
20421
  if ($table['borders_separate']) {
20422
+ $bw += $table['border_spacing_H'];
20423
+ if ($firstSpread) {
20424
+ $bw += $table['padding']['L'] + $table['border_details']['L']['w'];
20425
  }
20426
  else {
20427
+ $bx += ($table['padding']['L'] + $table['border_details']['L']['w']);
20428
  }
20429
+ if ($finalSpread) {
20430
+ $bw += $table['padding']['R'] + $table['border_details']['R']['w'];
20431
  }
20432
  }
20433
  }
20436
  }
20437
 
20438
  if (!$this->ColActive) {
20439
+ if (isset($table['bgcolor'][-1])) {
20440
  $color = $this->ConvertColor($table['bgcolor'][-1]);
20441
  if ($color) {
20442
  $this->tableBackgrounds[$level*9][] = array('gradient'=>false, 'x'=>$bx, 'y'=>$by, 'w'=>$bw, 'h'=>$bh, 'col'=>$color);
20476
 
20477
  if ($this->cacheTables) { fclose($fh); }
20478
 
20479
+ if ($split) {
20480
  // Are there more columns to print on a next page?
20481
  if ($lastCol < $numcols-1) {
20482
  $splitpg++;
20484
  return array(false, $startrow, $startcol, $splitpg, $returny, $y0);
20485
  }
20486
  else {
20487
+ if ($this->cacheTables) {
20488
+ unlink($table['cache']);
20489
+ @unlink($table['cache'].'.bak');
20490
  }
20491
  return array(true,0,0,0);
20492
  }
20493
  }
20494
+ if ($this->cacheTables) {
20495
+ unlink($table['cache']);
20496
+ @unlink($table['cache'].'.bak');
20497
  }
20498
 
20499
  }//END OF FUNCTION _tableWrite()
20549
  function _putpatterns() {
20550
  for ($i = 1; $i <= count($this->patterns); $i++) {
20551
  $x = $this->patterns[$i]['x'];
20552
+ $y = $this->patterns[$i]['y'];
20553
  $w = $this->patterns[$i]['w'];
20554
+ $h = $this->patterns[$i]['h'];
20555
+ $pgh = $this->patterns[$i]['pgh'];
20556
  $orig_w = $this->patterns[$i]['orig_w'];
20557
+ $orig_h = $this->patterns[$i]['orig_h'];
20558
  $image_id = $this->patterns[$i]['image_id'];
20559
  $itype = $this->patterns[$i]['itype'];
20560
 
20561
+ if ($this->patterns[$i]['x_repeat']) { $x_repeat = true; }
20562
  else { $x_repeat = false; }
20563
  if ($this->patterns[$i]['y_repeat']) { $y_repeat = true; }
20564
  else { $y_repeat = false; }
20565
  $x_pos = $this->patterns[$i]['x_pos'];
20566
+ if (stristr($x_pos ,'%') ) {
20567
+ $x_pos += 0;
20568
+ $x_pos /= 100;
20569
  $x_pos = ($w * $x_pos) - ($orig_w/_MPDFK * $x_pos);
20570
  }
20571
  $y_pos = $this->patterns[$i]['y_pos'];
20572
+ if (stristr($y_pos ,'%') ) {
20573
+ $y_pos += 0;
20574
+ $y_pos /= 100;
20575
  $y_pos = ($h * $y_pos) - ($orig_h/_MPDFK * $y_pos);
20576
  }
20577
  $adj_x = ($x_pos + $x) *_MPDFK;
20579
  $img_obj = false;
20580
  if ($itype == 'svg' || $itype == 'wmf') {
20581
  foreach($this->formobjects AS $fo) {
20582
+ if ($fo['i'] == $image_id) {
20583
+ $img_obj = $fo['n'];
20584
  $fo_w = $fo['w'];
20585
  $fo_h = -$fo['h'];
20586
  $wmf_x = $fo['x'];
20587
+ $wmf_y = $fo['y'];
20588
+ break;
20589
  }
20590
  }
20591
  }
20622
  $this->_out('/F'.$font['subsetfontids'][$k].' '.$font['n'][$k].' 0 R');
20623
  }
20624
  }
20625
+ else {
20626
  $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
20627
  }
20628
  }
20705
  $this->_out('/F'.$font['subsetfontids'][$k].' '.$font['n'][$k].' 0 R');
20706
  }
20707
  }
20708
+ else {
20709
  $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
20710
  }
20711
  }
20738
 
20739
 
20740
  // mPDF 5.6.01
20741
+ if ($this->hasOC || count($this->layers)) {
20742
  $this->_out('/Properties <<');
20743
+ if ($this->hasOC) {
20744
  $this->_out('/OC1 '.$this->n_ocg_print.' 0 R /OC2 '.$this->n_ocg_view.' 0 R /OC3 '.$this->n_ocg_hidden.' 0 R ');
20745
  }
20746
  if (count($this->layers)) {
20817
  foreach($this->PageNumSubstitutions AS $k=>$v) {
20818
  if ($this->PageNumSubstitutions[$k]['from']==$target_page) {
20819
  $tp_present = true;
20820
+ if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20821
  $this->PageNumSubstitutions[$k]['suppress']='off';
20822
  }
20823
  }
20824
  if ($this->PageNumSubstitutions[$k]['from']==$start_page) {
20825
  $sp_present = true;
20826
+ if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20827
  $this->PageNumSubstitutions[$k]['suppress']='off';
20828
  }
20829
  }
20830
  if ($this->PageNumSubstitutions[$k]['from']==($end_page+1)) {
20831
  $ep_present = true;
20832
+ if ($this->PageNumSubstitutions[$k]['suppress']!='on' && $this->PageNumSubstitutions[$k]['suppress']!=1) {
20833
  $this->PageNumSubstitutions[$k]['suppress']='off';
20834
  }
20835
  }
20836
  }
20837
 
20838
+ if (!$tp_present) {
20839
  list($tp_type, $tp_suppress, $tp_reset) = $this->docPageSettings($target_page);
20840
  }
20841
+ if (!$sp_present) {
20842
  list($sp_type, $sp_suppress, $sp_reset) = $this->docPageSettings($start_page);
20843
  }
20844
+ if (!$ep_present) {
20845
  list($ep_type, $ep_suppress, $ep_reset) = $this->docPageSettings($start_page-1);
20846
  }
20847
 
20976
  if (count($this->PageNumSubstitutions)) {
20977
  $newarr = array();
20978
  foreach($this->PageNumSubstitutions AS $k=>$v) {
20979
+ if($this->PageNumSubstitutions[$k]['from']>=$start_page && $this->PageNumSubstitutions[$k]['from']<=$end_page) {
20980
+ $this->PageNumSubstitutions[$k]['from'] += ($target_page - $start_page);
20981
+ $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20982
  }
20983
  else if($this->PageNumSubstitutions[$k]['from']>=$target_page && $this->PageNumSubstitutions[$k]['from']<$start_page) {
20984
  $this->PageNumSubstitutions[$k]['from'] += $n_toc;
20985
+ $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20986
  }
20987
  else {
20988
+ $newarr[$this->PageNumSubstitutions[$k]['from']] = $this->PageNumSubstitutions[$k];
20989
  }
20990
  }
20991
 
20992
  if (!$sp_present) {
20993
+ $newarr[$target_page] = array('from'=>$target_page, 'suppress'=>$sp_suppress, 'reset'=>$sp_reset, 'type'=>$sp_type);
20994
  }
20995
  if (!$tp_present) {
20996
+ $newarr[($target_page + $n_toc)] = array('from'=>($target_page+$n_toc), 'suppress'=>$tp_suppress, 'reset'=>$tp_reset, 'type'=>$tp_type);
20997
  }
20998
  if (!$ep_present && $end_page>count($this->pages)) {
20999
+ $newarr[($end_page+1)] = array('from'=>($end_page+1), 'suppress'=>$ep_suppress, 'reset'=>$ep_reset, 'type'=>$ep_type);
21000
  }
21001
  ksort($newarr);
21002
  $this->PageNumSubstitutions = array();
21164
  //==================================================================
21165
  function printtablebuffer() {
21166
 
21167
+ if (!$this->table_rotate) {
21168
  $this->pages[$this->page] .= $this->tablebuffer;
21169
  foreach($this->tbrot_Links AS $p => $l) {
21170
  foreach($l AS $v) {
21176
 
21177
 
21178
 
21179
+ return;
21180
  }
21181
  // else if rotated
21182
  $lm = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_left'];
21214
  $this->pages[$this->page] .= $this->transformRotate($this->table_rotate, $this->tbrot_x0 , $this->tbrot_y0 , true)."\n";
21215
 
21216
  // Now output the adjusted values
21217
+ $this->pages[$this->page] .= $this->tablebuffer;
21218
 
21219
 
21220
  foreach($this->tbrot_Links AS $p => $l) {
21271
  //==================================================================
21272
  // Keep-with-table This buffers contents of h1-6 to keep on page with table
21273
  function printkwtbuffer() {
21274
+ if (!$this->kwt_moved) {
21275
  foreach($this->kwt_buffer AS $s) { $this->pages[$this->page] .= $s['s']."\n"; }
21276
  foreach($this->kwt_Links AS $p => $l) {
21277
  foreach($l AS $v) {
21283
 
21284
 
21285
 
21286
+ return;
21287
  }
21288
 
21289
  //Start Transformation
21357
  $top[$p1] = $this->kt_y00;
21358
 
21359
  $top2 = $this->h;
21360
+ foreach($this->divbuffer AS $key=>$s) {
21361
  if ($s['page'] == $p2) {
21362
  $top2 = MIN($s['y'], $top2);
21363
  }
21371
  $yadj[$p2] = $height[$p1];
21372
 
21373
  // Output without any transformation
21374
+ if ($this->ColActive || !$this->keep_block_together || $this->blk[$this->blklvl]['startpage'] == $this->page || ($this->page - $this->blk[$this->blklvl]['startpage']) > 1 || ($height[$p1]+$height[$p2]) > $this->h) {
21375
  foreach($this->divbuffer AS $s) { $this->pages[$s['page']] .= $s['s']."\n"; }
21376
  foreach($this->ktLinks AS $p => $l) {
21377
  foreach($l AS $v) {
21393
  $this->ktBMoutlines = array();
21394
  $this->_kttoc = array();
21395
  $this->keep_block_together = 0;
21396
+ return;
21397
  }
21398
  else {
21399
  $np = '';
21400
  $pre = '';
21401
  $ispre = true;
21402
+ foreach($this->divbuffer AS $key=>$s) {
21403
  // callback function
21404
  $t = $s['s'];
21405
  $p = $s['page'];
21406
  if (preg_match('/(___PAGE___START'.date('jY').')/', $t)) { $ispre = false; }
21407
+ else if (preg_match('/(___HEADER___MARKER'.date('jY').')/', $t)) {
21408
  $np .= $t."\n".$pre;
21409
+ continue;
21410
  }
21411
  else {
21412
  $t = preg_replace('/BT (\d+\.\d\d+) (\d+\.\d\d+) Td/e',"\$this->blockAdjust('Td',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21413
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) ([\-]{0,1}\d+\.\d\d+) re/e',"\$this->blockAdjust('re',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4')",$t);
21414
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) l/e',"\$this->blockAdjust('l',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21415
+ $t = preg_replace('/q (\d+\.\d\d+) 0 0 (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) cm \/(I|FO)/e',"\$this->blockAdjust('img',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4','\\5')",$t);
21416
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) m/e',"\$this->blockAdjust('draw',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2')",$t);
21417
  $t = preg_replace('/(\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) (\d+\.\d\d+) c/e',"\$this->blockAdjust('bezier',_MPDFK,$xadj[$p],$yadj[$p],'\\1','\\2','\\3','\\4','\\5','\\6')",$t);
21418
  }
21479
  $ly=4/3*(M_SQRT2-1)*$ry;
21480
  $h=$this->h;
21481
  $this->_out(sprintf('%.3F %.3F m %.3F %.3F %.3F %.3F %.3F %.3F c', ($x+$rx)*_MPDFK,($h-$y)*_MPDFK, ($x+$rx)*_MPDFK,($h-($y-$ly))*_MPDFK, ($x+$lx)*_MPDFK,($h-($y-$ry))*_MPDFK, $x*_MPDFK,($h-($y-$ry))*_MPDFK));
21482
+ $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c', ($x-$lx)*_MPDFK,($h-($y-$ry))*_MPDFK, ($x-$rx)*_MPDFK,($h-($y-$ly))*_MPDFK, ($x-$rx)*_MPDFK,($h-$y)*_MPDFK));
21483
+ $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c', ($x-$rx)*_MPDFK,($h-($y+$ly))*_MPDFK, ($x-$lx)*_MPDFK,($h-($y+$ry))*_MPDFK, $x*_MPDFK,($h-($y+$ry))*_MPDFK));
21484
  $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F c %s', ($x+$lx)*_MPDFK,($h-($y+$ry))*_MPDFK, ($x+$rx)*_MPDFK,($h-($y+$ly))*_MPDFK, ($x+$rx)*_MPDFK,($h-$y)*_MPDFK, $op));
21485
  }
21486
 
21492
  // ====================================================
21493
  // ====================================================
21494
 
21495
+ //
21496
  // ****************************
21497
  // ****************************
21498
 
21524
 
21525
 
21526
  function SubstituteCharsSIP(&$writehtml_a, &$writehtml_i, &$writehtml_e) {
21527
+ if (preg_match("/^(.*?)([\x{20000}-\x{2FFFF}]+)(.*)/u", $writehtml_e, $m)) {
21528
  if (isset($this->CurrentFont['sipext']) && $this->CurrentFont['sipext']) {
21529
+ $font = $this->CurrentFont['sipext'];
21530
  if (!in_array($font, $this->available_unifonts)) { return 0; }
21531
  $writehtml_a[$writehtml_i] = $writehtml_e = $m[1];
21532
  array_splice($writehtml_a, $writehtml_i+1, 0, array('span style="font-family: '.$font.'"', $m[2], '/span', $m[3]));
21534
  return 4;
21535
  }
21536
  }
21537
+ return 0;
21538
  }
21539
 
21540
  // If core font is selected in document which is not onlyCoreFonts - substitute with non-core font
21549
  $flag = 0;
21550
  $ftype = '';
21551
  $u = array();
21552
+ if (!$this->subArrMB) {
21553
+ include(_MPDF_PATH.'includes/subs_core.php');
21554
  $this->subArrMB['a'] = $aarr;
21555
  $this->subArrMB['s'] = $sarr;
21556
  $this->subArrMB['z'] = $zarr;
21557
  }
21558
  foreach($unicode AS $c => $char) {
21559
+ if (($char> 127 || ($flag==1 && $char==32)) && $char != 173 && (!isset($this->subArrMB['a'][$char]) || ($flag==1 && $char==32)) && ($char<1536 || ($char>1791 && $char < 2304) || $char>3455)) {
21560
  if ($flag==0) { $start=$c; }
21561
+ $flag=1;
21562
  $u[] = $char;
21563
  }
21564
  else if ($flag>0) { $end=$c-1; break; }
21569
  if (!is_array($this->backupSubsFont)) { $this->backupSubsFont = array("$this->backupSubsFont"); }
21570
  foreach($this->backupSubsFont AS $bsfctr=>$bsf) {
21571
  if ($this->fonttrans[$bsf] == 'chelvetica' || $this->fonttrans[$bsf] == 'ctimes' || $this->fonttrans[$bsf] == 'ccourier') { continue; }
21572
+ $font = $bsf;
21573
  unset($cw);
21574
  $cw = '';
21575
  if (isset($this->fonts[$font])) { $cw = &$this->fonts[$font]['cw']; }
21611
  }
21612
  }
21613
 
21614
+ unset($cw);
21615
  return 0;
21616
  }
21617
 
21628
  if (($flag == 0 || $flag==2) && (!$this->_charDefined($cw,$char) || ($flag==2 && $char==32)) && $this->checkSIP && $char > 131071) { // Unicode Plane 2 (SIP)
21629
  if (in_array($this->FontFamily ,$this->available_CJK_fonts)) { return 0; }
21630
  if ($flag==0) { $start=$c; }
21631
+ $flag=2;
21632
  $u[] = $char;
21633
  }
21634
+ //else if (($flag == 0 || $flag==1) && $char != 173 && !$this->_charDefined($cw,$char) && ($char<1423 || ($char>3583 && $char < 11263))) {
21635
+ else if (($flag == 0 || $flag==1) && $char != 173 && (!$this->_charDefined($cw,$char) || ($flag==1 && $char==32)) && ($char<1536 || ($char>1791 && $char < 2304) || $char>3455)) {
21636
  if ($flag==0) { $start=$c; }
21637
+ $flag=1;
21638
  $u[] = $char;
21639
  }
21640
  else if ($flag>0) { $end=$c-1; break; }
21644
  if ($flag == 2) { // SIP
21645
  // Check if current CJK font has a ext-B related font
21646
  if (isset($this->CurrentFont['sipext']) && $this->CurrentFont['sipext']) {
21647
+ $font = $this->CurrentFont['sipext'];
21648
  unset($cw);
21649
  $cw = '';
21650
  if (isset($this->fonts[$font])) { $cw = &$this->fonts[$font]['cw']; }
21709
  }
21710
  }
21711
  }
21712
+ return 0;
21713
  }
21714
 
21715
 
21716
  // FIRST TRY CORE FONTS
21717
+ if (!$this->PDFA && !$this->PDFX) {
21718
  $repl = array();
21719
+ if (!$this->subArrMB) {
21720
+ include(_MPDF_PATH.'includes/subs_core.php');
21721
  $this->subArrMB['a'] = $aarr;
21722
  $this->subArrMB['s'] = $sarr;
21723
  $this->subArrMB['z'] = $zarr;
21724
  }
21725
+ if (isset($this->subArrMB['a'][$u[0]])) {
21726
+ $font = 'tta'; $ftype = 'C';
21727
  foreach($u AS $char) {
21728
  if ($this->subArrMB['a'][$char]) { $repl[] = $this->subArrMB['a'][$char]; }
21729
  else { break; }
21730
  }
21731
  }
21732
+ else if (isset($this->subArrMB['z'][$u[0]])) {
21733
+ $font = 'ttz'; $ftype = 'C';
21734
  foreach($u AS $char) {
21735
  if ($this->subArrMB['z'][$char]) { $repl[] = $this->subArrMB['z'][$char]; }
21736
  else { break; }
21737
  }
21738
  }
21739
+ else if (isset($this->subArrMB['s'][$u[0]])) {
21740
+ $font = 'tts'; $ftype = 'C';
21741
  foreach($u AS $char) {
21742
  if ($this->subArrMB['s'][$char]) { $repl[] = $this->subArrMB['s'][$char]; }
21743
  else { break; }
21777
  if (!$cw) { continue; }
21778
  $l = 0;
21779
  foreach($u AS $char) {
21780
+ if ($char == 173 || $this->_charDefined($cw,$char) || ($char>1536 && $char<1791) || ($char>2304 && $char<3455 )) { // Arabic and Indic
21781
  $l++;
21782
  }
21783
  else {
21802
  }
21803
  }
21804
 
21805
+ unset($cw);
21806
  return 0;
21807
  }
21808
 
21865
  function is_utf8(&$string) {
21866
  if ($string === mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32")) {
21867
  return true;
21868
+ }
21869
  else {
21870
  if ($this->ignore_invalid_utf8) {
21871
  $string = mb_convert_encoding(mb_convert_encoding($string, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") ;
21875
  return false;
21876
  }
21877
  }
21878
+ }
21879
 
21880
 
21881
  function purify_utf8($html,$lo=true) {
21884
  // converts html_entities > ASCII 127 to UTF-8
21885
  // Only exception - leaves low ASCII entities e.g. &lt; &amp; etc.
21886
  // Leaves in particular &lt; to distinguish from tag marker
21887
+ if (!$this->is_utf8($html)) {
21888
+ echo "<p><b>HTML contains invalid UTF-8 character(s)</b></p>";
21889
  while (mb_convert_encoding(mb_convert_encoding($html, "UTF-32", "UTF-8"), "UTF-8", "UTF-32") != $html) {
21890
  $a = iconv('UTF-8', 'UTF-8', $html);
21891
  echo ($a);
21899
  $html = substr($html, $pos);
21900
  }
21901
  echo $html;
21902
+ $this->Error("");
21903
  }
21904
  $html = preg_replace("/\r/", "", $html );
21905
 
21906
+ // converts html_entities > ASCII 127 to UTF-8
21907
  // Leaves in particular &lt; to distinguish from tag marker
21908
  $html = $this->SubstituteHiEntities($html);
21909
 
21916
  function purify_utf8_text($txt) {
21917
  // For TEXT
21918
  // Make sure UTF-8 string of characters
21919
+ if(!mb_strlen($txt))
21920
  {
21921
  $txt = ' ';
21922
+ }
21923
 
21924
  if (!$this->is_utf8($txt)) { $this->Error("Text contains invalid UTF-8 character(s)"); }
21925
 
21928
  return ($txt);
21929
  }
21930
  function all_entities_to_utf8($txt) {
21931
+ // converts txt_entities > ASCII 127 to UTF-8
21932
  // Leaves in particular &lt; to distinguish from tag marker
21933
  $txt = $this->SubstituteHiEntities($txt);
21934
 
22061
  $a[$i] = $e;
22062
  }
22063
  else {
22064
+ $a[$i] = '<'.$e.'>';
22065
  }
22066
  }
22067
  $n = implode('',$a);
22095
  if ($type == 'Td') { // xpos,ypos
22096
  $a += ($xadj * $k);
22097
  $b -= ($yadj * $k);
22098
+ return 'BT '.sprintf('%.3F %.3F',$a,$b).' Td';
22099
  }
22100
  else if ($type == 're') { // xpos,ypos,width,height
22101
  $a += ($xadj * $k);
22102
  $b -= ($yadj * $k);
22103
+ return sprintf('%.3F %.3F %.3F %.3F',$a,$b,$c,$d).' re';
22104
  }
22105
  else if ($type == 'l') { // xpos,ypos,x2pos,y2pos
22106
  $a += ($xadj * $k);
22107
  $b -= ($yadj * $k);
22108
+ return sprintf('%.3F %.3F l',$a,$b);
22109
  }
22110
  else if ($type == 'img') { // width,height,xpos,ypos
22111
  $c += ($xadj * $k);
22112
  $d -= ($yadj * $k);
22113
+ return sprintf('q %.3F 0 0 %.3F %.3F %.3F',$a,$b,$c,$d).' cm /'.$e;
22114
  }
22115
  else if ($type == 'draw') { // xpos,ypos
22116
  $a += ($xadj * $k);
22117
  $b -= ($yadj * $k);
22118
+ return sprintf('%.3F %.3F m',$a,$b);
22119
  }
22120
  else if ($type == 'bezier') { // xpos,ypos,x2pos,y2pos,x3pos,y3pos
22121
  $a += ($xadj * $k);
22124
  $d -= ($yadj * $k);
22125
  $e += ($xadj * $k);
22126
  $f -= ($yadj * $k);
22127
+ return sprintf('%.3F %.3F %.3F %.3F %.3F %.3F',$a,$b,$c,$d,$e,$f).' c';
22128
  }
22129
  }
22130
 
22142
  $cor = preg_replace('/\s+.*/','',$color); // in case of Background: #CCC url() x-repeat etc.
22143
  if (strlen($cor) == 4) { // Turn #RGB into #RRGGBB
22144
  $cor = "#" . $cor[1] . $cor[1] . $cor[2] . $cor[2] . $cor[3] . $cor[3];
22145
+ }
22146
  $r = hexdec(substr($cor, 1, 2));
22147
  $g = hexdec(substr($cor, 3, 2));
22148
  $b = hexdec(substr($cor, 5, 2));
22152
  $type= $m[1];
22153
  $cores = explode(",", $m[2]);
22154
  $ncores = count($cores);
22155
+ if (stristr($cores[0],'%') ) {
22156
+ $cores[0] += 0;
22157
  if ($type=='rgb' || $type=='rgba') { $cores[0] = intval($cores[0]*255/100); }
22158
  }
22159
+ if ($ncores>1 && stristr($cores[1],'%') ) {
22160
+ $cores[1] += 0;
22161
  if ($type=='rgb' || $type=='rgba') { $cores[1] = intval($cores[1]*255/100); }
22162
  if ($type=='hsl' || $type=='hsla') { $cores[1] = $cores[1]/100; }
22163
  }
22164
+ if ($ncores>2 && stristr($cores[2],'%') ) {
22165
+ $cores[2] += 0;
22166
  if ($type=='rgb' || $type=='rgba') { $cores[2] = intval($cores[2]*255/100); }
22167
  if ($type=='hsl' || $type=='hsla') { $cores[2] = $cores[2]/100; }
22168
  }
22169
+ if ($ncores>3 && stristr($cores[3],'%') ) {
22170
+ $cores[3] += 0;
22171
  }
22172
 
22173
  if ($type=='rgb') { $c = array(3,$cores[0],$cores[1],$cores[2]); }
22174
  else if ($type=='rgba') { $c = array(5,$cores[0],$cores[1],$cores[2],$cores[3]*100); }
22175
  else if ($type=='cmyk') { $c = array(4,$cores[0],$cores[1],$cores[2],$cores[3]); }
22176
  else if ($type=='cmyka') { $c = array(6,$cores[0],$cores[1],$cores[2],$cores[3],$cores[4]*100); }
22177
+ else if ($type=='hsl' || $type=='hsla') {
22178
  $conv = $this->hsl2rgb($cores[0]/360,$cores[1],$cores[2]);
22179
  if ($type=='hsl') { $c = array(3,$conv[0],$conv[1],$conv[2]); }
22180
  else if ($type=='hsla') { $c = array(5,$conv[0],$conv[1],$conv[2],$cores[3]*100); }
22181
  }
22182
+ else if ($type=='spot') {
22183
  $name = strtoupper(trim($cores[0]));
22184
  if(!isset($this->spotColors[$name])) $this->Error('Undefined spot color: '.$name);
22185
+ $c = array(2,$this->spotColors[$name]['i'],$cores[1]);
22186
  }
22187
  }
22188
 
22196
  }
22197
  else if ($c[0]==2) { // SPOT COLOR
22198
  if (!isset($this->spotColorIDs[$c[1]])) { die('Error: Spot colour has not been defined - '.$this->spotColorIDs[$c[1]]); }
22199
+ if ($this->PDFA) {
22200
  if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "Spot color specified '".$this->spotColorIDs[$c[1]]."' (converted to process color)"; }
22201
+ if ($this->restrictColorSpace!=3) {
22202
+ $sp = $this->spotColors[$this->spotColorIDs[$c[1]]];
22203
+ $c = $this->cmyk2rgb(array(4,$sp['c'],$sp['m'],$sp['y'],$sp['k']));
22204
  }
22205
  }
22206
+ else if ($this->restrictColorSpace==1) {
22207
+ $sp = $this->spotColors[$this->spotColorIDs[$c[1]]];
22208
+ $c = $this->cmyk2gray(array(4,$sp['c'],$sp['m'],$sp['y'],$sp['k']));
22209
  }
22210
  }
22211
  else if ($c[0]==3) { // RGB
22212
+ if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22213
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "RGB color specified '".$color."' (converted to CMYK)"; }
22214
+ $c = $this->rgb2cmyk($c);
22215
  }
22216
  else if ($this->restrictColorSpace==1) { $c = $this->rgb2gray($c); }
22217
  else if ($this->restrictColorSpace==3) { $c = $this->rgb2cmyk($c); }
22218
  }
22219
  else if ($c[0]==4) { // CMYK
22220
+ if ($this->PDFA && $this->restrictColorSpace!=3) {
22221
  if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "CMYK color specified '".$color."' (converted to RGB)"; }
22222
+ $c = $this->cmyk2rgb($c);
22223
  }
22224
  else if ($this->restrictColorSpace==1) { $c = $this->cmyk2gray($c); }
22225
  else if ($this->restrictColorSpace==2) { $c = $this->cmyk2rgb($c); }
22226
  }
22227
  else if ($c[0]==5) { // RGBa
22228
+ if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22229
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "RGB color with transparency specified '".$color."' (converted to CMYK without transparency)"; }
22230
+ $c = $this->rgb2cmyk($c);
22231
  $c = array(4, $c[1], $c[2], $c[3], $c[4]);
22232
  }
22233
+ else if ($this->PDFA && $this->restrictColorSpace!=3) {
22234
  if (!$this->PDFAauto) { $this->PDFAXwarnings[] = "RGB color with transparency specified '".$color."' (converted to RGB without transparency)"; }
22235
+ $c = $this->rgb2cmyk($c);
22236
  $c = array(4, $c[1], $c[2], $c[3], $c[4]);
22237
  }
22238
  else if ($this->restrictColorSpace==1) { $c = $this->rgb2gray($c); }
22239
  else if ($this->restrictColorSpace==3) { $c = $this->rgb2cmyk($c); }
22240
  }
22241
  else if ($c[0]==6) { // CMYKa
22242
+ if ($this->PDFA && $this->restrictColorSpace!=3) {
22243
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "CMYK color with transparency specified '".$color."' (converted to RGB without transparency)"; }
22244
+ $c = $this->cmyk2rgb($c);
22245
  $c = array(3, $c[1], $c[2], $c[3]);
22246
  }
22247
+ else if ($this->PDFX || ($this->PDFA && $this->restrictColorSpace==3)) {
22248
  if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "CMYK color with transparency specified '".$color."' (converted to CMYK without transparency)"; }
22249
+ $c = $this->cmyk2rgb($c);
22250
  $c = array(3, $c[1], $c[2], $c[3]);
22251
  }
22252
  else if ($this->restrictColorSpace==1) { $c = $this->cmyk2gray($c); }
22255
  }
22256
  if (is_array($c)) {
22257
  $c = array_pad($c, 6, 0);
22258
+ $cstr = pack("a1ccccc", $c[0], ($c[1] & 0xFF), ($c[2] & 0xFF), ($c[3] & 0xFF), ($c[4] & 0xFF), ($c[5] & 0xFF) );
22259
  }
22260
  return $cstr;
22261
  }
22364
  }
22365
  else if ($cor[0]==1) { // Grayscale
22366
  return array(1, (255-$cor[1]));
22367
+ }
22368
  // Cannot cope with non-RGB colors at present
22369
  die('Error in _invertColor - trying to invert non-RGB color');
22370
  }
22394
  elseif ( stristr($size,'mm') ) $size += 0; //millimeters
22395
  elseif ( stristr($size,'pt') ) $size *= 25.4/72; //72 pts/inch
22396
  elseif ( stristr($size,'em') ) {
22397
+ $size += 0; //make "0.83em" become simply "0.83"
22398
  if ($fontsize) { $size *= $fontsize; }
22399
  else { $size *= $maxsize; }
22400
  }
22401
  elseif ( stristr($size,'%') ) {
22402
+ $size += 0; //make "90%" become simply "90"
22403
  if ($fontsize && $usefontsize) { $size *= $fontsize/100; }
22404
  else { $size *= $maxsize/100; }
22405
  }
22406
+ elseif ( stristr($size,'in') ) $size *= 25.4; //inches
22407
+ elseif ( stristr($size,'pc') ) $size *= 38.1/9; //PostScript picas
22408
  elseif ( stristr($size,'ex') ) { // Approximates "ex" as half of font height
22409
+ $size += 0; //make "3.5ex" become simply "3.5"
22410
  if ($fontsize) { $size *= $fontsize/2; }
22411
  else { $size *= $maxsize/2; }
22412
  }
22469
 
22470
 
22471
  preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
22472
+ if (count($svgi[0])) {
22473
  for($i=0;$i<count($svgi[0]);$i++) {
22474
  $file = _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.$i.'.svg';
22475
  //Save to local file
22568
  $html = str_replace("</erp>","</pre>",$html);
22569
  $html = str_replace("<aeratxet","<textarea",$html);
22570
  $html = str_replace("</aeratxet>","</textarea>",$html);
22571
+ $html = str_replace("</innerpre","</pre",$html);
22572
+ $html = str_replace("<innerpre","<pre",$html);
22573
 
22574
  $html = preg_replace('/<textarea([^>]*)><\/textarea>/si','<textarea\\1> </textarea>',$html);
22575
  $html = preg_replace('/(<table[^>]*>)\s*(<caption)(.*?<\/caption>)(.*?<\/table>)/si','\\2 position="top"\\3\\1\\4\\2 position="bottom"\\3',$html); // *TABLES*
22581
  function dec2other($num, $cp) {
22582
  $nstr = (string) $num;
22583
  $rnum = '';
22584
+ for ($i=0;$i<strlen($nstr);$i++) {
22585
  if ($this->_charDefined($this->CurrentFont['cw'],$cp+intval($nstr[$i]))) { // contains arabic-indic numbers
22586
  $rnum .= code2utf($cp+intval($nstr[$i]));
22587
  }
22713
 
22714
  }//end of Class
22715
 
 
 
 
 
mPDF/mpdf-lite.php CHANGED
@@ -826,7 +826,7 @@ var $innerblocktags;
826
  // **********************************
827
  // **********************************
828
 
829
- function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
830
 
831
  if (!class_exists('grad', false)) { include(_MPDF_PATH.'classes/grad.php'); }
832
  if (empty($this->grad)) { $this->grad = new grad($this); }
@@ -1407,7 +1407,6 @@ function _getPageFormat($format) {
1407
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1408
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1409
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
1410
- default: $format = false;
1411
  }
1412
  return $format;
1413
  }
@@ -27277,6 +27276,3 @@ function SetJS($script) {
27277
  }//end of Class
27278
 
27279
 
27280
-
27281
-
27282
- ?>
826
  // **********************************
827
  // **********************************
828
 
829
+ function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
830
 
831
  if (!class_exists('grad', false)) { include(_MPDF_PATH.'classes/grad.php'); }
832
  if (empty($this->grad)) { $this->grad = new grad($this); }
1407
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1408
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1409
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
 
1410
  }
1411
  return $format;
1412
  }
27276
  }//end of Class
27277
 
27278
 
 
 
 
mPDF/mpdf.php CHANGED
@@ -823,7 +823,7 @@ var $innerblocktags;
823
  // **********************************
824
  // **********************************
825
 
826
- function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
827
 
828
  /*-- BACKGROUNDS --*/
829
  if (!class_exists('grad', false)) { include(_MPDF_PATH.'classes/grad.php'); }
@@ -1419,7 +1419,6 @@ function _getPageFormat($format) {
1419
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1420
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1421
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
1422
- default: $format = false;
1423
  }
1424
  return $format;
1425
  }
@@ -32798,7 +32797,3 @@ function SetJS($script) {
32798
 
32799
  }//end of Class
32800
 
32801
-
32802
-
32803
-
32804
- ?>
823
  // **********************************
824
  // **********************************
825
 
826
+ function __construct($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
827
 
828
  /*-- BACKGROUNDS --*/
829
  if (!class_exists('grad', false)) { include(_MPDF_PATH.'classes/grad.php'); }
1419
  case 'A': {$format=array(314.65,504.57 ); break;} // 'A' format paperback size 111x178mm
1420
  case 'DEMY': {$format=array(382.68,612.28 ); break;} // 'Demy' format paperback size 135x216mm
1421
  case 'ROYAL': {$format=array(433.70,663.30 ); break;} // 'Royal' format paperback size 153x234mm
 
1422
  }
1423
  return $format;
1424
  }
32797
 
32798
  }//end of Class
32799
 
 
 
 
 
mPDF/mpdfi/fpdi_pdf_parser.php CHANGED
@@ -60,11 +60,11 @@ class fpdi_pdf_parser extends pdf_parser {
60
  * @param string $filename Source-Filename
61
  * @param object $fpdi Object of type fpdi
62
  */
63
- function fpdi_pdf_parser($filename,&$fpdi) {
64
  $this->fpdi =& $fpdi;
65
  $this->filename = $filename;
66
 
67
- parent::pdf_parser($filename);
68
  if ($this->success == false) { return false; }
69
 
70
  // resolve Pages-Dictonary
@@ -216,16 +216,16 @@ class fpdi_pdf_parser extends pdf_parser {
216
  switch ($_filter[1]) {
217
  case "/FlateDecode":
218
  if (function_exists('gzuncompress')) {
219
- $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
220
  } else {
221
  $this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
222
  }
223
- if ($stream === false) {
224
  $this->fpdi->error("Error while decompressing stream.");
225
  }
226
  break;
227
  // mPDF 4.2.003
228
- case '/LZWDecode':
229
  include_once(_MPDF_PATH.'mpdfi/filters/FilterLZW.php');
230
  // mPDF 5.0 Removed pass by reference =&
231
  $decoder = new FilterLZW();
@@ -359,5 +359,3 @@ class fpdi_pdf_parser extends pdf_parser {
359
 
360
 
361
  }
362
-
363
- ?>
60
  * @param string $filename Source-Filename
61
  * @param object $fpdi Object of type fpdi
62
  */
63
+ function __construct($filename,&$fpdi) {
64
  $this->fpdi =& $fpdi;
65
  $this->filename = $filename;
66
 
67
+ parent::__construct($filename);
68
  if ($this->success == false) { return false; }
69
 
70
  // resolve Pages-Dictonary
216
  switch ($_filter[1]) {
217
  case "/FlateDecode":
218
  if (function_exists('gzuncompress')) {
219
+ $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
220
  } else {
221
  $this->fpdi->error(sprintf("To handle %s filter, please compile php with zlib support.",$_filter[1]));
222
  }
223
+ if ($stream === false) {
224
  $this->fpdi->error("Error while decompressing stream.");
225
  }
226
  break;
227
  // mPDF 4.2.003
228
+ case '/LZWDecode':
229
  include_once(_MPDF_PATH.'mpdfi/filters/FilterLZW.php');
230
  // mPDF 5.0 Removed pass by reference =&
231
  $decoder = new FilterLZW();
359
 
360
 
361
  }
 
 
mPDF/mpdfi/pdf_context.php CHANGED
@@ -28,7 +28,7 @@ class pdf_context {
28
 
29
  // Constructor
30
 
31
- function pdf_context($f) {
32
  $this->file = $f;
33
  $this->reset();
34
  }
@@ -75,4 +75,3 @@ class pdf_context {
75
  }
76
 
77
  }
78
- ?>
28
 
29
  // Constructor
30
 
31
+ function __construct($f) {
32
  $this->file = $f;
33
  $this->reset();
34
  }
75
  }
76
 
77
  }
 
mPDF/mpdfi/pdf_parser.php CHANGED
@@ -82,7 +82,7 @@ class pdf_parser {
82
  *
83
  * @param string $filename Source-Filename
84
  */
85
- function pdf_parser($filename) {
86
  $this->filename = $filename;
87
  // mPDF 4.0
88
  $this->success = true;
@@ -120,9 +120,9 @@ class pdf_parser {
120
  */
121
  function closeFile() {
122
  if (isset($this->f)) {
123
- fclose($this->f);
124
  unset($this->f);
125
- }
126
  }
127
 
128
  /**
@@ -131,7 +131,7 @@ class pdf_parser {
131
  * @param string $msg Error-Message
132
  */
133
  function error($msg) {
134
- die("<b>PDF-Parser Error:</b> ".$msg);
135
  }
136
 
137
  /**
@@ -181,7 +181,7 @@ class pdf_parser {
181
  fseek ($this->f, -min(filesize($this->filename),1500), SEEK_END);
182
  $data = fread($this->f, 1500);
183
 
184
- $pos = strlen($data) - strpos(strrev($data), strrev('startxref'));
185
  $data = substr($data, $pos);
186
 
187
  if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
@@ -207,7 +207,7 @@ class pdf_parser {
207
  fseek($this->f, $o_pos = $offset);
208
  $data = trim(fgets($this->f,1024));
209
 
210
- if (strlen($data) == 0)
211
  $data = trim(fgets($this->f,1024));
212
 
213
  if ($data !== 'xref') {
@@ -215,7 +215,7 @@ class pdf_parser {
215
  $data = trim(_fgets($this->f, true));
216
  if ($data !== 'xref') {
217
  if (preg_match('/(.*xref)(.*)/m', $data, $m)) { // xref 0 128 - in one line
218
- fseek($this->f, $o_pos+strlen($m[1]));
219
  } elseif (preg_match('/(x|r|e|f)+/', $data, $m)) { // correct invalid xref-pointer
220
  $tmpOffset = $offset-4+strlen($m[0]);
221
  $this->pdf_read_xref($result, $tmpOffset, $start, $end);
@@ -271,7 +271,7 @@ class pdf_parser {
271
 
272
  $o_pos = ftell($this->f);
273
  $data = fgets($this->f,1024);
274
- if (strlen(trim($data)) == 0)
275
  $data = fgets($this->f, 1024);
276
 
277
  if (preg_match("/trailer/",$data)) {
@@ -433,7 +433,7 @@ class pdf_parser {
433
  if ($pos > $c->offset + $c->length) {
434
  $c->increase_length();
435
  }
436
- }
437
  }
438
 
439
  case "stream":
@@ -454,14 +454,14 @@ class pdf_parser {
454
  $tmp_length = $this->pdf_resolve_object($tmp_c,$this->actual_obj[1][1]['/Length']);
455
  $length = $tmp_length[1][1];
456
  } else {
457
- $length = $this->actual_obj[1][1]['/Length'][1];
458
  }
459
 
460
  if ($length > 0) {
461
  $c->reset($startpos+$e,$length);
462
  $v = $c->buffer;
463
  } else {
464
- $v = '';
465
  }
466
  $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream")
467
 
@@ -686,5 +686,3 @@ class pdf_parser {
686
 
687
 
688
  }
689
-
690
- ?>
82
  *
83
  * @param string $filename Source-Filename
84
  */
85
+ function __construct($filename) {
86
  $this->filename = $filename;
87
  // mPDF 4.0
88
  $this->success = true;
120
  */
121
  function closeFile() {
122
  if (isset($this->f)) {
123
+ fclose($this->f);
124
  unset($this->f);
125
+ }
126
  }
127
 
128
  /**
131
  * @param string $msg Error-Message
132
  */
133
  function error($msg) {
134
+ die("<b>PDF-Parser Error:</b> ".$msg);
135
  }
136
 
137
  /**
181
  fseek ($this->f, -min(filesize($this->filename),1500), SEEK_END);
182
  $data = fread($this->f, 1500);
183
 
184
+ $pos = strlen($data) - strpos(strrev($data), strrev('startxref'));
185
  $data = substr($data, $pos);
186
 
187
  if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
207
  fseek($this->f, $o_pos = $offset);
208
  $data = trim(fgets($this->f,1024));
209
 
210
+ if (strlen($data) == 0)
211
  $data = trim(fgets($this->f,1024));
212
 
213
  if ($data !== 'xref') {
215
  $data = trim(_fgets($this->f, true));
216
  if ($data !== 'xref') {
217
  if (preg_match('/(.*xref)(.*)/m', $data, $m)) { // xref 0 128 - in one line
218
+ fseek($this->f, $o_pos+strlen($m[1]));
219
  } elseif (preg_match('/(x|r|e|f)+/', $data, $m)) { // correct invalid xref-pointer
220
  $tmpOffset = $offset-4+strlen($m[0]);
221
  $this->pdf_read_xref($result, $tmpOffset, $start, $end);
271
 
272
  $o_pos = ftell($this->f);
273
  $data = fgets($this->f,1024);
274
+ if (strlen(trim($data)) == 0)
275
  $data = fgets($this->f, 1024);
276
 
277
  if (preg_match("/trailer/",$data)) {
433
  if ($pos > $c->offset + $c->length) {
434
  $c->increase_length();
435
  }
436
+ }
437
  }
438
 
439
  case "stream":
454
  $tmp_length = $this->pdf_resolve_object($tmp_c,$this->actual_obj[1][1]['/Length']);
455
  $length = $tmp_length[1][1];
456
  } else {
457
+ $length = $this->actual_obj[1][1]['/Length'][1];
458
  }
459
 
460
  if ($length > 0) {
461
  $c->reset($startpos+$e,$length);
462
  $v = $c->buffer;
463
  } else {
464
+ $v = '';
465
  }
466
  $c->reset($startpos+$e+$length+9); // 9 = strlen("endstream")
467
 
686
 
687
 
688
  }
 
 
pdf.php CHANGED
@@ -4,12 +4,12 @@
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
- * Version: 3.7.4
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
11
 
12
- /*
13
  This file is part of Gravity PDF.
14
 
15
  Gravity PDF Copyright (C) 2015 Blue Liquid Designs
@@ -39,30 +39,30 @@
39
  }
40
 
41
  /*
42
- * Define our constants
43
  */
44
- define('PDF_EXTENDED_VERSION', '3.7.4');
45
- define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
- define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
- define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
48
 
49
- define('PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
50
- define('PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ));
51
- define("PDF_SETTINGS_URL", site_url() .'/wp-admin/admin.php?page=gf_settings&subview=PDF');
52
- define('PDF_SAVE_FOLDER', 'PDF_EXTENDED_TEMPLATES');
53
- define('GF_PDF_EXTENDED_PLUGIN_BASENAME', plugin_basename(__FILE__));
54
 
55
- /*
56
  * Include the core files
57
- */
58
- include PDF_PLUGIN_DIR . 'helper/data.php';
59
- include PDF_PLUGIN_DIR . 'helper/notices.php';
60
- include PDF_PLUGIN_DIR . 'helper/pdf-configuration-indexer.php';
61
- include PDF_PLUGIN_DIR . 'helper/installation-update-manager.php';
62
- include PDF_PLUGIN_DIR . 'helper/pdf-common.php';
63
- include PDF_PLUGIN_DIR . 'helper/pdf-render.php';
64
-
65
- /*
66
  * Initiate the class after Gravity Forms has been loaded using the init hook.
67
  */
68
  add_action('init', array('GFPDF_Core', 'pdf_init'));
@@ -74,30 +74,30 @@ class GFPDF_Core extends PDFGenerator
74
  public $render;
75
 
76
  /*
77
- * Main Controller
78
  * First function fired when plugin is loaded
79
  * Determines if the plugin can run or not
80
  */
81
- public static function pdf_init()
82
  {
83
  /*
84
  * Initialise our data helper class
85
  */
86
  global $gfpdfe_data;
87
- $gfpdfe_data = new GFPDFE_DATA();
88
 
89
  /* set our PDF folder storage */
90
- $gfpdfe_data->set_directory_structure();
91
 
92
  /*
93
  * Include any dependancy-based files
94
- */
95
  include_once PDF_PLUGIN_DIR . 'pdf-settings.php';
96
  include_once PDF_PLUGIN_DIR . 'depreciated.php';
97
- include_once PDF_PLUGIN_DIR . 'helper/pdf-entry-detail.php';
98
 
99
  /*
100
- * Set the notice type
101
  */
102
  self::set_notice_type();
103
 
@@ -109,20 +109,20 @@ class GFPDF_Core extends PDFGenerator
109
  /*
110
  * Call our Settings class which will do our compatibility processing
111
  */
112
- $gfpdfe_data->settingsClass = new GFPDF_Settings();
113
 
114
  /*
115
- * Only run settings page if Gravity Forms version is installed and compatible
116
- * Needs to be run before major compatibility checks so it can prompt user
117
- * about issues with WP version or PHP
118
  */
119
 
120
  if($gfpdfe_data->gf_is_compatible === true && is_admin())
121
- {
122
  /*
123
  * Run our settings page
124
  */
125
- GFPDF_Settings::settings_page();
126
 
127
  /*
128
  * Only load our scripts if on a Gravity Forms admin page
@@ -130,8 +130,8 @@ class GFPDF_Core extends PDFGenerator
130
  if( isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_') )
131
  {
132
  /*
133
- * Run our scripts and add the settings page to the admin area
134
- */
135
  add_action('admin_init', array('GFPDF_Core', 'gfe_admin_init'), 9);
136
  }
137
  }
@@ -139,7 +139,7 @@ class GFPDF_Core extends PDFGenerator
139
  /*
140
  * We'll initialise our model which will do any function checks ect
141
  */
142
- include PDF_PLUGIN_DIR . 'model/pdf.php';
143
 
144
  /*
145
  * Check for any major compatibility issues early
@@ -150,78 +150,78 @@ class GFPDF_Core extends PDFGenerator
150
  * Major compatibility errors (WP version, Gravity Forms or PHP errors)
151
  * Exit to prevent conflicts
152
  */
153
- return;
154
  }
155
 
156
  /*
157
  * Some functions are required to monitor changes in the admin area
158
  * and ensure the plugin functions smoothly
159
  */
160
- add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
161
 
162
  /*
163
  * Only load the plugin if the following requirements are met:
164
  * - Load on Gravity Forms Admin pages
165
  * - Load if on any front-end admin page
166
  * - Load if doing AJAX request (which natively is called from the /wp-admin/ backend)
167
- */
168
  if( (is_admin() && isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_')) ||
169
  !is_admin() ||
170
  defined( 'DOING_AJAX' ) && DOING_AJAX )
171
- {
172
  /*
173
  * Initialise the core class which will load the __construct() function
174
  */
175
  global $gfpdf;
176
- $gfpdf = new GFPDF_Core();
177
  }
178
 
179
  return;
180
 
181
- }
182
 
183
  public function __construct()
184
- {
185
 
186
  /*
187
- * Ensure the system is fully installed
188
- * We run this after the 'settings' page has been set up (above)
189
  */
190
  if(GFPDF_Core_Model::is_fully_installed() === false)
191
  {
192
- return;
193
- }
194
 
195
- global $gfpdfe_data;
196
 
197
  /*
198
  * Set up the PDF configuration and indexer
199
  * Accessed through $this->configuration and $this->index.
200
  */
201
- parent::__construct();
202
 
203
  /*
204
  * Add our main hooks
205
- */
206
  add_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link'), 10, 4);
207
  add_action("gform_entry_info", array('GFPDF_Core_Model', 'detail_pdf_link'), 10, 2);
208
- add_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages'));
209
 
210
  /*
211
  * Apply default filters
212
- */
213
  add_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags'), 10, 3); /* convert mergetags in PDF template automatically */
214
- add_filter('gfpdfe_pdf_template', 'do_shortcode', 10, 1); /* convert shortcodes in PDF template automatically */
215
 
216
  /* Check if on the entries page and output javascript */
217
  if(is_admin() && rgget('page') == 'gf_entries')
218
  {
219
- wp_enqueue_script( 'gfpdfeentries', PDF_PLUGIN_URL . 'resources/javascript/entries-admin.min.js', array('jquery') );
220
- }
221
 
222
  /*
223
  * Register render class
224
- */
225
  $this->render = new PDFRender();
226
 
227
  /*
@@ -230,7 +230,7 @@ class GFPDF_Core extends PDFGenerator
230
  if($gfpdfe_data->can_write_output_dir === true)
231
  {
232
  add_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf'), 10, 2);
233
- add_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf'), 100, 3); /* ensure it's called later than standard so the attachment array isn't overridden */
234
  }
235
 
236
  }
@@ -242,7 +242,7 @@ class GFPDF_Core extends PDFGenerator
242
  {
243
 
244
  /*
245
- * Check user has the correct permissions to deploy the software
246
  */
247
  if(!current_user_can( 'manage_options' ))
248
  {
@@ -255,25 +255,25 @@ class GFPDF_Core extends PDFGenerator
255
  * Don't run initialiser if we cannot...
256
  */
257
  if($gfpdfe_data->allow_initilisation === false)
258
- {
259
  /*
260
  * Prompt user about a server configuration problem
261
  */
262
- add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_server_problem_detected"));
263
- return false;
264
- }
265
 
266
  /*
267
- * Check if we have direct write access to the server
268
  */
269
  GFPDF_InstallUpdater::check_filesystem_api();
270
 
271
  /*
272
- * Check if we can automatically deploy the software.
273
- * 90% of sites should be able to do this as they will have 'direct' write abilities
274
  * to their server files.
275
  */
276
- GFPDF_InstallUpdater::maybe_deploy();
277
 
278
  /*
279
  * Check if we need to deploy the software
@@ -282,16 +282,16 @@ class GFPDF_Core extends PDFGenerator
282
 
283
  /*
284
  * Check if the template folder location needs to be migrated
285
- */
286
  if(!rgpost('upgrade'))
287
  {
288
- GFPDF_InstallUpdater::check_template_migration();
289
  }
290
  }
291
 
292
  /*
293
- * Depending on what page we are on, we need to fire different notices
294
- * We've added our own custom notice to the settings page as some functions fire later than the normal 'admin_notices' action
295
  */
296
  private static function set_notice_type()
297
  {
@@ -320,9 +320,9 @@ class GFPDF_Core extends PDFGenerator
320
  global $gfpdfe_data;
321
 
322
  /*
323
- * Check if client is using the automated installer
324
- * If installer has issues or client cannot use auto installer (using FTP/SSH ect) then run the usual
325
- * initialisation messages.
326
  */
327
  if($gfpdfe_data->automated === true && $gfpdfe_data->fresh_install === true & get_option('gfpdfe_automated_install') != 'installing')
328
  {
@@ -331,23 +331,23 @@ class GFPDF_Core extends PDFGenerator
331
 
332
  /*
333
  * Check if GF PDF Extended is correctly installed. If not we'll run the installer.
334
- */
335
- $theme_switch = get_option('gfpdfe_switch_theme');
336
 
337
  if( get_option('gf_pdf_extended_installed') != 'installed' && !rgpost('upgrade') )
338
  {
339
  /*
340
  * Prompt user to initialise plugin
341
  */
342
- add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_not_deployed_fresh"));
343
  }
344
  elseif( (
345
  ( !is_dir($gfpdfe_data->template_site_location)) ||
346
  ( !file_exists($gfpdfe_data->template_site_location . 'configuration.php') ) ||
347
- ( !is_dir($gfpdfe_data->template_save_location) )
348
  )
349
  && (!rgpost('upgrade'))
350
- && (!is_dir($gfpdfe_data->old_template_location)
351
  && (!is_dir($gfpdfe_data->old_3_6_template_site_location)) ) /* add in 3.6 directory change */
352
  )
353
  {
@@ -356,19 +356,19 @@ class GFPDF_Core extends PDFGenerator
356
  * Prompt user that a problem was detected and they need to redeploy
357
  */
358
  add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_problem_detected"));
359
- }
360
  }
361
 
362
  /**
363
- * Add our scripts and settings page to the admin area
364
  */
365
  public static function gfe_admin_init()
366
- {
367
- /*
368
  * Configure the settings page
369
  */
370
- wp_enqueue_style( 'pdfextended-admin-styles', PDF_PLUGIN_URL . 'resources/css/admin-styles.min.css', array(), '1.3' );
371
- wp_enqueue_script( 'pdfextended-settings-script', PDF_PLUGIN_URL . 'resources/javascript/admin.min.js', array(), '1.3' );
372
 
373
  /*
374
  * Localise admin script
@@ -382,10 +382,10 @@ class GFPDF_Core extends PDFGenerator
382
  /*
383
  * Register our scripts/styles with Gravity Forms to prevent them being removed in no conflict mode
384
  */
385
- add_filter('gform_noconflict_scripts', array('GFPDF_Core', 'register_gravityform_scripts'));
386
- add_filter('gform_noconflict_styles', array('GFPDF_Core', 'register_gravityform_styles'));
387
 
388
- add_filter('gform_tooltips', array('GFPDF_Notices', 'add_tooltips'));
389
 
390
  }
391
 
@@ -402,13 +402,13 @@ class GFPDF_Core extends PDFGenerator
402
 
403
  /*
404
  * Register our styles with Gravity Forms so they aren't removed when no conflict mode is active
405
- */
406
  public static function register_gravityform_styles($styles)
407
  {
408
- $styles[] = 'pdfextended-admin-styles';
409
 
410
  return $styles;
411
- }
412
 
413
  }
414
 
@@ -445,5 +445,5 @@ if (!function_exists('array_replace_recursive'))
445
  }
446
 
447
  return $base;
448
- }
449
  }
4
  * Plugin Name: Gravity PDF
5
  * Plugin URI: https://gravitypdf.com
6
  * Description: Gravity PDF allows you to save/view/download a PDF from the front- and back-end, and automate PDF creation on form submission. Our Business Plus package also allows you to overlay field onto an existing PDF.
7
+ * Version: 3.7.5
8
  * Author: Blue Liquid Designs
9
  * Author URI: http://www.blueliquiddesigns.com.au
10
  */
11
 
12
+ /*
13
  This file is part of Gravity PDF.
14
 
15
  Gravity PDF Copyright (C) 2015 Blue Liquid Designs
39
  }
40
 
41
  /*
42
+ * Define our constants
43
  */
44
+ define('PDF_EXTENDED_VERSION', '3.7.5');
45
+ define('GF_PDF_EXTENDED_SUPPORTED_VERSION', '1.8');
46
+ define('GF_PDF_EXTENDED_WP_SUPPORTED_VERSION', '3.9');
47
+ define('GF_PDF_EXTENDED_PHP_SUPPORTED_VERSION', '5');
48
 
49
+ define('PDF_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
50
+ define('PDF_PLUGIN_URL', plugin_dir_url( __FILE__ ));
51
+ define("PDF_SETTINGS_URL", site_url() .'/wp-admin/admin.php?page=gf_settings&subview=PDF');
52
+ define('PDF_SAVE_FOLDER', 'PDF_EXTENDED_TEMPLATES');
53
+ define('GF_PDF_EXTENDED_PLUGIN_BASENAME', plugin_basename(__FILE__));
54
 
55
+ /*
56
  * Include the core files
57
+ */
58
+ include PDF_PLUGIN_DIR . 'helper/data.php';
59
+ include PDF_PLUGIN_DIR . 'helper/notices.php';
60
+ include PDF_PLUGIN_DIR . 'helper/pdf-configuration-indexer.php';
61
+ include PDF_PLUGIN_DIR . 'helper/installation-update-manager.php';
62
+ include PDF_PLUGIN_DIR . 'helper/pdf-common.php';
63
+ include PDF_PLUGIN_DIR . 'helper/pdf-render.php';
64
+
65
+ /*
66
  * Initiate the class after Gravity Forms has been loaded using the init hook.
67
  */
68
  add_action('init', array('GFPDF_Core', 'pdf_init'));
74
  public $render;
75
 
76
  /*
77
+ * Main Controller
78
  * First function fired when plugin is loaded
79
  * Determines if the plugin can run or not
80
  */
81
+ public static function pdf_init()
82
  {
83
  /*
84
  * Initialise our data helper class
85
  */
86
  global $gfpdfe_data;
87
+ $gfpdfe_data = new GFPDFE_DATA();
88
 
89
  /* set our PDF folder storage */
90
+ $gfpdfe_data->set_directory_structure();
91
 
92
  /*
93
  * Include any dependancy-based files
94
+ */
95
  include_once PDF_PLUGIN_DIR . 'pdf-settings.php';
96
  include_once PDF_PLUGIN_DIR . 'depreciated.php';
97
+ include_once PDF_PLUGIN_DIR . 'helper/pdf-entry-detail.php';
98
 
99
  /*
100
+ * Set the notice type
101
  */
102
  self::set_notice_type();
103
 
109
  /*
110
  * Call our Settings class which will do our compatibility processing
111
  */
112
+ $gfpdfe_data->settingsClass = new GFPDF_Settings();
113
 
114
  /*
115
+ * Only run settings page if Gravity Forms version is installed and compatible
116
+ * Needs to be run before major compatibility checks so it can prompt user
117
+ * about issues with WP version or PHP
118
  */
119
 
120
  if($gfpdfe_data->gf_is_compatible === true && is_admin())
121
+ {
122
  /*
123
  * Run our settings page
124
  */
125
+ GFPDF_Settings::settings_page();
126
 
127
  /*
128
  * Only load our scripts if on a Gravity Forms admin page
130
  if( isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_') )
131
  {
132
  /*
133
+ * Run our scripts and add the settings page to the admin area
134
+ */
135
  add_action('admin_init', array('GFPDF_Core', 'gfe_admin_init'), 9);
136
  }
137
  }
139
  /*
140
  * We'll initialise our model which will do any function checks ect
141
  */
142
+ include PDF_PLUGIN_DIR . 'model/pdf.php';
143
 
144
  /*
145
  * Check for any major compatibility issues early
150
  * Major compatibility errors (WP version, Gravity Forms or PHP errors)
151
  * Exit to prevent conflicts
152
  */
153
+ return;
154
  }
155
 
156
  /*
157
  * Some functions are required to monitor changes in the admin area
158
  * and ensure the plugin functions smoothly
159
  */
160
+ add_action('admin_init', array('GFPDF_Core', 'fully_loaded_admin'), 9999); /* run later than usual to give our auto initialiser a chance to fire */
161
 
162
  /*
163
  * Only load the plugin if the following requirements are met:
164
  * - Load on Gravity Forms Admin pages
165
  * - Load if on any front-end admin page
166
  * - Load if doing AJAX request (which natively is called from the /wp-admin/ backend)
167
+ */
168
  if( (is_admin() && isset($_GET['page']) && (substr($_GET['page'], 0, 3) === 'gf_')) ||
169
  !is_admin() ||
170
  defined( 'DOING_AJAX' ) && DOING_AJAX )
171
+ {
172
  /*
173
  * Initialise the core class which will load the __construct() function
174
  */
175
  global $gfpdf;
176
+ $gfpdf = new GFPDF_Core();
177
  }
178
 
179
  return;
180
 
181
+ }
182
 
183
  public function __construct()
184
+ {
185
 
186
  /*
187
+ * Ensure the system is fully installed
188
+ * We run this after the 'settings' page has been set up (above)
189
  */
190
  if(GFPDF_Core_Model::is_fully_installed() === false)
191
  {
192
+ return;
193
+ }
194
 
195
+ global $gfpdfe_data;
196
 
197
  /*
198
  * Set up the PDF configuration and indexer
199
  * Accessed through $this->configuration and $this->index.
200
  */
201
+ parent::__construct();
202
 
203
  /*
204
  * Add our main hooks
205
+ */
206
  add_action('gform_entries_first_column_actions', array('GFPDF_Core_Model', 'pdf_link'), 10, 4);
207
  add_action("gform_entry_info", array('GFPDF_Core_Model', 'detail_pdf_link'), 10, 2);
208
+ add_action('wp', array('GFPDF_Core_Model', 'process_exterior_pages'));
209
 
210
  /*
211
  * Apply default filters
212
+ */
213
  add_filter('gfpdfe_pdf_template', array('PDF_Common', 'do_mergetags'), 10, 3); /* convert mergetags in PDF template automatically */
214
+ add_filter('gfpdfe_pdf_template', 'do_shortcode', 10, 1); /* convert shortcodes in PDF template automatically */
215
 
216
  /* Check if on the entries page and output javascript */
217
  if(is_admin() && rgget('page') == 'gf_entries')
218
  {
219
+ wp_enqueue_script( 'gfpdfeentries', PDF_PLUGIN_URL . 'resources/javascript/entries-admin.min.js', array('jquery') );
220
+ }
221
 
222
  /*
223
  * Register render class
224
+ */
225
  $this->render = new PDFRender();
226
 
227
  /*
230
  if($gfpdfe_data->can_write_output_dir === true)
231
  {
232
  add_action('gform_after_submission', array('GFPDF_Core_Model', 'gfpdfe_save_pdf'), 10, 2);
233
+ add_filter('gform_notification', array('GFPDF_Core_Model', 'gfpdfe_create_and_attach_pdf'), 100, 3); /* ensure it's called later than standard so the attachment array isn't overridden */
234
  }
235
 
236
  }
242
  {
243
 
244
  /*
245
+ * Check user has the correct permissions to deploy the software
246
  */
247
  if(!current_user_can( 'manage_options' ))
248
  {
255
  * Don't run initialiser if we cannot...
256
  */
257
  if($gfpdfe_data->allow_initilisation === false)
258
+ {
259
  /*
260
  * Prompt user about a server configuration problem
261
  */
262
+ add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_server_problem_detected"));
263
+ return false;
264
+ }
265
 
266
  /*
267
+ * Check if we have direct write access to the server
268
  */
269
  GFPDF_InstallUpdater::check_filesystem_api();
270
 
271
  /*
272
+ * Check if we can automatically deploy the software.
273
+ * 90% of sites should be able to do this as they will have 'direct' write abilities
274
  * to their server files.
275
  */
276
+ GFPDF_InstallUpdater::maybe_deploy();
277
 
278
  /*
279
  * Check if we need to deploy the software
282
 
283
  /*
284
  * Check if the template folder location needs to be migrated
285
+ */
286
  if(!rgpost('upgrade'))
287
  {
288
+ GFPDF_InstallUpdater::check_template_migration();
289
  }
290
  }
291
 
292
  /*
293
+ * Depending on what page we are on, we need to fire different notices
294
+ * We've added our own custom notice to the settings page as some functions fire later than the normal 'admin_notices' action
295
  */
296
  private static function set_notice_type()
297
  {
320
  global $gfpdfe_data;
321
 
322
  /*
323
+ * Check if client is using the automated installer
324
+ * If installer has issues or client cannot use auto installer (using FTP/SSH ect) then run the usual
325
+ * initialisation messages.
326
  */
327
  if($gfpdfe_data->automated === true && $gfpdfe_data->fresh_install === true & get_option('gfpdfe_automated_install') != 'installing')
328
  {
331
 
332
  /*
333
  * Check if GF PDF Extended is correctly installed. If not we'll run the installer.
334
+ */
335
+ $theme_switch = get_option('gfpdfe_switch_theme');
336
 
337
  if( get_option('gf_pdf_extended_installed') != 'installed' && !rgpost('upgrade') )
338
  {
339
  /*
340
  * Prompt user to initialise plugin
341
  */
342
+ add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_not_deployed_fresh"));
343
  }
344
  elseif( (
345
  ( !is_dir($gfpdfe_data->template_site_location)) ||
346
  ( !file_exists($gfpdfe_data->template_site_location . 'configuration.php') ) ||
347
+ ( !is_dir($gfpdfe_data->template_save_location) )
348
  )
349
  && (!rgpost('upgrade'))
350
+ && (!is_dir($gfpdfe_data->old_template_location)
351
  && (!is_dir($gfpdfe_data->old_3_6_template_site_location)) ) /* add in 3.6 directory change */
352
  )
353
  {
356
  * Prompt user that a problem was detected and they need to redeploy
357
  */
358
  add_action($gfpdfe_data->notice_type, array("GFPDF_Notices", "gf_pdf_problem_detected"));
359
+ }
360
  }
361
 
362
  /**
363
+ * Add our scripts and settings page to the admin area
364
  */
365
  public static function gfe_admin_init()
366
+ {
367
+ /*
368
  * Configure the settings page
369
  */
370
+ wp_enqueue_style( 'pdfextended-admin-styles', PDF_PLUGIN_URL . 'resources/css/admin-styles.min.css', array(), '1.3' );
371
+ wp_enqueue_script( 'pdfextended-settings-script', PDF_PLUGIN_URL . 'resources/javascript/admin.min.js', array(), '1.3' );
372
 
373
  /*
374
  * Localise admin script
382
  /*
383
  * Register our scripts/styles with Gravity Forms to prevent them being removed in no conflict mode
384
  */
385
+ add_filter('gform_noconflict_scripts', array('GFPDF_Core', 'register_gravityform_scripts'));
386
+ add_filter('gform_noconflict_styles', array('GFPDF_Core', 'register_gravityform_styles'));
387
 
388
+ add_filter('gform_tooltips', array('GFPDF_Notices', 'add_tooltips'));
389
 
390
  }
391
 
402
 
403
  /*
404
  * Register our styles with Gravity Forms so they aren't removed when no conflict mode is active
405
+ */
406
  public static function register_gravityform_styles($styles)
407
  {
408
+ $styles[] = 'pdfextended-admin-styles';
409
 
410
  return $styles;
411
+ }
412
 
413
  }
414
 
445
  }
446
 
447
  return $base;
448
+ }
449
  }
view/templates/settings/changelog.php CHANGED
@@ -23,14 +23,14 @@
23
  You should have received a copy of the GNU General Public License
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- */
27
 
28
  /*
29
  <li>Don't run if the correct class isn't present
30
  */
31
  if(!class_exists('GFPDF_Settings_Model'))
32
  {
33
- exit;
34
  }
35
 
36
  ?>
@@ -40,7 +40,11 @@
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
 
 
 
43
 
 
44
  <ul>
45
  <li>Housekpeeing - Revert patch made in last update as Gravity Forms 1.9.9 fixes the issue internally.</li>
46
  </ul>
@@ -68,9 +72,9 @@
68
 
69
  <h3>3.7.0</h3>
70
  <ul>
71
- <li>Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. If this option is enabled and the section break is empty it will still be displayed on the PDF. Note: Existing installations will have to reinitialise their templates with the 'Reinstall Default and Example Templates' option enabled.</li>
72
  <li>Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location</li>
73
- <li>Housekeeping - Migrate your template and configuration files. As of Gravity PDF 3.7 we'll be dropping the 'site_name' folder for single WordPress installs and changing the multisite install directory to the site ID.</li>
74
  <li>Housekeeping - Added $form_data['html_id'] key which has the HTML fields added by their ID (much like the signature_details_id key).</li>
75
  <li>Housekeeping - Add large number of unit tests </li>
76
  <li>Housekeeping - Derestrict certain pages software loads on.</li>
@@ -160,7 +164,7 @@
160
  <li>Bug - Correctly check if the plugin is loaded correctly before letting the PDF class fully load</li>
161
  </ul>
162
 
163
- <h3>3.5.4</h3>
164
  <ul>
165
  <li>Bug - Fixed issue with incorrect PDF name showing on the entry details page</li>
166
  <li>Bug - Fixed issue with custom fonts being inaccessible without manually reinstalling after upgrading.</li>
@@ -210,7 +214,7 @@
210
  <li>Housekeeping - Update initialisation tab copy for both pre- and post- initialisation</li>
211
  <li>Housekeeping - Use Gravity Forms get_ip() function instead of custom function</li>
212
  <li>Housekeeping - The in-built support form uses SSL once again (disabled in the past due to some servers being unable to verify the certificate). </li>
213
- <li>Bug - When testing write permissions, file_exist() is throwing false positives for some users which would generate a warning when unlink() is called. Hide warning using '@'. </li>
214
  </ul>
215
 
216
 
@@ -335,7 +339,7 @@
335
  <li>Feature - Added a Support tab to the settings page which allows users to securely (over HTTPS) submit a support ticket to the Gravity PDF support desk</li>
336
  <li>Feature - Changed select, multiselect and radio fields so that the default templates use the name rather than the value. $form_data now also includes the name and values for all these fields.</li>
337
  <li>Feature - $form_data now includes all miscellaneous lead information in the $form_data['misc'] array.</li>
338
- <li>Feature - $form_data now contains 24 and 12 hour time of entry submission.</li>
339
  <li>Feature - Added localisation support</li>
340
  <li>Compatibility - Added new multi-upload support which was added in Gravity Forms 1.8.</li>
341
  <li>Bug - Added 'aid' parametre to the PDF url when multiple configuration nodes present on a single form</li>
@@ -349,7 +353,7 @@
349
  <li>Housekeeping - Update core styles to match Wordpress 3.8/Gravity Forms 1.8.</li>
350
  <li>Housekeeping - Updated header/footer examples to use @page in example.</li>
351
 
352
- </ul>
353
 
354
  <h3>3.2.0</h3>
355
  <ul>
23
  You should have received a copy of the GNU General Public License
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+ */
27
 
28
  /*
29
  <li>Don't run if the correct class isn't present
30
  */
31
  if(!class_exists('GFPDF_Settings_Model'))
32
  {
33
+ exit;
34
  }
35
 
36
  ?>
40
  <p><strong>Current Version: <?php echo PDF_EXTENDED_VERSION; ?></strong></p>
41
 
42
  <h3><?php echo PDF_EXTENDED_VERSION; ?></h3>
43
+ <ul>
44
+ <li>Tweak mPDF package to be PHP7 compatible.</li>
45
+ </ul>
46
 
47
+ <h3>3.7.4</h3>
48
  <ul>
49
  <li>Housekpeeing - Revert patch made in last update as Gravity Forms 1.9.9 fixes the issue internally.</li>
50
  </ul>
72
 
73
  <h3>3.7.0</h3>
74
  <ul>
75
+ <li>Feature - Added 'default-show-section-content' configuration option. You can now display the section break content in the default template. If this option is enabled and the section break is empty it will still be displayed on the PDF. Note: Existing installations will have to reinitialise their templates with the 'Reinstall Default and Example Templates' option enabled.</li>
76
  <li>Feature - Added hooks 'gfpdfe_template_location' and 'gfpdfe_template_location_uri' to change PDF template location</li>
77
+ <li>Housekeeping - Migrate your template and configuration files. As of Gravity PDF 3.7 we'll be dropping the 'site_name' folder for single WordPress installs and changing the multisite install directory to the site ID.</li>
78
  <li>Housekeeping - Added $form_data['html_id'] key which has the HTML fields added by their ID (much like the signature_details_id key).</li>
79
  <li>Housekeeping - Add large number of unit tests </li>
80
  <li>Housekeeping - Derestrict certain pages software loads on.</li>
164
  <li>Bug - Correctly check if the plugin is loaded correctly before letting the PDF class fully load</li>
165
  </ul>
166
 
167
+ <h3>3.5.4</h3>
168
  <ul>
169
  <li>Bug - Fixed issue with incorrect PDF name showing on the entry details page</li>
170
  <li>Bug - Fixed issue with custom fonts being inaccessible without manually reinstalling after upgrading.</li>
214
  <li>Housekeeping - Update initialisation tab copy for both pre- and post- initialisation</li>
215
  <li>Housekeeping - Use Gravity Forms get_ip() function instead of custom function</li>
216
  <li>Housekeeping - The in-built support form uses SSL once again (disabled in the past due to some servers being unable to verify the certificate). </li>
217
+ <li>Bug - When testing write permissions, file_exist() is throwing false positives for some users which would generate a warning when unlink() is called. Hide warning using '@'. </li>
218
  </ul>
219
 
220
 
339
  <li>Feature - Added a Support tab to the settings page which allows users to securely (over HTTPS) submit a support ticket to the Gravity PDF support desk</li>
340
  <li>Feature - Changed select, multiselect and radio fields so that the default templates use the name rather than the value. $form_data now also includes the name and values for all these fields.</li>
341
  <li>Feature - $form_data now includes all miscellaneous lead information in the $form_data['misc'] array.</li>
342
+ <li>Feature - $form_data now contains 24 and 12 hour time of entry submission.</li>
343
  <li>Feature - Added localisation support</li>
344
  <li>Compatibility - Added new multi-upload support which was added in Gravity Forms 1.8.</li>
345
  <li>Bug - Added 'aid' parametre to the PDF url when multiple configuration nodes present on a single form</li>
353
  <li>Housekeeping - Update core styles to match Wordpress 3.8/Gravity Forms 1.8.</li>
354
  <li>Housekeeping - Updated header/footer examples to use @page in example.</li>
355
 
356
+ </ul>
357
 
358
  <h3>3.2.0</h3>
359
  <ul>