@bcyesil/capacitor-plugin-printer

中文文档
0.0.6发布于 2025/10/30MITTypeScriptESM + CJS零依赖近 30 天下载 1万

Capacitor plugin for printing HTML format value iOS/Android apps.

原始使用文档
文档目录9 节
  1. Versions
  2. Supported Platforms
  3. Supported Contents
  4. Installation
  5. Usage
  6. Examples
  7. API
  8. print(...)
  9. Interfaces

Capacitor Printer Plugin


@bcyesil/capacitor-plugin-printer

Capacitor plugin for printing HTML, plain text, and images in iOS/Android apps. Supports additional features like Base64 PDF and image printing (from v0.0.5).

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

Versions

Capacitor VersionPlugin Version
v5.xv0.0.3
v6.xv0.0.5
v7.xv0.0.6+

Supported Platforms

Plugin VersioniOSAndroid
v0.0.5 and earlier13+5.1+ (API 22)
v0.0.6+14+6.0+ (API 23)

Supported Contents

  • HTML (can use CSS inline styling)
  • Text
  • Image(as HTML)
  • Base64(PDF & image) (since v0.0.5)

Installation

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

Usage

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

.
.
.

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

Examples

Text:

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

HTML:

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

Printing multiple HTML elements:

    let contentTest: string = "";

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

    Printer.print({ content: contentTest })

Images with HTML:

 Printer.print({ content: '<img src="base64/url/path">'})

with inline CSS:

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

Base64:

// (since v0.0.5)
// Base64 decoder supports Plain text(just the Base64 value) & Data URI(data:content/type;base64)

 Printer.print({ content: 'base64:...'})

API

print(...)

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

Interfaces

PrintOptions

PropTypeDescriptionDefaultSince
contentstringHTML content for print.0.0.1
namestringName of the print of the document.iOS=YourAppName/Android=Document+CurrentTimestamp0.0.1
orientationstringOrientation of the printing page. "portrait" or "landscape""portrait"0.0.1

版本与发布记录

@bcyesil/capacitor-plugin-printer 共发布 6 个版本,首次发布于 2023/07/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.6latest2025/10/301 年前
0.0.52024/11/042 年前
0.0.42024/06/082 年前
0.0.32023/07/103 年前
0.0.22023/07/083 年前
0.0.12023/07/083 年前

关于 @bcyesil/capacitor-plugin-printer 的常见问题

@bcyesil/capacitor-plugin-printer 是什么?

Capacitor plugin for printing HTML format value iOS/Android apps.

如何安装 @bcyesil/capacitor-plugin-printer?

在项目目录运行 npm install @bcyesil/capacitor-plugin-printer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bcyesil/capacitor-plugin-printer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bcyesil/capacitor-plugin-printer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bcyesil/capacitor-plugin-printer 可以商用吗?

@bcyesil/capacitor-plugin-printer 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bcyesil/capacitor-plugin-printer 的下载量有多少?

根据 npm 官方下载统计,@bcyesil/capacitor-plugin-printer 在 2026/10/08 – 2026/11/06 这 30 天内被下载 10,469 次,日均约 349 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bcyesil/capacitor-plugin-printer 还在维护吗?

最新版本 0.0.6 发布于 2025/10/30(1 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/07/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。