htmltar-to-pdf

2.0.3 • Public • Published

Build Status Coverage Status Version License Code style

Motivation

htmltar-to-pdf is a wrapper around phantomjs that convert a HTML payload (in a tarball) as a PDF (or png) file.

Using a simple tar as input makes the whole API simple & stable.

API/usage

const html2pdf = require('htmltar-to-pdf');
const infile  = '/some/path/to/a/file.tar';

let output_path = await html2pdf(infile, [format = "pdf|png", [options ]]); //will capture (index.html in tar file)


//you wont make it any simplier...
console.log("Please find a fine PDF in", output_path);

Configuration parameters & defaults values

  let opts = {
    format         : 'A4',
    orientation    : 'portrait || landscape',
    dpi            : 72,
    index          : 'index.html',

    waitForDom     : true,
    waitForEvent   : 'customPageEvent',
    waitForTimeout : 5000 // timeout as ms

     //configure one will set up #page-footer #page-header
    pageBodyAnchor : null,
    footerFile     : null,
    headerFile     : null,
  };

Credits

Dependents (0)

Package Sidebar

Install

npm i htmltar-to-pdf

Weekly Downloads

1

Version

2.0.3

License

UNLICENSED

Unpacked Size

11.1 kB

Total Files

10

Last publish

Collaborators

  • 131
  • frodon