forked from Setasign/FPDI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Setasign#196 from Setasign/indirect-references-in-…
…annotation-dictionaries Handle indirect references in annotation dictionaries
- Loading branch information
Showing
7 changed files
with
120 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* A simple helper script to modify links.pdf in view to indirect references in annotation dictionaries. | ||
* We used SetaPDF-Core for doing such low-level modifications. | ||
*/ | ||
|
||
require_once __DIR__ . '/../../../../../SetaPDF/library/SetaPDF/Autoload.php'; | ||
|
||
$writer = new SetaPDF_Core_Writer_File('links-with-indirect-references.pdf'); | ||
$document = SetaPDF_Core_Document::loadByFilename('links.pdf', $writer); | ||
|
||
$pages = $document->getCatalog()->getPages(); | ||
$page = $pages->getPage(1); | ||
|
||
$annotations = $page->getAnnotations(); | ||
$allAnnots = $annotations->getAll(); | ||
|
||
$dict = $allAnnots[0]->getDictionary(); | ||
$bs = $dict->getValue('BS'); | ||
$d = $bs->getValue('D'); | ||
$bs->offsetSet('D', $document->createNewObject($d)); | ||
$dict->offsetSet('BS', $document->createNewObject($bs)); | ||
|
||
$dict = $allAnnots[1]->getDictionary(); | ||
$c = $dict->getValue('C'); | ||
$object = $document->createNewObject($c); | ||
$ref = new SetaPDF_Core_Type_IndirectReference($object, 0, $document); | ||
$dict->offsetSet('C', $document->createNewObject($ref)); | ||
|
||
|
||
$dict = $allAnnots[5]->getDictionary(); | ||
$border = $dict->getValue('Border'); | ||
$dict->offsetSet('Border', $document->createNewObject($border)); | ||
|
||
$page = $pages->getPage(2); | ||
$annotations = $page->getAnnotations(); | ||
$allAnnots = $annotations->getAll(); | ||
|
||
$dict = $allAnnots[0]->getDictionary(); | ||
$rect = $dict->getValue('Rect'); | ||
$dict->offsetSet('Rect', $document->createNewObject($rect)); | ||
|
||
$document->save()->finish(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters