0

I have a directory of jpg files that are scans of my handwritten notes. How do I convert them to a single pdf file that has the filenames as bookmarks?

(I eventually also want to add ocr. As mentioned online, we can convert the .jpg files to a .pdf using img2pdf .jp --output combined.pdf, and then we can add ocr using ocrmypdf combined.pdf combined_ocr.pdf. My question is mainly about how to also make sure the pdf file has bookmarks (created from filenames) so that the document is easy to navigate.)

jm jm
  • 1

1 Answers1

0

ImageMagick convert can convert jpg images to a pdf file.

convert *.jpg document.pdf

It may happen that ImageMagick will refuse to do it with a message like this

convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.

In that case, use advice from here: https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion

ImageMagick will make a pdf without bookmarks. You will have to add them with the help of this answers https://stackoverflow.com/questions/30304718/create-bookmarks-into-a-pdf-file-via-command-line.

If you make a script that will sort jpg files (one per page), you will know which jpg is on each page. First, you will have to specifiy each jpeg file

convert a.jpg b.jpg ... z.jpg output.pdf

Then you will set a bookmark a.jpg to the first page, b.jpg to the second, and so on. In that way, you should be able to add bookmarks, too.

I guess you have some scripting/programming to do, but I am positive that it can be done.

nobody
  • 1,710