npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mlsolutions/print-thermal

v0.0.13

Published

Plugin de Impressão Térmica para Capacitor (via Bluetooth)

Downloads

17

Readme

🖨️ Capacitor Thermal Bluetooth Printer Plugin

Este plugin Capacitor permite impressão direta em impressoras térmicas Bluetooth (58mm ou 80mm) e AirPrint no iOS, usando conteúdo HTML renderizado e convertido em imagem. Inclui suporte a:

✅ Impressão de HTML ✅ Impressão de QR Code ✅ Inclusão de logotipo no topo ✅ Listagem de impressoras emparelhadas ✅ Comunicação direta via Bluetooth (Android) ou AirPrint (iOS) ✅ Sem necessidade de apps externos


📦 Instalação

npm install ./print-plugin
npx cap sync

🧠 Pré-requisitos

Android

  • minSdkVersion: 21+
  • No AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

⚠️ Para Android 12+ (API 31+), solicite permissões BLUETOOTH_CONNECT e BLUETOOTH_SCAN em tempo de execução.


iOS

  • Suporta apenas impressoras AirPrint
  • Não é necessário permissão extra
  • A impressão abre o seletor nativo do sistema

🚀 Como Usar

1. Importar o plugin:

import PrintThermalPlugin from 'print-plugin';

2. Listar impressoras disponíveis:

const result = await PrintThermalPlugin.listPrinters();
console.log(result.devices);
// Android: [{ name: 'XP-58', address: '00:11:22:33:44:55' }]
// iOS:     [{ name: 'AirPrint (iOS)', address: 'airprint' }]

3. Imprimir conteúdo:

await PrintThermalPlugin.print({
  macAddress: selected.address, // no iOS, use 'airprint'
  html: '<h1>Pedido #123</h1><p>Total: R$ 25,00</p>',
  logoBase64: 'data:image/png;base64,...',   // opcional
  qrCodeText: 'https://meusite.com/pedido/123', // opcional
  paperWidthMm: 58                            // obrigatório no Android
});

🍏 iOS – AirPrint

No iOS, o plugin usa UIPrintInteractionController para abrir o seletor de impressão nativo.

✅ Como usar no iOS:

await PrintThermalPlugin.print({
  html: '<h2>Recibo</h2><p>Obrigado por comprar conosco!</p>',
  macAddress: 'airprint' // obrigatório usar este valor no iOS
});

No iOS, os campos logoBase64, qrCodeText e paperWidthMm são ignorados, pois o conteúdo é renderizado pelo próprio motor de impressão do sistema.


🎨 Personalização

html

Conteúdo HTML com estilos inline.

logoBase64 (opcional)

Imagem base64 (PNG, JPG...) que será posicionada no topo do recibo.

qrCodeText (opcional)

Texto ou URL que será convertido automaticamente em QR Code.

paperWidthMm

  • 58: impressoras compactas
  • 80: impressoras maiores (mais largas)
  • Obrigatório no Android, ignorado no iOS

📸 Exemplo Completo

import PrintThermalPlugin from 'print-plugin';

async function imprimirPedido() {
  const printers = await PrintThermalPlugin.listPrinters();
  const selected = printers.devices[0];

  await PrintThermalPlugin.print({
    macAddress: selected.address,
    html: `
      <div style="text-align:center">
        <h1>Pedido #123</h1>
        <p>Produto A - R$ 10,00</p>
        <p>Produto B - R$ 15,00</p>
        <h3>Total: R$ 25,00</h3>
      </div>
    `,
    logoBase64: 'data:image/png;base64,...',
    qrCodeText: 'https://meusite.com/pedido/123',
    paperWidthMm: 58
  });
}

📍 Observações Técnicas

  • Android: envia imagem renderizada como ESC/POS via Bluetooth
  • iOS: usa renderização do sistema para AirPrint
  • Layout e qualidade podem variar conforme a marca/modelo da impressora

📘 Roadmap Futuro

  • [ ] Suporte a impressoras USB
  • [ ] Impressão via IP (TCP/Socket)
  • [ ] Exportação para PDF
  • [ ] Impressão em background
  • [ ] Interface nativa para seleção de impressora

🛠️ Desenvolvimento

npm run build     # compila o plugin
npx cap sync      # aplica mudanças no app

📄 Licença

MIT © ML Solutions