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.
To generate an API key, visit our RapidAPI page: Get API Key
Or visit the homepage of our PDF Generator: https://www.pdfgenerator.cloud
Invoice Template Generator
Discover our customizable invoice template generator. Design your template, generate a code snippet for easy integration by your developer into your software system, ensuring a quick and seamless process. Invoice Template Generator
Installation
Install the module using npm:
npm install pdfgenerator.cloud
Usage
Once the package is installed, you can import the library using import or require approach:
const { PdfGenerator } = require('pdfgenerator.cloud');
or
import { PdfGenerator } from 'pdfgenerator.cloud';
Then, import and instantiate the module:
const { PdfGenerator } = require('pdfgenerator.cloud');
const pdfGenerator = new PdfGenerator({ apiKey: 'YOUR_API_KEY' });
Generate a PDF from a URL:
pdfGenerator.urlToPdf('http://example.com').then(pdf => {
fs.writeFileSync('PdfFromUrl.pdf', pdf);
});
Generate a PDF from an HTML string:
pdfGenerator.htmlToPdf('<html>...Your HTML...</html>').then(pdf => {
fs.writeFileSync('PdfFromHtml.pdf', 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.
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.