The Engineering Guide to Client-Side Image to PDF Conversion and Target Size Optimization
Converting image collections into standardized PDF documents is a daily requirement across business, education, and government registration workflows. Standard online tools introduce privacy risks by transmitting user images to remote cloud servers, enforce rigid subscriptions, and often fail on mobile devices due to mismatched binary headers. PrivaUtils eliminates these limitations by executing the entire image processing and PDF assembly pipeline strictly inside your local browser runtime.
Target Size Budgeting Engine (Under 100 KB & 200 KB)
Portals for university admissions, civil service exams (UPSC, SSC), visa applications, and state job portals strictly enforce maximum file sizes, typically 100 KB or 200 KB. Submitting a file even one byte over the threshold causes immediate rejection.
PrivaUtils handles this with an iterative budgeting algorithm. It reserves approximately 4 KB for the PDF document catalog, xref table, and page dictionaries, then divides the remaining byte allowance evenly across the input images. Each image is dynamically downsampled in resolution and adjusted in compression quality until the aggregate binary payload is guaranteed to fall below your target threshold.
Resolving the iPhone SOI Not Found in JPEG Error
When uploading photos from iOS devices, files frequently arrive in High Efficiency Image Container (HEIC) format or contain non-standard EXIF headers. Standard PDF embedding engines require the standard JPEG Start of Image marker (0xFF, 0xD8). When an image does not start with these exact bytes, the engine aborts with an "SOI not found in JPEG" exception.
PrivaUtils resolves this by routing all input files through an internal HTML5 canvas normalizer. The browser decodes the image source, corrects EXIF orientation, applies any selected document scan filter, and re-encodes the buffer into clean JPEG or PNG bytes with verified binary headers before handing the data to the PDF worker.
Page Geometry, Aspect Ratio Preservation, and Margins
Standard paper formats have fixed aspect ratios: international A4 (1:1.414) and North American US Letter (1:1.294). Photos and camera captures rarely match these proportions. PrivaUtils provides two distinct rendering approaches:
Each PDF page adopts the exact pixel dimensions and aspect ratio of its image. No white bars or letterboxing borders are added.
Images are scaled proportionally to fit within the chosen page dimensions, preserving aspect ratio without distortion.
Horizontal images receive landscape pages, while vertical captures receive portrait pages, avoiding unnecessary white space.
Zero-Knowledge Architecture for Sensitive Documents
Photos converted to PDF often contain confidential information: identity cards, passports, driver licenses, financial invoices, medical records, and legal contracts. When utilizing remote online conversion tools, your confidential files are transmitted across third-party networks and temporarily stored on unknown cloud servers.
PrivaUtils eliminates third-party data exposure completely. All image decoding, resampling, filtering, and PDF compilation take place within your browser memory environment. Once you close the tab, the in-memory data structures are reclaimed by the garbage collector. No files are ever uploaded to any server.

