Convert Images to PDF with pdf-lib — On-Device Processing
Converting photos, receipts, or scanned documents into a single PDF document is one of the most common tasks for work, school, and admin applications. PDFBucket's Image to PDF Converter runs entirely inside your browser using pdf-lib (v1.17+) and the native HTML5 Canvas API.Unlike traditional cloud converters that require uploading your private photos to a remote server, PDFBucket decodes and embeds your images locally in browser memory — preserving full privacy while generating crisp PDF documents in milliseconds.
How Image to PDF Conversion Works Under the Hood
PDF files treat images as binary stream objects embedded within page dictionaries. When you convert an image to PDF:- Format Handling: For JPEG/JPG images,
pdf-libembeds the raw compressed DCT bytes directly without re-compression (pdfDoc.embedJpg), maintaining 100% original image quality. - Alpha & WebP Conversion: For WebP or non-standard formats, the browser's Canvas API draws the pixels into a PNG buffer before embedding (
pdfDoc.embedPng). - Page Geometry: You can select Native Size (creates PDF pages matched exactly to pixel dimensions) or Standard A4 (scales and centers images nicely within standard margins).
- Page Assembly:
pdf-libconstructs page objects, builds the cross-reference table, and outputs a clean PDF 1.7 binary file.
Practical Use Cases
Submitting Scanned Documents & Receipts: Combine multiple scanned photos or receipts into a single organized PDF file for expense reports or tax filing.Creating Portfolios & Presentational PDFs: Merge design mockups or photo galleries into a single deliverable PDF document.
School & Job Applications: Combine ID cards, certificate photos, and transcripts into one file.