Skip to content

Commit

Permalink
Avoid duplicate annotrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 13, 2024
1 parent 9f42eb7 commit 7fe0cc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.8
4.0.9
18 changes: 12 additions & 6 deletions src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -315,7 +320,7 @@ protected function getPageTransition(array $page): string
}
}

return $out . ('>>' . "\n");
return $out . '>>' . "\n";
}

/**
Expand All @@ -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";
}

/**
Expand All @@ -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";
}

/**
Expand All @@ -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";
}

/**
Expand Down

0 comments on commit 7fe0cc8

Please sign in to comment.