Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image PDF Maker

Generate a print-ready PDF from a folder of images.

The tool automatically:

  • Reads all images from the images folder
  • Scales every image to 5.5 cm wide
  • Preserves the original aspect ratio
  • Arranges images across A4 pages
  • Creates new rows automatically
  • Creates new pages automatically
  • Exports a single PDF ready for printing

Requirements

  • Node.js 18+
  • npm

Installation

Install dependencies:

npm install pdfkit sharp

Project Structure

image-pdfmaker/
│
├── images/
│   ├── image1.jpg
│   ├── image2.png
│   ├── image3.jpeg
│   └── ...
│
├── index.cjs
├── package.json
└── README.md

Place all images you want to print inside the images folder.


Configuration

Open index.cjs and adjust these values if needed:

const PAGE_SIZE = "A4";
const MARGIN_MM = 10;
const GAP_MM = 3;
const IMAGE_WIDTH_CM = 5.5;

Options

Setting Description
PAGE_SIZE Paper size (A4, Letter, etc.)
MARGIN_MM Page margin in millimeters
GAP_MM Gap between images in millimeters
IMAGE_WIDTH_CM Width of each image in centimeters

Usage

Generate the PDF:

node index.cjs

After completion:

output.pdf

will be created in the project root.


Example

Input:

images/
├── photo1.jpg
├── photo2.jpg
├── photo3.jpg
└── photo4.jpg

Output:

output.pdf

Images will be arranged automatically across one or more A4 sheets.


Supported Formats

  • JPG
  • JPEG
  • PNG
  • WEBP

Features

✅ Fixed image width (5.5 cm)

✅ Aspect ratio preserved

✅ Automatic row wrapping

✅ Automatic page creation

✅ A4 print layout

✅ Multiple page support

✅ Works with portrait and landscape images


Troubleshooting

No images found

Make sure images are placed inside:

./images

PDF is empty

Verify that the images are valid JPG, PNG, JPEG, or WEBP files.

Sharp installation issues

Reinstall dependencies:

rm -rf node_modules package-lock.json
npm install

License

MIT

About

An Images Folder to Printable PDF Maker

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages