Skip to main content
@capgo/capacitor-printer Files & Storage Open source

Printer Capacitor plugin

Capacitor plugin for printing documents, HTML, PDFs, images and web views

Install

bun add @capgo/capacitor-printer bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-printer
  • pnpm add @capgo/capacitor-printer
  • yarn add @capgo/capacitor-printer

Guide

How to use Printer in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Printer plugin preview QR code

Using @capgo/capacitor-printer

Capacitor plugin for printing documents, HTML, PDFs, images and web views.

Install

bun add @capgo/capacitor-printer
bunx cap sync

What This Plugin Exposes

  • printBase64 - Presents the printing UI to print files encoded as base64 strings.
  • printFile - Presents the printing UI to print device files.
  • printHtml - Presents the printing UI to print HTML documents.
  • printPdf - Presents the printing UI to print PDF documents.

Example Usage

printBase64

Presents the printing UI to print files encoded as base64 strings.

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

// Print a base64 encoded PDF
await Printer.printBase64({
  name: 'Invoice #12345',
  data: 'base64-encoded-pdf-data',
  mimeType: 'application/pdf',
});

// Print a base64 encoded image
await Printer.printBase64({
  name: 'Product Photo',
  data: '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDA...',
  mimeType: 'image/jpeg',
});

printFile

Presents the printing UI to print device files.

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

// iOS: Print from app documents directory
await Printer.printFile({
  name: 'Contract',
  path: 'file:///var/mobile/Containers/Data/Application/.../Documents/contract.pdf',
});

// Android: Print from content URI
await Printer.printFile({
  name: 'Receipt',
  path: 'content://com.android.providers.downloads.documents/document/123',
  mimeType: 'application/pdf',
});

// Android: Print from file path
await Printer.printFile({
  name: 'Photo',
  path: 'file:///storage/emulated/0/Download/photo.jpg',
  mimeType: 'image/jpeg',
});

printHtml

Presents the printing UI to print HTML documents.

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

// Simple HTML document
await Printer.printHtml({
name: 'Sales Report',
html: '<html><body><h1>Q4 Sales Report</h1><p>Revenue: $125,000</p></body></html>',
});

// HTML with print-specific CSS
await Printer.printHtml({
name: 'Styled Invoice',
html: `
<html>
<head>
<style>

printPdf

Presents the printing UI to print PDF documents.

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

// Print PDF from app storage
await Printer.printPdf({
  name: 'Annual Report 2024',
  path: 'file:///var/mobile/Containers/Data/Application/.../Documents/report.pdf',
});

// Print PDF from Android downloads
await Printer.printPdf({
  name: 'Downloaded Document',
  path: 'content://com.android.providers.downloads.documents/document/123',
});

Full Reference

Keep going from Using @capgo/capacitor-printer

If you are using Using @capgo/capacitor-printer to plan native plugin work, connect it with @capgo/capacitor-printer for the implementation detail in @capgo/capacitor-printer, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

Printer plugin FAQ

How do I install the Printer plugin in a Capacitor app?

Run "bun add @capgo/capacitor-printer" (or "npm install @capgo/capacitor-printer"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-printer" in your app code.

Does @capgo/capacitor-printer work with React, Vue and Angular?

Yes. Printer is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-printer support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-printer free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-printer/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Printer without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Printer changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo