JSPM

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

Package Exports

  • from-data-to-pdf

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 (from-data-to-pdf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

from-data-to-pdf

This library converts html files, URL and character string from html files to PDF files or PDF buffer.

Installation

$ npm i from-data-to-pdf

Usage

getPdfAndSave(targets: FileBuffer[]): Promise<FileBuffer[]>

async function main() {
    const dataToPdf = require("from-data-to-pdf");

    const listOfSavedPdf = await dataToPdf.getPdfAndSave(
        [
            {
                name: 'Google',
                url: 'https://www.google.com'
            },
            {
                name: 'String of html',
                text: '<string>'
            }
        ]
    );

    console.log(listOfSavedPdf);
    // Display:
    // [
    //     {
    //         name: 'Google',
    //         pathOfsavedFile: '<your project path>/temp/generatedPdf/Google1614854566504.pdf',
    //         done: true
    //     },
    //     {
    //         name: 'String of html',
    //         pathOfsavedFile: '<your project path>/temp/generatedPdf/Strin-of-html1614854568915.pdf',
    //         done: true
    //     }
    // ]
}

main();

getPdf(targets: FileBuffer[]): Promise<FileBuffer[]>

async function main() {
    const dataToPdf = require("from-data-to-pdf");

    const listOfPdfBuffer = await dataToPdf.getPdf(
        [
            {
                name: 'Google',
                url: 'https://www.google.com'
            },
            {
                name: 'String of html',
                text: '<string>'
            }
        ]
    );
    
    console.log(listOfPdfBuffer);
    // Display:
    // [
    //     {
    //         name: 'Google',
    //         buffer: [binary data...]
    //     },
    //     {
    //         name: 'String of html',
    //         buffer: [binary data...]
    //     }
    // ]

}

main();

fromHtmlFileToPdfAndSave(files: HTMLTarget[]): Promise<FileBuffer[]>

async function main() {
    const dataToPdf = require("from-data-to-pdf");

    const data = [
        {
            projectName: "Test1",
            fileName: "project1.html"
        }
    ];

    const listOfSavedPdf = await dataToPdf.fromHtmlFileToPdfAndSave(data);

    console.log(listOfSavedPdf);
    // Display:
    // [
    //     {
    //         name: 'Test1',
    //         done: true,
    //         pathOfsavedFile: '<your project>/temp/generatedPDF/Test11614887750982.pdf'
    //     }
    // ]
}

main();

fromHtmlFileToPdf(files: HTMLTarget[]): Promise<FileBuffer[]>

async function main() {
    const dataToPdf = require("from-data-to-pdf");

    const data = [
        {
            projectName: "Test1",
            fileName: "project1.html"
        }
    ];

    const listOfPdfBuffer = await dataToPdf.fromHtmlFileToPdfAndSave(data);

    console.log(listOfPdfBuffer);
    // Display:
    // [
    //     {
    //         name: 'Test1',
    //         pathOfsavedFile: <Buffer>
    //     }
    // ]
}

main();