本文へ移動
rdlabo.dev

PDF

PDF などのファイルのシステム印刷 UI を出します。Android と iOS のみです。インストール のあとで呼び出します。現在の WebView を印刷する場合は Web です。

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

const filePath = '/path/to/document.pdf';

try {
  await Printer.printFile({ path: filePath });
} finally {
  // The promise settles after the OS no longer needs the source file.
}

Android はファイルパス、file:// URL、content:// URL に対応します。iOS はファイルパスとローカル file:// URL です。mimeType は Android のみです。

method printFile(...)

Present the printing user interface to print a file.

The promise settles after the operating system no longer needs the source
file, so the file can be safely deleted in a finally block.

Only available on Android and iOS.

printFile(options: PrintFileOptions) => Promise<void>

interface PrintFileOptions

Prop Type Description
path string The path to the file. Android supports file paths, file:// URLs, and content:// URLs. iOS supports file paths and local file:// URLs.
mimeType string The MIME type of the file. Only used on Android.