From daf5788c778a4d57122da3b5af92793829e76d7d Mon Sep 17 00:00:00 2001 From: rdlabo Date: Sat, 15 Aug 2026 17:20:23 +0900 Subject: [PATCH 1/3] point README to centralized documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a3d522f..ec69c16 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ printer plugin for capacitor +**Documentation:** [Read the full documentation](https://docs.rdlabo.dev/projects/capacitor-printer) + ## Install ```bash From cf134b5cc4e4103f1209690cc0c961ccbb18e1ee Mon Sep 17 00:00:00 2001 From: rdlabo Date: Wed, 19 Aug 2026 12:47:45 +0900 Subject: [PATCH 2/3] docs: split PDF and Web guides and add rdlabo-docs-omit README markers Publish pdf.md and web.md for the docs portal englishFromPackage pipeline. --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++--------- docs/pdf.md | 17 ++++++++++ docs/web.md | 11 +++++++ package.json | 1 + 4 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 docs/pdf.md create mode 100644 docs/web.md diff --git a/README.md b/README.md index ec69c16..77398b7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,17 @@ # @rdlabo/capacitor-printer -printer plugin for capacitor + +[![npm version](https://badge.fury.io/js/@rdlabo%2Fcapacitor-printer.svg)](https://badge.fury.io/js/@rdlabo%2Fcapacitor-printer) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + -**Documentation:** [Read the full documentation](https://docs.rdlabo.dev/projects/capacitor-printer) +Print files or the current web view from a Capacitor app. + +This plugin wraps the native printing UI on iOS and Android. You can print a local file (for example, a PDF generated in your app) or the content of the current web view. + + +**Full documentation:** [https://docs.rdlabo.dev/projects/capacitor-printer](https://docs.rdlabo.dev/projects/capacitor-printer) + ## Install @@ -11,14 +20,61 @@ npm install @rdlabo/capacitor-printer npx cap sync ``` +## Usage + +See [PDF](./docs/pdf.md) to print a file and [Web](./docs/web.md) to print the current WebView. + + +### Print a file + +```ts +import { Printer } from '@rdlabo/capacitor-printer'; + +const printPdf = async (filePath: string) => { + try { + await Printer.printFile({ + path: filePath, + mimeType: 'application/pdf', + }); + } finally { + // The source file can be deleted once the promise settles. + } +}; +``` + +### Print the current web view + +```ts +import { Printer } from '@rdlabo/capacitor-printer'; + +const printPage = async () => { + await Printer.printWebView({ name: 'My Receipt' }); +}; +``` + + + +## When to use + +Use this plugin when your app needs to present the system print dialog, such as: + +- Printing a receipt or invoice as PDF. +- Printing a report generated in the app. +- Printing the contents of the current page. + +## Platform notes + +- **iOS and Android**: `printFile` and `printWebView` are both supported. +- **Web**: Not supported because browsers already provide `window.print()`. + ## API -* [`printFile(...)`](#printfile) -* [`printWebView(...)`](#printwebview) -* [Interfaces](#interfaces) -* [Type Aliases](#type-aliases) +- [`printFile(...)`](#printfile) +- [`printWebView(...)`](#printwebview) +- [Interfaces](#interfaces) +- [Type Aliases](#type-aliases) @@ -42,8 +98,7 @@ Only available on Android and iOS. | ------------- | ------------------------------------------------------------- | | **`options`** | PrintFileOptions | --------------------- - +--- ### printWebView(...) @@ -57,12 +112,10 @@ Present the printing user interface to print the web view content. | ------------- | ----------------------------------------------------- | | **`options`** | PrintOptions | --------------------- - +--- ### Interfaces - #### PrintFileOptions | Prop | Type | Description | @@ -70,19 +123,24 @@ Present the printing user interface to print the web view content. | **`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. | - #### PrintOptions | Prop | Type | Description | Default | | ---------- | ------------------- | -------------------------- | ----------------------- | | **`name`** | string | The name of the print job. | 'Document' | - ### Type Aliases - #### PrintWebViewOptions -PrintOptions + + PrintOptions + + + +## License + +This project is licensed under the [MIT License](./LICENSE). + diff --git a/docs/pdf.md b/docs/pdf.md new file mode 100644 index 0000000..465678b --- /dev/null +++ b/docs/pdf.md @@ -0,0 +1,17 @@ +# PDF + +Present the system print UI for a PDF or other file. Only Android and iOS. Call this after [Installation](/docs/readme#installation). Print the current WebView with [Web](/docs/web). + +```ts +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 supports file paths, `file://` URLs, and `content://` URLs. iOS supports file paths and local `file://` URLs. `mimeType` is Android-only. Signatures are on the [API](/docs/api#printfile) page. diff --git a/docs/web.md b/docs/web.md new file mode 100644 index 0000000..c649279 --- /dev/null +++ b/docs/web.md @@ -0,0 +1,11 @@ +# Web + +Present the system print UI for the current WebView content. Only Android and iOS. Call this after [Installation](/docs/readme#installation). Print a PDF or other file with [PDF](/docs/pdf). + +```ts +import { Printer } from '@rdlabo/capacitor-printer'; + +await Printer.printWebView({ name: 'Document' }); +``` + +`name` is the print job name and defaults to `'Document'`. Signatures are on the [API](/docs/api#printwebview) page. diff --git a/package.json b/package.json index 345c5b3..8c29a12 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "android/src/main/", "android/build.gradle", "dist/", + "docs/", "ios/Sources", "ios/Tests", "Package.swift", From ddd637d08baefd8defd2321e334c6d4c2b353b77 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Wed, 19 Aug 2026 13:05:10 +0900 Subject: [PATCH 3/3] docs: regenerate README API from docgen Keep the published API reference in sync with src/definitions.ts. --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 77398b7..b7a8756 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ Use this plugin when your app needs to present the system print dialog, such as: -- [`printFile(...)`](#printfile) -- [`printWebView(...)`](#printwebview) -- [Interfaces](#interfaces) -- [Type Aliases](#type-aliases) +* [`printFile(...)`](#printfile) +* [`printWebView(...)`](#printwebview) +* [Interfaces](#interfaces) +* [Type Aliases](#type-aliases) @@ -98,7 +98,8 @@ Only available on Android and iOS. | ------------- | ------------------------------------------------------------- | | **`options`** | PrintFileOptions | ---- +-------------------- + ### printWebView(...) @@ -112,10 +113,12 @@ Present the printing user interface to print the web view content. | ------------- | ----------------------------------------------------- | | **`options`** | PrintOptions | ---- +-------------------- + ### Interfaces + #### PrintFileOptions | Prop | Type | Description | @@ -123,19 +126,20 @@ Present the printing user interface to print the web view content. | **`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. | + #### PrintOptions | Prop | Type | Description | Default | | ---------- | ------------------- | -------------------------- | ----------------------- | | **`name`** | string | The name of the print job. | 'Document' | + ### Type Aliases + #### PrintWebViewOptions - - PrintOptions - +PrintOptions