/** * Writes the page contents and definition to the writer. * * @param ObjectWriter $objectWriter * @param int $pageTreeId * @return int */ public function writePage(ObjectWriter $objectWriter, $pageTreeId) { $objectWriter->startObject($this->pageId); $objectWriter->startDictionary(); $objectWriter->writeName('Type'); $objectWriter->writeName('Page'); $objectWriter->writeName('Parent'); $objectWriter->writeIndirectReference($pageTreeId); $objectWriter->writeName('Resources'); $objectWriter->startDictionary(); $objectWriter->endDictionary(); $objectWriter->writeName('Contents'); $objectWriter->startArray(); $objectWriter->endArray(); foreach ($this->boxes as $name => $box) { $objectWriter->writeName($name); $box->writeRectangleArray($objectWriter); } if (null !== $this->rotation) { $objectWriter->writeName('Rotate'); $objectWriter->writeNumber($this->rotation); } $objectWriter->endDictionary(); $objectWriter->endObject(); return $this->pageId; }
/** * Writes the trailer. */ private function writeTrailer() { $this->objectWriter->ensureBlankLine(); $this->objectWriter->writeRawLine('trailer'); $this->objectWriter->startDictionary(); $this->objectWriter->writeName('Id'); $this->objectWriter->startArray(); $this->objectWriter->writeHexadecimalString($this->permanentFileIdentifier); $this->objectWriter->writeHexadecimalString($this->changingFileIdentifier); $this->objectWriter->endArray(); if (null !== $this->encryption) { $this->objectWriter->writeName('Encrypt'); $this->encryption->writeEncryptDictionary($this->objectWriter); } $this->objectWriter->endDictionary(); }
/** * {@inheritdoc} */ public function writeEncryptDictionary(ObjectWriter $objectWriter) { $objectWriter->startDictionary(); $objectWriter->writeName('Filter'); $objectWriter->writeName('Standard'); $objectWriter->writeName('V'); $objectWriter->writeNumber($this->getAlgorithm()); $objectWriter->writeName('R'); $objectWriter->writeNumber($this->getRevision()); $objectWriter->writeName('O'); $objectWriter->writeNumber($this->ownerEntry); $objectWriter->writeName('U'); $objectWriter->writeNumber($this->userEntry); $objectWriter->writeName('P'); if (null === $this->userPermissions) { $objectWriter->writeNumber(0); } else { $objectWriter->writeNumber($this->userPermissions->toInt($this->getRevision())); } $this->writeAdditionalEncryptDictionaryEntries($objectWriter); $objectWriter->endDictionary(); }
public function testStartDictionary() { $this->objectWriter->startDictionary(); $this->assertSame('<<', $this->getFileObjectData()); }
/** * Creates a shadow mask from an image's alpha channel. * * @param ObjectWriter $objectWriter * @param Imagick $image * @param string $filter * @return int */ private function createShadowMask(ObjectWriter $objectWriter, Imagick $image, $filter) { $shadowMask = clone $image; $shadowMask->separateImageChannel(Imagick::CHANNEL_ALPHA); if ('FlateDecode' === $filter) { $image->setImageFormat('GRAY'); } $streamData = $shadowMask->getImageBlob(); $shadowMask->clear(); $id = $objectWriter->startObject(); $objectWriter->startDictionary(); $this->writeCommonDictionaryEntries($objectWriter, 'DeviceGray', strlen($streamData), $filter); $objectWriter->endDictionary(); $objectWriter->startStream(); $objectWriter->writeRaw($streamData); $objectWriter->endStream(); $objectWriter->endObject(); return $id; }
/** * Writes the info dictionary. * * @param ObjectWriter $objectWriter * @internal */ public function writeInfoDictionary(ObjectWriter $objectWriter) { $objectWriter->startDictionary(); foreach ($this->data as $key => $value) { $objectWriter->writeName($key); switch ($key) { case 'CreationDate': case 'ModDate': $objectWriter->writeLiteralString(StringUtils::formatDateTime($value)); break; case 'Trapped': $objectWriter->writeName($value); break; default: $objectWriter->writeLiteralString(StringUtils::encodeString($value)); } } $objectWriter->endDictionary(); }
/** * @iterations 10000 */ public function startDictionary() { $this->objectWriter->startDictionary(); }