mirror of
https://github.com/moodle/moodle.git
synced 2025-03-17 22:20:00 +01:00
Merge branch 'MDL-71717' of git://github.com/paulholden/moodle
This commit is contained in:
commit
d9347556e3
@ -29,7 +29,7 @@ class Fpdi extends FpdfTpl
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const VERSION = '2.3.5';
|
||||
const VERSION = '2.3.6';
|
||||
|
||||
protected function _enddoc()
|
||||
{
|
||||
|
@ -334,43 +334,48 @@ trait FpdiTrait
|
||||
// try to use the existing content stream
|
||||
$pageDict = $page->getPageDictionary();
|
||||
|
||||
$contentsObject = PdfType::resolve(PdfDictionary::get($pageDict, 'Contents'), $reader->getParser(), true);
|
||||
$contents = PdfType::resolve($contentsObject, $reader->getParser());
|
||||
try {
|
||||
$contentsObject = PdfType::resolve(PdfDictionary::get($pageDict, 'Contents'), $reader->getParser(), true);
|
||||
$contents = PdfType::resolve($contentsObject, $reader->getParser());
|
||||
|
||||
// just copy the stream reference if it is only a single stream
|
||||
if (
|
||||
($contentsIsStream = ($contents instanceof PdfStream))
|
||||
|| ($contents instanceof PdfArray && \count($contents->value) === 1)
|
||||
) {
|
||||
if ($contentsIsStream) {
|
||||
/**
|
||||
* @var PdfIndirectObject $contentsObject
|
||||
*/
|
||||
$stream = $contents;
|
||||
// just copy the stream reference if it is only a single stream
|
||||
if (
|
||||
($contentsIsStream = ($contents instanceof PdfStream))
|
||||
|| ($contents instanceof PdfArray && \count($contents->value) === 1)
|
||||
) {
|
||||
if ($contentsIsStream) {
|
||||
/**
|
||||
* @var PdfIndirectObject $contentsObject
|
||||
*/
|
||||
$stream = $contents;
|
||||
} else {
|
||||
$stream = PdfType::resolve($contents->value[0], $reader->getParser());
|
||||
}
|
||||
|
||||
$filter = PdfDictionary::get($stream->value, 'Filter');
|
||||
if (!$filter instanceof PdfNull) {
|
||||
$dict->value['Filter'] = $filter;
|
||||
}
|
||||
$length = PdfType::resolve(PdfDictionary::get($stream->value, 'Length'), $reader->getParser());
|
||||
$dict->value['Length'] = $length;
|
||||
$stream->value = $dict;
|
||||
// otherwise extract it from the array and re-compress the whole stream
|
||||
} else {
|
||||
$stream = PdfType::resolve($contents->value[0], $reader->getParser());
|
||||
$streamContent = $this->compress
|
||||
? \gzcompress($page->getContentStream())
|
||||
: $page->getContentStream();
|
||||
|
||||
$dict->value['Length'] = PdfNumeric::create(\strlen($streamContent));
|
||||
if ($this->compress) {
|
||||
$dict->value['Filter'] = PdfName::create('FlateDecode');
|
||||
}
|
||||
|
||||
$stream = PdfStream::create($dict, $streamContent);
|
||||
}
|
||||
|
||||
$filter = PdfDictionary::get($stream->value, 'Filter');
|
||||
if (!$filter instanceof PdfNull) {
|
||||
$dict->value['Filter'] = $filter;
|
||||
}
|
||||
$length = PdfType::resolve(PdfDictionary::get($stream->value, 'Length'), $reader->getParser());
|
||||
$dict->value['Length'] = $length;
|
||||
$stream->value = $dict;
|
||||
|
||||
// otherwise extract it from the array and re-compress the whole stream
|
||||
} else {
|
||||
$streamContent = $this->compress
|
||||
? \gzcompress($page->getContentStream())
|
||||
: $page->getContentStream();
|
||||
|
||||
$dict->value['Length'] = PdfNumeric::create(\strlen($streamContent));
|
||||
if ($this->compress) {
|
||||
$dict->value['Filter'] = PdfName::create('FlateDecode');
|
||||
}
|
||||
|
||||
$stream = PdfStream::create($dict, $streamContent);
|
||||
// Catch faulty pages and use an empty content stream
|
||||
} catch (FpdiException $e) {
|
||||
$dict->value['Length'] = PdfNumeric::create(0);
|
||||
$stream = PdfStream::create($dict, '');
|
||||
}
|
||||
|
||||
$this->importedPages[$pageId] = [
|
||||
|
@ -42,7 +42,7 @@ class Fpdi extends \pdf
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const VERSION = '2.3.5';
|
||||
const VERSION = '2.3.6';
|
||||
|
||||
/**
|
||||
* A counter for template ids.
|
||||
|
@ -30,7 +30,7 @@ class Fpdi extends FpdfTpl
|
||||
*
|
||||
* @string
|
||||
*/
|
||||
const VERSION = '2.3.5';
|
||||
const VERSION = '2.3.6';
|
||||
|
||||
public function _enddoc()
|
||||
{
|
||||
|
@ -8,8 +8,7 @@
|
||||
* @license http://opensource.org/licenses/mit-license The MIT License
|
||||
*/
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
spl_autoload_register(function ($class) {
|
||||
spl_autoload_register(static function ($class) {
|
||||
if (strpos($class, 'setasign\Fpdi\\') === 0) {
|
||||
$filename = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 14)) . '.php';
|
||||
$fullpath = __DIR__ . DIRECTORY_SEPARATOR . $filename;
|
||||
|
@ -19,6 +19,12 @@ Installation
|
||||
3) Update mod/assign/feedback/editpdf/fpdi/Tcpdf/Fpdi.php(or whichever file it has been replaced with) to extend 'pdf' instead of 'TCPDF'.
|
||||
4) Make a note below of any changes made.
|
||||
|
||||
2021/05/26
|
||||
----------
|
||||
1/ Updated to 2.3.6
|
||||
|
||||
Updated by Paul Holden (MDL-71717)
|
||||
|
||||
2020/12/16
|
||||
----------
|
||||
1/ Updated to 2.3.5
|
||||
|
@ -4,7 +4,7 @@
|
||||
<location>fpdi</location>
|
||||
<name>FPDI</name>
|
||||
<license>MIT</license>
|
||||
<version>2.3.5</version>
|
||||
<version>2.3.6</version>
|
||||
<licenseversion></licenseversion>
|
||||
</library>
|
||||
</libraries>
|
||||
|
Loading…
x
Reference in New Issue
Block a user