I appreciated the constructive feedback you provided. Your process-oriented consultation helped me see gaps in my logic. Your consultation provided me a greater sense of security in our finished product.




Blazing a trail to better facilities management.

Split PDF into pages, by bookmark

You've got a PDF with bookmarks. You want one PDF file per book mark. Here's a quick way to accomplish that.

pdftk example.pdf dump_data | perl -e 'undef $/; $_=<>; while (/BookmarkTitle: (.*)\nBookmarkLevel: (\d+)\nBookmarkPageNumber: (\d+)/mg) { print "pdftk example.pdf cat $3 output \"$1.pdf\"\n"; }'

Replace "example.pdf" with the name of your original PDF.  That will create a series of command lines, which you can then run to do the extraction, for example:

pdftk example.pdf cat 1 output "Introduction.pdf"
pdftk example.pdf cat 1 output "Getting Started.pdf"
pdftk example.pdf cat 1 output "Printing a test page.pdf"
pdftk example.pdf cat 5 output "Creating PDF Files.pdf"
Because multiple bookmarks may exist on a single page, you might have one page appear many times, each with a different name.  In the example output, page 1 gets split into three files ("Introduction", "Getting Started", and "Printing a test page") because page 1 has 3 bookmarks on it.
You will need the extremely-excellent PDF Toolkit to get this work done.

Trackback URL for this post:


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Enter the characters shown in the image.