induwara.lk
induwara.lkDocuments · Privacy-first

JPG to PDF Converter

Combine your JPG, PNG, or WebP photos into one PDF — fully inside your browser, no signup, no upload. Pick page size, orientation, and margin; reorder pages with a tap. The PDF is built locally and downloads instantly. Sources cited.

By Induwara AshinsanaUpdated May 11, 2026
JPG to PDF ConverterIn-browser · no upload
Files stay on your device

Everything happens in your browser. Nothing is uploaded.

Page size
Orientation
Margin
Fit
Images queued
0
Pages in PDF
0
Input size
0 B
PDF size
Press Generate PDF to compute
Ready to convert

Add at least one image to get started.

Built against the ISO 32000-2 PDF 2.0 specification and ITU-T T.81 (JPEG). Cross-checked against the IRD-style two-formula pattern on 2026-05-11— full source list in the "Sources & references" section below.

How it works

A PDF is, in essence, a small text envelope wrapped around image and graphics streams. Embedding a JPEG is the easiest case in the whole specification — PDF's default user space is measured in points (1 point = 1/72 inch), and the format defines a native filter called DCTDecode that says “this stream is JPEG data, render it as an image” (ISO 32000-2 §7.4.5). That means a JPEG byte stream can be written into a PDF Image XObject with zero re-encoding. PNG and WebP do not have a direct PDF equivalent, so this tool transcodes them to JPEG in the browser canvas (92% quality) before embedding.

The PDF builder is hand-written and lives in lib/data/jpg-to-pdf.ts. Per image, three PDF objects are emitted: a Page node, a Contents stream, and an Image XObject. The Contents stream uses two PDF operators — cm (concatenate the current transformation matrix; encodes scale and position) and Do (invoke the named XObject). The image is intrinsically one unit wide and one unit tall in user space, so the cm matrix encodes both the on-page size in points and the bottom-left placement coordinate.

For each image the tool does five deterministic things:

  1. Validate the file. Confirms the image type (JPG / PNG / WebP), a non-zero size, and a per-image cap of 50.0 MB. JPEGs are checked for the literal 0xFFD8 SOI marker; PNG and WebP fall through to the canvas transcoder.
  2. Extract the natural size. For JPEGs, the Start-Of-Frame marker is parsed directly from the byte stream (ITU-T T.81 §B.2.2) — no decode required. For PNG and WebP, the canvas reports the natural width and height after the browser has decoded the image.
  3. Resolve the page size. One of 6standard page sizes, or “Fit to image” which makes each page exactly match the image at 72 DPI. Orientation can be Portrait, Landscape, or Auto — Auto picks the orientation closer to the image's aspect ratio.
  4. Solve the placement. The image is placed inside the page's content rectangle (the page minus margins) using the chosen fit mode. The math is cross-checked two ways: a scale-factor formula (min vs max of widthScale and heightScale) and an aspect-ratio formula (image ratio compared to content-rectangle ratio). The two agree to the millimetre.
  5. Assemble the PDF. Objects are written sequentially, byte offsets recorded as we go, then an xref table and trailer close the file. The resulting byte stream is wrapped in a Blob and offered as a download via an object URL. No bytes leave the browser tab.

Worked examples

Phone photo on portrait A4

A typical 4032 × 3024 phone JPEG placed on portrait A4 with a 15 mm margin, fit-contained.

  1. Image: 4,032 × 3,024 px
  2. Page: 210.0 × 297.0 mm (595 × 842 pt)
  3. Drawn at: 180.0 × 135.0 mm (510 × 383 pt)

Wide screenshot on auto-oriented A4

A 1920 × 1080 widescreen capture on A4 with auto orientation flips the page to landscape and contains the image inside a 6 mm margin.

  1. Image: 1,920 × 1,080 px
  2. Page: 297.0 × 210.0 mm (842 × 595 pt)
  3. Drawn at: 285.0 × 160.3 mm (808 × 454 pt)

Square scan with fit-to-image

A 2000 × 2000 square scan written with fit-to-image produces a page exactly 2000 × 2000 points and no margins.

  1. Image: 2,000 × 2,000 px
  2. Page: 705.6 × 705.6 mm (2,000 × 2,000 pt)
  3. Drawn at: 705.6 × 705.6 mm (2,000 × 2,000 pt)

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.