PNG to PDF Converter

Hand-builds a real, valid single-page PDF around your PNG: a DeviceRGB Image XObject compressed with the browser's native deflate implementation, plus a DeviceGray SMask object so transparency survives, with a byte-exact cross-reference table so the file opens correctly in any real PDF reader. Runs entirely client-side. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool converts a PNG into a real, minimal single-page PDF, hand-assembling the actual PDF object structure — catalog, page tree, image XObject, content stream, and cross-reference table — rather than relying on any PDF-generation library.

It specifically embeds an alpha-carrying SMask object, so transparent PNGs stay transparent when placed into other documents or viewed with a PDF reader that respects soft masks.

What Is PNG to PDF Converter?

A client-side PDF encoder that writes six PDF objects (Catalog, Pages, Page, Image XObject, SMask XObject, Content stream), each deflate-compressed where required, followed by a byte-exact xref table computed by tracking the file's running byte offset as it's built.

The result is a real, spec-compliant PDF file — not an image renamed with a .pdf extension.

How PNG to PDF Converter Works

Pixel data is split into an RGB stream and a separate single-channel alpha stream, each compressed independently with the browser's native CompressionStream('deflate') API, which produces the zlib-wrapped output PDF's /FlateDecode filter expects.

A content stream then paints the image XObject scaled to exactly fill the page's MediaBox, and every object's byte offset is recorded as the file is written so the final xref table points to the exact right locations — the detail that actually makes a hand-written PDF valid.

When To Use PNG to PDF Converter

Use it when you need a single image delivered as a PDF — for print submission, document attachment, or any workflow that specifically requires PDF over a raw image format.

It's also useful for producing a small, dependency-free test PDF with a known, exact embedded image for testing a PDF-reading pipeline.

Features

Advantages

  • Runs entirely client-side, including compression, via the Web Streams API; your image is never uploaded to a server.
  • Preserves the full alpha channel through a proper PDF SMask, not a flattened background.
  • Produces a byte-exact, real cross-reference table, so the output is a genuinely valid PDF that real readers open correctly.

Limitations

  • Only single-image, single-page output is supported — there's no text, multiple pages, or other PDF content beyond the one embedded image.
  • This relies on the browser's native CompressionStream API for deflate compression; it isn't available in extremely old browsers (all evergreen browsers since roughly 2021 support it).

Examples

Convert a transparent logo

Input

A 300x300 PNG logo with a transparent background

Output

A one-page PDF with the logo rendered with real transparency via an SMask

The SMask object's grayscale alpha data tells PDF readers exactly which pixels to render as translucent.

Convert an opaque photo

Input

A 1200x800 opaque PNG photo

Output

A compact single-page PDF, deflate-compressed

Deflate compression typically shrinks the embedded RGB stream well below its raw width x height x 3 byte size.

Best Practices & Notes

Best Practices

  • Use this when a workflow specifically needs PDF; for general sharing, PNG remains simpler and often smaller.
  • Pair with PDF to PNG Converter to confirm a generated PDF round-trips back to the exact original pixels before relying on it downstream.

Developer Notes

The PDF is assembled with a small internal byte-writer class that tracks a running offset as text and binary chunks are appended, so every object's exact starting offset is known when the xref table is written at the end — this is the detail a naive string-concatenation approach gets wrong and that makes many hand-rolled PDFs fail to open.

PNG to PDF Converter Use Cases

  • Submitting a single image as a PDF for print or document workflows that require that format
  • Embedding a transparent graphic into a PDF via a real SMask instead of flattening it onto a background
  • Generating a small, known-exact test PDF for a PDF-parsing pipeline

Common Mistakes

  • Assuming this produces a general-purpose PDF editor's output — it writes exactly one image on exactly one page, nothing more.
  • Forgetting that very old browsers without CompressionStream support won't be able to run this converter.

Tips

  • If you need multiple images in one PDF, convert each individually and merge with dedicated PDF-merging software.
  • Check the SMask is preserved by viewing the PDF over a colored background in your PDF reader — transparent areas should show the background through.

References

Frequently Asked Questions