JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q30852F
  • License ISC

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pdfgenerator.cloud) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    TypeScript PDF Generator Module

    This TypeScript module provides functionalities to generate PDFs from URLs or HTML strings, using a specified API endpoint. It's designed to be simple, efficient, and easy to integrate into any TypeScript or JavaScript project.

    Installation

    Install the module using npm:

    npm install your-module-name

    Usage

    First, import and instantiate the module:

    const { PdfGenerator } = require('your-module-name');
    const pdfGenerator = new PdfGenerator({ apiKey: 'YOUR_API_KEY' });

    Generate a PDF from a URL:

    pdfGenerator.urlToPdf('http://example.com').then(pdf => {
        // Do something with the PDF
    });

    Generate a PDF from an HTML string:

    pdfGenerator.htmlToPdf('<html>...Your HTML...</html>').then(pdf => {
        // Do something with the PDF
    });

    API Reference

    urlToPdf(url: string): Promise<Buffer>

    • url: The URL of the webpage to be converted into a PDF.

    htmlToPdf(html: string): Promise<Buffer>

    • html: An HTML string to be converted into a PDF.

    Configuration

    Ensure you have your API key set in your environment variables as API_KEY. The module uses this key for authentication with the PDF generation service.

    Testing

    Run the tests using the following command:

    npm test

    Make sure to have your API key set in your environment variables before running the tests.

    Contributing

    Contributions are welcome! Please submit pull requests for any improvements. Ensure that all tests pass before submitting a pull request.

    License

    This module is available under the MIT License.