From 536892fd4c55de2cfe662d67083a6c9ba610cc23 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 4 Dec 2015 20:07:23 +0800 Subject: [PATCH 1/2] MDL-52312 assignfeedback_editpdf: updated the FPDI libary to 1.6.1 --- mod/assign/feedback/editpdf/fpdi/ASL20.txt | 202 ------------- mod/assign/feedback/editpdf/fpdi/LICENSE | 21 ++ .../editpdf/fpdi/filters/FilterASCII85.php | 31 +- .../fpdi/filters/FilterASCII85_FPDI.php | 33 --- .../fpdi/filters/FilterASCIIHexDecode.php | 25 +- .../editpdf/fpdi/filters/FilterLZW.php | 25 +- .../editpdf/fpdi/filters/FilterLZW_FPDI.php | 33 --- mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php | 31 +- mod/assign/feedback/editpdf/fpdi/fpdi.php | 272 +++++++++--------- .../feedback/editpdf/fpdi/fpdi_bridge.php | 29 +- .../feedback/editpdf/fpdi/fpdi_pdf_parser.php | 63 ++-- .../feedback/editpdf/fpdi/pdf_context.php | 25 +- .../feedback/editpdf/fpdi/pdf_parser.php | 27 +- 13 files changed, 246 insertions(+), 571 deletions(-) delete mode 100644 mod/assign/feedback/editpdf/fpdi/ASL20.txt create mode 100644 mod/assign/feedback/editpdf/fpdi/LICENSE delete mode 100644 mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php delete mode 100644 mod/assign/feedback/editpdf/fpdi/filters/FilterLZW_FPDI.php diff --git a/mod/assign/feedback/editpdf/fpdi/ASL20.txt b/mod/assign/feedback/editpdf/fpdi/ASL20.txt deleted file mode 100644 index d6456956733..00000000000 --- a/mod/assign/feedback/editpdf/fpdi/ASL20.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/mod/assign/feedback/editpdf/fpdi/LICENSE b/mod/assign/feedback/editpdf/fpdi/LICENSE new file mode 100644 index 00000000000..7b4f5302921 --- /dev/null +++ b/mod/assign/feedback/editpdf/fpdi/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Setasign - Jan Slabon, https://www.setasign.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php index e16ac0517cb..b7e89663292 100644 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php +++ b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php @@ -1,21 +1,12 @@ > 24); $out .= chr($r >> 16); $out .= chr($r >> 8); diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php deleted file mode 100644 index 03413ebf6af..00000000000 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php +++ /dev/null @@ -1,33 +0,0 @@ -fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCIIHexDecode.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCIIHexDecode.php index 37c59864d52..66ddae48392 100644 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCIIHexDecode.php +++ b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCIIHexDecode.php @@ -1,21 +1,12 @@ fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php b/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php index dbaa1f2b18a..de746dda313 100644 --- a/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php +++ b/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php @@ -1,21 +1,12 @@ _out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', - $tplData['scaleX'], $tplData['scaleY'], $tplData['tx'] * $this->k, $tplData['ty'] * $this->k) + $tplData['scaleX'], $tplData['scaleY'], $tplData['tx'] * $this->k, $tplData['ty'] * $this->k) ); // Translate $this->_out(sprintf('%s%d Do Q', $this->tplPrefix, $tplIdx)); @@ -362,7 +353,7 @@ class FPDF_TPL extends fpdi_bridge * @see http://fpdf.org/en/doc/addpage.htm * @see http://www.tcpdf.org/doc/code/classTCPDF.html#a5171e20b366b74523709d84c349c1ced */ - public function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) + public function AddPage($orientation = '', $format = '', $rotationOrKeepmargins = false, $tocpage = false) { if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); @@ -373,7 +364,7 @@ class FPDF_TPL extends fpdi_bridge throw new LogicException('Adding pages in templates is not possible!'); } - parent::AddPage($orientation, $format); + parent::AddPage($orientation, $format, $rotationOrKeepmargins); } /** diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi.php b/mod/assign/feedback/editpdf/fpdi/fpdi.php index c81cd9f507d..8ecc661d8e4 100644 --- a/mod/assign/feedback/editpdf/fpdi/fpdi.php +++ b/mod/assign/feedback/editpdf/fpdi/fpdi.php @@ -1,21 +1,12 @@ PDFVersion; - } + return $this->PDFVersion; + } /** * Set the PDF version. @@ -151,7 +142,7 @@ class FPDI extends FPDF_TPL { $this->PDFVersion = sprintf('%.1F', $version); } - + /** * Import a page. * @@ -243,7 +234,7 @@ class FPDI extends FPDF_TPL $rotation = $parser->getPageRotation($pageNo); $tpl['_rotationAngle'] = 0; if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) { - $steps = $angle / 90; + $steps = $angle / 90; $_w = $tpl['w']; $_h = $tpl['h']; @@ -251,9 +242,9 @@ class FPDI extends FPDF_TPL $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; if ($angle < 0) - $angle += 360; + $angle += 360; - $tpl['_rotationAngle'] = $angle * -1; + $tpl['_rotationAngle'] = $angle * -1; } $this->_importedPages[$pageKey] = $this->tpl; @@ -301,29 +292,33 @@ class FPDI extends FPDF_TPL $size = array($size['w'], $size['h']); if (is_subclass_of($this, 'TCPDF')) { - $this->setPageFormat($size, $orientation); + $this->setPageFormat($size, $orientation); } else { - $size = $this->_getpagesize($size); - - if($orientation != $this->CurOrientation || + $size = $this->_getpagesize($size); + + if($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1] ) { - // New size or orientation - if ($orientation=='P') { - $this->w = $size[0]; - $this->h = $size[1]; - } else { - $this->w = $size[1]; - $this->h = $size[0]; - } - $this->wPt = $this->w * $this->k; - $this->hPt = $this->h * $this->k; - $this->PageBreakTrigger = $this->h - $this->bMargin; - $this->CurOrientation = $orientation; - $this->CurPageSize = $size; - $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); - } + // New size or orientation + if ($orientation=='P') { + $this->w = $size[0]; + $this->h = $size[1]; + } else { + $this->w = $size[1]; + $this->h = $size[0]; + } + $this->wPt = $this->w * $this->k; + $this->hPt = $this->h * $this->k; + $this->PageBreakTrigger = $this->h - $this->bMargin; + $this->CurOrientation = $orientation; + $this->CurPageSize = $size; + if (FPDF_VERSION >= 1.8) { + $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); + } else { + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); + } + } } } @@ -373,13 +368,13 @@ class FPDI extends FPDF_TPL protected function _putformxobjects() { $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->_tpls); + reset($this->_tpls); foreach($this->_tpls AS $tplIdx => $tpl) { $this->_newobj(); - $currentN = $this->n; // TCPDF/Protection: rem current "n" - - $this->_tpls[$tplIdx]['n'] = $this->n; - $this->_out('<<' . $filter . '/Type /XObject'); + $currentN = $this->n; // TCPDF/Protection: rem current "n" + + $this->_tpls[$tplIdx]['n'] = $this->n; + $this->_out('<<' . $filter . '/Type /XObject'); $this->_out('/Subtype /Form'); $this->_out('/FormType 1'); @@ -406,15 +401,15 @@ class FPDI extends FPDF_TPL switch($tpl['_rotationAngle']) { case -90: - $tx = -$tpl['box']['lly']; - $ty = $tpl['box']['urx']; - break; + $tx = -$tpl['box']['lly']; + $ty = $tpl['box']['urx']; + break; case -180: $tx = $tpl['box']['urx']; $ty = $tpl['box']['ury']; break; case -270: - $tx = $tpl['box']['ury']; + $tx = $tpl['box']['ury']; $ty = -$tpl['box']['llx']; break; } @@ -478,15 +473,15 @@ class FPDI extends FPDF_TPL $buffer = ($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; if (is_subclass_of($this, 'TCPDF')) { - $buffer = $this->_getrawstream($buffer); - $this->_out('/Length ' . strlen($buffer) . ' >>'); - $this->_out("stream\n" . $buffer . "\nendstream"); + $buffer = $this->_getrawstream($buffer); + $this->_out('/Length ' . strlen($buffer) . ' >>'); + $this->_out("stream\n" . $buffer . "\nendstream"); } else { - $this->_out('/Length ' . strlen($buffer) . ' >>'); - $this->_putstream($buffer); + $this->_out('/Length ' . strlen($buffer) . ' >>'); + $this->_putstream($buffer); } - $this->_out('endobj'); - $this->n = $newN; // TCPDF: reset to new "n" + $this->_out('endobj'); + $this->n = $newN; // TCPDF: reset to new "n" } $this->_putimportedobjects(); @@ -507,7 +502,7 @@ class FPDI extends FPDF_TPL $objId = ++$this->n; } - //Begin a new object + // Begin a new object if (!$onlyNewObj) { $this->offsets[$objId] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer); $this->_out($objId . ' 0 obj'); @@ -532,93 +527,92 @@ class FPDI extends FPDF_TPL switch ($value[0]) { - case pdf_parser::TYPE_TOKEN: + case pdf_parser::TYPE_TOKEN: $this->_straightOut($value[1] . ' '); - break; - case pdf_parser::TYPE_NUMERIC: - case pdf_parser::TYPE_REAL: + break; + case pdf_parser::TYPE_NUMERIC: + case pdf_parser::TYPE_REAL: if (is_float($value[1]) && $value[1] != 0) { - $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' '); - } else { - $this->_straightOut($value[1] . ' '); - } - break; - - case pdf_parser::TYPE_ARRAY: + $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' '); + } else { + $this->_straightOut($value[1] . ' '); + } + break; + + case pdf_parser::TYPE_ARRAY: - // An array. Output the proper - // structure and move on. + // An array. Output the proper + // structure and move on. - $this->_straightOut('['); + $this->_straightOut('['); for ($i = 0; $i < count($value[1]); $i++) { - $this->_writeValue($value[1][$i]); - } + $this->_writeValue($value[1][$i]); + } - $this->_out(']'); - break; + $this->_out(']'); + break; - case pdf_parser::TYPE_DICTIONARY: + case pdf_parser::TYPE_DICTIONARY: - // A dictionary. - $this->_straightOut('<<'); + // A dictionary. + $this->_straightOut('<<'); - reset ($value[1]); + reset ($value[1]); - while (list($k, $v) = each($value[1])) { - $this->_straightOut($k . ' '); - $this->_writeValue($v); - } + while (list($k, $v) = each($value[1])) { + $this->_straightOut($k . ' '); + $this->_writeValue($v); + } - $this->_straightOut('>>'); - break; + $this->_straightOut('>>'); + break; - case pdf_parser::TYPE_OBJREF: + case pdf_parser::TYPE_OBJREF: - // An indirect object reference - // Fill the object stack if needed - $cpfn =& $this->currentParser->filename; - if (!isset($this->_doneObjStack[$cpfn][$value[1]])) { - $this->_newobj(false, true); - $this->_objStack[$cpfn][$value[1]] = array($this->n, $value); + // An indirect object reference + // Fill the object stack if needed + $cpfn =& $this->currentParser->filename; + if (!isset($this->_doneObjStack[$cpfn][$value[1]])) { + $this->_newobj(false, true); + $this->_objStack[$cpfn][$value[1]] = array($this->n, $value); $this->_doneObjStack[$cpfn][$value[1]] = array($this->n, $value); } $objId = $this->_doneObjStack[$cpfn][$value[1]][0]; - $this->_out($objId . ' 0 R'); - break; + $this->_out($objId . ' 0 R'); + break; - case pdf_parser::TYPE_STRING: + case pdf_parser::TYPE_STRING: - // A string. + // A string. $this->_straightOut('(' . $value[1] . ')'); - break; + break; - case pdf_parser::TYPE_STREAM: + case pdf_parser::TYPE_STREAM: - // A stream. First, output the - // stream dictionary, then the - // stream data itself. + // A stream. First, output the + // stream dictionary, then the + // stream data itself. $this->_writeValue($value[1]); - $this->_out('stream'); - $this->_out($value[2][1]); - $this->_straightOut("endstream"); - break; - + $this->_out('stream'); + $this->_out($value[2][1]); + $this->_straightOut("endstream"); + break; + case pdf_parser::TYPE_HEX: $this->_straightOut('<' . $value[1] . '>'); break; case pdf_parser::TYPE_BOOLEAN: - $this->_straightOut($value[1] ? 'true ' : 'false '); - break; + $this->_straightOut($value[1] ? 'true ' : 'false '); + break; - case pdf_parser::TYPE_NULL: + case pdf_parser::TYPE_NULL: // The null object. - - $this->_straightOut('null '); - break; - } + $this->_straightOut('null '); + break; + } } @@ -629,32 +623,32 @@ class FPDI extends FPDF_TPL { if (!is_subclass_of($this, 'TCPDF')) { if ($this->state == 2) { - $this->pages[$this->page] .= $s; + $this->pages[$this->page] .= $s; } else { - $this->buffer .= $s; + $this->buffer .= $s; } } else { if ($this->state == 2) { - if ($this->inxobj) { - // we are inside an XObject template - $this->xobjects[$this->xobjid]['outdata'] .= $s; - } else if ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) { - // puts data before page footer - $pagebuff = $this->getPageBuffer($this->page); - $page = substr($pagebuff, 0, -$this->footerlen[$this->page]); - $footer = substr($pagebuff, -$this->footerlen[$this->page]); - $this->setPageBuffer($this->page, $page . $s . $footer); - // update footer position - $this->footerpos[$this->page] += strlen($s); - } else { - // set page data - $this->setPageBuffer($this->page, $s, true); - } - } else if ($this->state > 0) { - // set general data - $this->setBuffer($s); - } + if ($this->inxobj) { + // we are inside an XObject template + $this->xobjects[$this->xobjid]['outdata'] .= $s; + } else if ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) { + // puts data before page footer + $pagebuff = $this->getPageBuffer($this->page); + $page = substr($pagebuff, 0, -$this->footerlen[$this->page]); + $footer = substr($pagebuff, -$this->footerlen[$this->page]); + $this->setPageBuffer($this->page, $page . $s . $footer); + // update footer position + $this->footerpos[$this->page] += strlen($s); + } else { + // set page data + $this->setPageBuffer($this->page, $s, true); + } + } else if ($this->state > 0) { + // set general data + $this->setBuffer($s); + } } } @@ -677,7 +671,7 @@ class FPDI extends FPDF_TPL protected function _closeParsers() { if ($this->state > 2) { - $this->cleanUp(); + $this->cleanUp(); return true; } diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php b/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php index dc69d2e5d99..a7adb3d92ce 100644 --- a/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php +++ b/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php @@ -1,21 +1,12 @@ resolveObject($obj); + $obj = $this->resolveObject($obj); // If the current object has a resources - // dictionary associated with it, we use - // it. Otherwise, we move back to its - // parent object. + // dictionary associated with it, we use + // it. Otherwise, we move back to its + // parent object. if (isset($obj[1][1]['/Resources'])) { - $res = $this->resolveObject($obj[1][1]['/Resources']); - if ($res[0] == pdf_parser::TYPE_OBJECT) + $res = $this->resolveObject($obj[1][1]['/Resources']); + if ($res[0] == pdf_parser::TYPE_OBJECT) return $res[1]; return $res; - } + } if (!isset($obj[1][1]['/Parent'])) { return false; @@ -301,13 +292,13 @@ class fpdi_pdf_parser extends pdf_parser */ protected function _getPageRotation($obj) { - $obj = $this->resolveObject($obj); - if (isset($obj[1][1]['/Rotate'])) { - $res = $this->resolveObject($obj[1][1]['/Rotate']); - if ($res[0] == pdf_parser::TYPE_OBJECT) + $obj = $this->resolveObject($obj); + if (isset($obj[1][1]['/Rotate'])) { + $res = $this->resolveObject($obj[1][1]['/Rotate']); + if ($res[0] == pdf_parser::TYPE_OBJECT) return $res[1]; return $res; - } + } if (!isset($obj[1][1]['/Parent'])) { return false; @@ -330,7 +321,7 @@ class fpdi_pdf_parser extends pdf_parser protected function _readPages(&$pages, &$result) { // Get the kids dictionary - $_kids = $this->resolveObject($pages[1][1]['/Kids']); + $_kids = $this->resolveObject($pages[1][1]['/Kids']); if (!is_array($_kids)) { throw new Exception('Cannot find /Kids in current /Page-Dictionary'); @@ -343,14 +334,14 @@ class fpdi_pdf_parser extends pdf_parser $kids = $_kids[1]; foreach ($kids as $v) { - $pg = $this->resolveObject($v); + $pg = $this->resolveObject($v); if ($pg[1][1]['/Type'][1] === '/Pages') { // If one of the kids is an embedded - // /Pages array, resolve it as well. + // /Pages array, resolve it as well. $this->_readPages($pg, $result); - } else { - $result[] = $pg; - } - } + } else { + $result[] = $pg; + } + } } } \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/pdf_context.php b/mod/assign/feedback/editpdf/fpdi/pdf_context.php index aa78f64a827..474aa72e4a8 100644 --- a/mod/assign/feedback/editpdf/fpdi/pdf_context.php +++ b/mod/assign/feedback/editpdf/fpdi/pdf_context.php @@ -1,21 +1,12 @@ Date: Fri, 4 Dec 2015 20:12:49 +0800 Subject: [PATCH 2/2] MDL-52312 assignfeedback_editpdf: changes to files after FPDI update 1) Change the fpdi_bridge class so that it extends the pdf class, rather than the TCPDF class. 2) Updated the editpdf/fpdi/readme_moodle.txt file to document the changes. 3) Updated the editpdf/thirdpartylibs.xml to reflect the update to the FPDI library. --- mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php | 4 +++- mod/assign/feedback/editpdf/fpdi/readme_moodle.txt | 9 ++++++++- mod/assign/feedback/editpdf/thirdpartylibs.xml | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php b/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php index a7adb3d92ce..b2e43c41e71 100644 --- a/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php +++ b/mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php @@ -29,8 +29,10 @@ if (!class_exists('TCPDF', false)) { /** * Class fpdi_bridge + * + * This has been modified to use the Moodle pdf class which in turn extends the TCPDF class. */ - class fpdi_bridge extends TCPDF + class fpdi_bridge extends pdf { /** * Array of Tpl-Data diff --git a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt b/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt index bc1bae1be6a..7cac3bb2488 100644 --- a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt +++ b/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt @@ -10,7 +10,7 @@ Information URL: http://www.setasign.de/products/pdf-php-solutions/fpdi/ Download from: http://www.setasign.de/products/pdf-php-solutions/fpdi/downloads Documentation: http://www.setasign.de/products/pdf-php-solutions/fpdi/manuals/ -License: Apache Software License 2.0 +License: The MIT License (MIT) Installation ------------ @@ -19,6 +19,13 @@ Installation 3) Update mod/assign/feedback/editpdf/fpdi/fpdi_bridge.php (or the replacement file) to extend 'pdf' instead of 'TCPDF'. 4) Make a note below of any changes made. +2015/12/04 +---------- +Updated to FPDI: 1.6.1 + +1) Changed 'TCPDF' to 'pdf' (as stated above). +2) License changed from Apache Software License 2.0 to The MIT License (MIT). + 2015/10/01 ---------- Updated to FPDI: 1.5.4 diff --git a/mod/assign/feedback/editpdf/thirdpartylibs.xml b/mod/assign/feedback/editpdf/thirdpartylibs.xml index 5ce0dd6a5fb..cf10e9b1496 100644 --- a/mod/assign/feedback/editpdf/thirdpartylibs.xml +++ b/mod/assign/feedback/editpdf/thirdpartylibs.xml @@ -3,8 +3,8 @@ fpdi FPDI - Apache - 1.5.4 - 2.0 + MIT + 1.6.1 +