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 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-pdf-generator

v1.1.0

Published

A Capacitor plugin to generate PDF from HTML.

Readme

Capacitor PDF Generator

This Capacitor plugin enables you to easily generate PDF documents from HTML content directly within your mobile app. Designed for both Android and iOS platforms, it seamlessly converts your HTML strings or files into high-quality PDF files that can be saved, shared, or printed.

Installation

npm install capacitor-pdf-generator
npx cap sync

Usage

The generate method takes an options object with the following properties:

  • html: The HTML template to use.
  • data: The data to render in the template.
  • direction: The direction of the text (ltr or rtl).
  • locale: The locale to use for the text.
  • logo: The URL of the logo to use in the header.
  • headerLine1: The first line of the header.
  • headerLine2: The second line of the header.
  • footerLine1: The first line of the footer.
  • footerLine2: The second line of the footer.
  • filename: The name of the generated PDF file.
  • margin: The margin of the PDF file.

Example

import { Plugins } from '@capacitor/core';
const { PdfGenerator } = Plugins;

async function generatePdf() {
  const html = `
   USE HTML template with CSS. Attached DEMO file name dynamic-template.html
  `;

  const requestData = [
  { subHead: 'Invoice Number', subValue: 'INV-2025-00123' },
  { subHead: 'Invoice Date', subValue: '2025-08-11' },
  { subHead: 'Due Date', subValue: '2025-09-10' },
  { subHead: 'Bill To', subValue: 'John Doe' },
  { subHead: 'Billing Address', subValue: '1234 Elm Street, Springfield, IL' },
  { subHead: 'Shipping Address', subValue: '5678 Oak Avenue, Springfield, IL' },
  { subHead: 'Item Description', subValue: 'Laptop Model XYZ' },
  { subHead: 'Quantity', subValue: '2' },
  { subHead: 'Unit Price', subValue: '$1200.00' },
  { subHead: 'Subtotal', subValue: '$2400.00' },
  { subHead: 'Tax (10%)', subValue: '$240.00' },
  { subHead: 'Total Amount', subValue: '$2640.00' },
  { subHead: 'Payment Terms', subValue: 'Net 30 days' },
  { subHead: 'Notes', subValue: 'Thank you for your business!' },
]

 const options = {
    html: template,
    data: {
      logo: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2", 
      headerLine1: 'Your Company Name',
      headerLine2: 'Invoice',
      footerLine1: 'Thank you for your business!',
      footerLine2: 'www.yourcompany.com',
      title: 'Demo',
      items: requestData,
      isRtl: false // Set to true for Arabic, Hebrew.
    },
    locale: 'ar-SA', // Example for Arabic
    margin:10
  };

 PdfGenerator.generate(options).then(result => {
    console.log('PDF generated', result.base64);
      // Do something with the base64 string
  });

}

API

generate(...)

generate(options: PdfGeneratorOptions) => Promise<{ base64: string; }>

| Param | Type | | ------------- | --------------------------------------------------------------------- | | options | PdfGeneratorOptions |

Returns: Promise<{ base64: string; }>


Interfaces

PdfGeneratorOptions

| Prop | Type | Description | | ----------------- | --------------------------------- | ----------------------------------------- | | html | string | The HTML template to use. | | data | any | The data to render in the template. | | direction | 'ltr' | 'rtl' | The direction of the text (ltr or rtl). | | locale | string | The locale to use for the text. | | logo | string | The URL of the logo to use in the header. | | headerLine1 | string | The first line of the header. | | headerLine2 | string | The second line of the header. | | footerLine1 | string | The first line of the footer. | | footerLine2 | string | The second line of the footer. | | filename | string | The name of the generated PDF file. | | margin | number | The margin of the PDF file. |