Lines Matching +full:q +full:- +full:box

7  * @license   http://opensource.org/licenses/mit-license The MIT License
34 use /* This namespace/class is used by the commercial FPDI PDF-Parser add-on. */
101 $readers = $allReaders ? array_keys($this->readers) : $this->createdReaders;
103 $this->readers[$id]->getParser()->getStreamReader()->cleanUp();
104 unset($this->readers[$id]);
107 $this->createdReaders= [];
117 if (\version_compare($pdfVersion, $this->PDFVersion, '>')) {
118 $this->PDFVersion = $pdfVersion;
165 if (isset($this->readers[$id])) {
173 $this->createdReaders[] = $id;
178 $reader = new PdfReader($this->getPdfParserInstance($streamReader));
180 $this->readers[$id] = $reader;
193 if (isset($this->readers[$id])) {
194 return $this->readers[$id];
211 $this->currentReaderId = $this->getPdfReaderId($file);
212 $this->objectsToCopy[$this->currentReaderId] = [];
214 $reader = $this->getPdfReader($this->currentReaderId);
215 $this->setMinPdfVersion($reader->getPdfVersion());
217 return $reader->getPageCount();
224 * @param string $box The page boundary to import. Default set to PageBoundaries::CROP_BOX.
234 public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true) argument
236 if (null === $this->currentReaderId) {
240 $pageId = $this->currentReaderId;
246 $box = \ltrim($box, '/');
247 if (!PageBoundaries::isValidName($box)) {
249 \sprintf('Box name is invalid: "%s"', $box)
253 $pageId .= '|' . $box;
255 if (isset($this->importedPages[$pageId])) {
259 $reader = $this->getPdfReader($this->currentReaderId);
260 $page = $reader->getPage($pageNumber);
262 $bbox = $page->getBoundary($box);
265 \sprintf("Page doesn't have a boundary box (%s).", $box),
271 $dict->value['Type'] = PdfName::create('XObject');
272 $dict->value['Subtype'] = PdfName::create('Form');
273 $dict->value['FormType'] = PdfNumeric::create(1);
274 $dict->value['BBox'] = $bbox->toPdfArray();
277 $this->setMinPdfVersion('1.4');
278 $dict->value['Group'] = PdfDictionary::create([
284 $resources = $page->getAttribute('Resources');
286 $dict->value['Resources'] = $resources;
289 list($width, $height) = $page->getWidthAndHeight($box);
295 $e = -$bbox->getLlx();
296 $f = -$bbox->getLly();
298 $rotation = $page->getRotation();
301 $rotation *= -1;
305 $c = -$b;
309 case -90:
310 $e = -$bbox->getLly();
311 $f = $bbox->getUrx();
313 case -180:
314 $e = $bbox->getUrx();
315 $f = $bbox->getUry();
317 case -270:
318 $e = $bbox->getUry();
319 $f = -$bbox->getLlx();
326 $dict->value['Matrix'] = PdfArray::create([
333 $pageDict = $page->getPageDictionary();
335 …$contentsObject = PdfType::resolve(PdfDictionary::get($pageDict, 'Contents'), $reader->getParser()…
336 $contents = PdfType::resolve($contentsObject, $reader->getParser());
340 || ($contents instanceof PdfArray && \count($contents->value) === 1)
348 $stream = PdfType::resolve($contents->value[0], $reader->getParser());
351 $filter = PdfDictionary::get($stream->value, 'Filter');
353 $dict->value['Filter'] = $filter;
355 … $length = PdfType::resolve(PdfDictionary::get($stream->value, 'Length'), $reader->getParser());
356 $dict->value['Length'] = $length;
357 $stream->value = $dict;
359 // otherwise extract it from the array and re-compress the whole stream
361 $streamContent = $this->compress
362 ? \gzcompress($page->getContentStream())
363 : $page->getContentStream();
365 $dict->value['Length'] = PdfNumeric::create(\strlen($streamContent));
366 if ($this->compress) {
367 $dict->value['Filter'] = PdfName::create('FlateDecode');
373 $this->importedPages[$pageId] = [
375 'readerId' => $this->currentReaderId,
376 'id' => 'TPL' . $this->getNextTemplateId(),
377 'width' => $width / $this->k,
378 'height' => $height / $this->k,
392 …* @param float|int|array $x The abscissa of upper-left corner. Alternatively you could use an asso…
394 * @param float|int $y The ordinate of upper-left corner.
413 if (!isset($this->importedPages[$pageId])) {
417 $importedPage = $this->importedPages[$pageId];
419 $originalSize = $this->getTemplateSize($pageId);
420 $newSize = $this->getTemplateSize($pageId, $width, $height);
422 $this->setPageFormat($newSize, $newSize['orientation']);
425 $this->_out(
428 'q 0 J 1 w 0 j 0 G 0 g %.4F 0 0 %.4F %.4F %.4F cm /%s Do Q',
431 $x * $this->k,
432 ($this->h - $y - $newSize['height']) * $this->k,
453 if (isset($this->importedPages[$tpl])) {
454 $importedPage = $this->importedPages[$tpl];
492 if (\is_int($value->value)) {
493 $this->_put($value->value . ' ', false);
495 $this->_put(\rtrim(\rtrim(\sprintf('%.5F', $value->value), '0'), '.') . ' ', false);
499 $this->_put('/' . $value->value . ' ', false);
502 $this->_put('(' . $value->value . ')', false);
505 $this->_put('<' . $value->value . '>');
508 $this->_put($value->value ? 'true ' : 'false ', false);
511 $this->_put('[', false);
512 foreach ($value->value as $entry) {
513 $this->writePdfType($entry);
515 $this->_put(']');
518 $this->_put('<<', false);
519 foreach ($value->value as $name => $entry) {
520 $this->_put('/' . $name . ' ', false);
521 $this->writePdfType($entry);
523 $this->_put('>>');
526 $this->_put($value->value);
529 $this->_put('null ');
535 $this->writePdfType($value->value);
536 $this->_put('stream');
537 $this->_put($value->getStream());
538 $this->_put('endstream');
541 if (!isset($this->objectMap[$this->currentReaderId])) {
542 $this->objectMap[$this->currentReaderId] = [];
545 if (!isset($this->objectMap[$this->currentReaderId][$value->value])) {
546 $this->objectMap[$this->currentReaderId][$value->value] = ++$this->n;
547 $this->objectsToCopy[$this->currentReaderId][] = $value->value;
550 $this->_put($this->objectMap[$this->currentReaderId][$value->value] . ' 0 R ', false);
556 $n = $this->objectMap[$this->currentReaderId][$value->objectNumber];
557 $this->_newobj($n);
558 $this->writePdfType($value->value);
559 $this->_put('endobj');