Skip to content

Instantly share code, notes, and snippets.

@azettl
Created October 9, 2018 19:24
Show Gist options
  • Save azettl/6b4b5cace5288081b92cd3ac550028b3 to your computer and use it in GitHub Desktop.
Save azettl/6b4b5cace5288081b92cd3ac550028b3 to your computer and use it in GitHub Desktop.
Get the Bookmarks from a PDF
<?php
$sPdfContent = file_get_contents("filename.pdf");
$sRegexPattern = "/R\/[A-Za-z0-9\s\/\[\.\]]*\/Title\(([A-Za-z0-9\.\s\:]*)\)[\/Prev|>>]/";
preg_match_all($sRegexPattern, $sPdfContent, $aBookmarkMatches);
$aBookmarkTitles = $aBookmarkMatches[1];
foreach($aBookmarkTitles as $sBookmarkTitle) {
echo $sBookmarkTitle . '<br />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment