npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gingersnapsoftware/capacitor-plugin-printer

v0.0.15

Published

Capacitor plugin for printing HTML, PDF, image, base64, and file-path content from iOS/Android apps.

Readme

Printer.print({ content: '<b>Lorem ipsum...</b>' })

Versions

| Capacitor Version | Plugin Version | | ----------------- | -------------- | | v5.x | v0.0.3 | | v6.x | v0.0.4 – 0.0.11 | | v7.x | v0.0.13+ |

Supported Platforms

  • Android 5.1+
  • iOS 13+

Supported Content

  • HTML (with inline CSS)
  • Plain text
  • Images (passed as HTML <img> or as Base64 / file path)
  • Base64-encoded PDFs and images (auto-detected from base64: prefix or data: URI)
  • Local PDFs and images via a filesystem path (contentType: 'path')

Installation

npm install @gingersnapsoftware/capacitor-plugin-printer
npx cap sync

Usage

import { Printer } from '@gingersnapsoftware/capacitor-plugin-printer';

await Printer.print({
  content: 'Lorem ipsum...',
  name: 'lorem-filename',
  orientation: 'landscape',
});

Examples

Plain text

Printer.print({ content: 'Lorem ipsum...' });

HTML

Printer.print({ content: '<h1>Lorem</h1>' });

HTML with multiple elements

let body = '';
body += '<li style="color:green">Tea</li>';
body += '<li style="font-size:50px">Coffee</li>';
body += '<img src="https://picsum.photos/200">';

Printer.print({ content: body });

Inline CSS

Printer.print({ content: '<b style="color:red">Lorem ipsum</b>' });

Base64 PDF or image (auto-detected, no contentType required)

// "base64:" prefix
Printer.print({ content: 'base64:JVBERi0xLjQK...' });

// or a full data URI
Printer.print({ content: 'data:application/pdf;base64,JVBERi0xLjQK...' });

Local file path (PDF or image) — useful when the file was just downloaded or generated via @capacitor/filesystem:

import { Filesystem, Directory } from '@capacitor/filesystem';

const writeResult = await Filesystem.writeFile({
  path: 'ticket.pdf',
  data: base64Pdf,           // base64-encoded PDF bytes
  directory: Directory.Cache,
});

// writeResult.uri is a "file://" URI; the plugin strips the prefix automatically
await Printer.print({
  content: writeResult.uri,
  name: 'ticket',
  orientation: 'portrait',
  contentType: 'path',
});

Notes on contentType: 'path':

  • Accepts both file:///absolute/path/to/file.pdf and /absolute/path/to/file.pdf.
  • PDFs are printed directly. Images are wrapped into a single-page PDF on the fly.
  • Unsupported file types reject the promise with a descriptive error.

Why prefer contentType: 'path' over Base64

Base64 embeds the entire document in the JavaScript string passed across the Capacitor bridge, which means the same bytes can briefly live in memory three times at once (the JS string, the decoded native buffer, and the print-system copy). On large or image-heavy PDFs this can spike RSS by tens of megabytes per print.

This matters more on recent iOS releases: the OS has become more aggressive about killing background or memory-pressured apps mid-print. A print that works in development can be silently terminated on a real device once total memory crosses the per-app limit. Symptoms are usually one of:

  • The print sheet opens, then the app crashes or is forcibly backgrounded.
  • The print job appears to send but never reaches the printer.
  • An OOM jetsam log entry in Console.app referencing your app right after Printer.print was called.

Using contentType: 'path' avoids this entirely: only the file path is sent across the bridge, the file is streamed by the OS printing service directly from disk, and your app's JS heap stays flat. For anything larger than a small text receipt — and for all PDFs produced by @capacitor/filesystem, downloads, or PDF generators — write the bytes to a file once and pass the path.

API

print(...)

print(printOptions: PrintOptions) => Promise<void>

| Param | Type | | ------------------ | ----------------------------------------------------- | | printOptions | PrintOptions |


Interfaces

PrintOptions

| Prop | Type | Description | Default | Since | | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- | ----- | | content | string | Content to print. Interpreted according to {@link PrintOptions.contentType}. | | 0.0.1 | | name | string | Name of the print job / document. | iOS=YourAppName/Android=Document+CurrentTimestamp | 0.0.1 | | orientation | string | Orientation of the printing page. "portrait" or "landscape". | "portrait" | 0.0.1 | | contentType | string | How to interpret {@link PrintOptions.content}. - "html" (default): treat content as raw HTML. - "path": treat content as a filesystem path (with or without a file:// prefix) pointing to a PDF or image to print. Note: base64-encoded content (base64:... or a data: URI) is detected automatically and does not require setting this. | "html" | 0.0.1 |