PDF Bookmarks to individual file names

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Argyle
Posts: 2
Joined: 2019-07-23T13:17:14-07:00
Authentication code: 1152

PDF Bookmarks to individual file names

Post by Argyle »

I’m splitting multi page PDF files into individual PNG images. Each png is a page from the file.

I’d love to be able to name my png’s according to the bookmark name of the pdf page they were converted from.

Is it possible?

User avatar
fmw42
Posts: 25971
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF Bookmarks to individual file names

Post by fmw42 »

Imagemagick cannot read PDF bookmarks. But you can number the pages.


Just use _%02d appended to the filename. This will work for up to 99 pages. If you want more, then use _%03d.

Here I start the scene numbering at 01 rather than 00.

First I create a simply PDF file:

Code: Select all

convert lena.jpg lena.jpg lena.jpg lena.pdf
Now I separate the pages

Code: Select all

convert lena.pdf -scene 1 lena_%02d.png
The result is 3 files:

Code: Select all

lena_01.png
lena_02.png
lena_03.png

Argyle
Posts: 2
Joined: 2019-07-23T13:17:14-07:00
Authentication code: 1152

Re: PDF Bookmarks to individual file names

Post by Argyle »

Unfortunately appending the file names doesn’t help my situation. The PDF bookmarks contain order numbers. I’d like to name my PNG files according to those order numbers.

Acrobat will let me split the pdf into individual pages & use the bookmark as the file name. I can then convert the entire folder to PNG. It’s a longer less organized process but it gets the job done.

246246
Posts: 194
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: PDF Bookmarks to individual file names

Post by 246246 »

You need some programming using some library that can handle PDF bookmark, for example Apache PDFBox in Java.
Following page would be your help: https://memorynotfound.com/apache-pdfbo ... f-example/
You can also split it to single page pdf files in it, so then write a script that convert to png using ImageMagick.

Post Reply