This repository is outdated. Please use node package /mooz/node-pdf-image as solution. This feature is integrated there.
Even if there are no further plans with this repo, this script is still working and might be a good reference for your project.
This is a small and simple bash script which convert a single pdf document to a single png file. So whats the secret? This script supports multipage PDF documents and convert them to a single png file.
This script is for you if you have multipage or singlepage pdf documents and need to batch convert them to png. You can run on a full folder with pdf files and convert them all with a single command.
It's written and tested on a mac but should be compatible for linux, too
- pdfseparate - (
brew install poppler
will also installpdfseparate
) - imagemagick convert - download
- pdfseparate splits the pdf file
- imagemagick convert it to png combine it back and crop existing whitespace
- Put that .sh in a folder with some pdf files.
- Run
chmod +x pdfToSinglePng.sh
- Run
./pdfToSinglePng.sh
.png files will be created beside .pdf files with the same filename each pdf page goes vertically upon the other with a spacing between each page. Headers repeating every page.
no repo without demo: readme_demo.pdf converted to readme_demo.png
- check out this repo
- delete readme_demo.png
- run script