Skip to content

@capawesome-team/capacitor-printer

Capacitor plugin for printing.

Sponsorware

This project is available as Sponsorware.

Sponsorware is a release strategy for open-source software that enables developers to be compensated for their open-source work with fewer downsides than traditional open-source funding models. (Source)

This means...

  • The source code will be published as soon as our GitHub Sponsors goal is reached.
  • Any GitHub sponsor with a sponsorware tier gets immediate access to our sponsors-only repository and can start using the project right away.

Terms

This project is licensed under the terms of the MIT license.
However, we kindly ask you to respect our fair use policy:

  • Please don't distribute the source code of the sponsors-only repository. You may freely use it for public, private or commercial projects, privately fork or mirror it, but please don't make the source code public, as it would counteract the sponsorware strategy.
  • If you cancel your subscription, you're automatically removed as a collaborator and will miss out on all future updates. However, you may use the latest version that's available to you as long as you like.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Android iOS

Installation

See Getting started with Insiders and follow the instructions to install the plugin.

Android

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $androidxDocumentFileVersion version of androidx.documentfile:documentfile (default: 1.0.1)

Configuration

No configuration required for this plugin.

Usage

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

const printHtml = async () => {
  await Printer.printHtml({
    name: 'My Document',
    html: '<h1>Hello World</h1>',
  });
};

const printPdf = async () => {
  await Printer.printPdf({
    name: 'My Document',
    path: 'content://com.android.providers.downloads.documents/document/msf%3A1000000485',
  });
};

const printWebView = async () => {
  await Printer.printWebView({
    name: 'My Document',
  });
};

API

printHtml(...)

printHtml(options: PrintHtmlOptions) => Promise<void>

Present the printing user interface to print a html document.

Only available for Android and iOS.

Param Type
options PrintHtmlOptions

Since: 5.0.0


printPdf(...)

printPdf(options: PrintPdfOptions) => Promise<void>

Present the printing user interface to print a pdf document.

Only available for Android and iOS.

Param Type
options PrintPdfOptions

Since: 5.1.0


printWebView(...)

printWebView(options?: PrintOptions | undefined) => Promise<void>

Present the printing user interface to print the web view content.

Param Type
options PrintOptions

Since: 5.0.0

Only available for Android and iOS.


Interfaces

PrintHtmlOptions

Prop Type Description Since
html string The HTML content to print. 5.0.0

PrintPdfOptions

Prop Type Description Since
path string The path to the pdf document on the device. 5.1.0

PrintOptions

Prop Type Description Default Since
name string The name of the print job. 'Document' 5.0.0

Type Aliases

PrintWebViewOptions

PrintOptions

Changelog

See CHANGELOG.md.

License

See LICENSE.