A Node.js utility that converts JPG images to PDFs and merges them into a single output file.
- Converts multiple JPG images to individual PDF files
- Automatically merges all generated PDFs into a single output file
- Preserves original image dimensions in PDF conversion
- Simple command-line interface
- Node.js (version 12 or higher)
- npm (Node Package Manager)
- Clone this repository
- Install dependencies:
npm install
Run the script with a directory path containing your JPG images:
node index.js /path/to/image/directory
The script will:
- Convert all JPG files in the specified directory to individual PDFs
- Merge all generated PDFs into a single file named
output.pdf
- Save the final PDF in the same directory as the input images
If you have a directory /photos
containing images:
- vacation1.jpg
- vacation2.jpg
- vacation3.jpg
Running:
node index.js /photos
Will generate:
- vacation1.pdf
- vacation2.pdf
- vacation3.pdf
- output.pdf (containing all images)
- pdf-lib: PDF creation and manipulation
- fs: File system operations
- path: Path manipulation
MIT