htmltar-to-pdf

convert html tar archives to pdf

Usage no npm install needed!

<script type="module">
  import htmltarToPdf from 'https://cdn.skypack.dev/htmltar-to-pdf';
</script>

README

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 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); //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