diff --git a/VERSION b/VERSION index a2cec7a..7919852 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.8 +4.0.9 diff --git a/src/Page.php b/src/Page.php index b1e10d3..536a2a1 100644 --- a/src/Page.php +++ b/src/Page.php @@ -158,6 +158,11 @@ public function getPages(): array public function addAnnotRef(int $oid, int $pid = -1): void { $pid = $this->sanitizePageID($pid); + + if (in_array($oid, $this->page[$pid]['annotrefs'])) { + return; + } + $this->page[$pid]['annotrefs'][] = $oid; } @@ -315,7 +320,7 @@ protected function getPageTransition(array $page): string } } - return $out . ('>>' . "\n"); + return $out . '>>' . "\n"; } /** @@ -332,11 +337,12 @@ protected function getAnnotationRef(array $page): string } $out = '/Annots [ '; + sort($page['annotrefs']); foreach ($page['annotrefs'] as $val) { $out .= (int) $val . ' 0 R '; } - return $out . (']' . "\n"); + return $out . ']' . "\n"; } /** @@ -360,12 +366,12 @@ protected function getPageContentObj(int &$pon, string $content = ''): string } $stream = $this->enc->encryptString($content, $pon); - return $out . (' /Length ' . strlen($stream) + return $out . ' /Length ' . strlen($stream) . ' >>' . "\n" . 'stream' . "\n" . $stream . "\n" . 'endstream' . "\n" - . 'endobj' . "\n"); + . 'endobj' . "\n"; } /** @@ -387,8 +393,8 @@ protected function getPageRootObj(int &$pon): string $out .= $this->page[$pid]['n'] . ' 0 R '; } - return $out . ('] /Count ' . $numpages . ' >>' . "\n" - . 'endobj' . "\n"); + return $out . '] /Count ' . $numpages . ' >>' . "\n" + . 'endobj' . "\n"; } /**