JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q35081F
  • License MIT

HTML to PDF converter that uses slimerjs

Package Exports

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

Readme

slimer-html-pdf - convert any HTML document to PDF format using slimerjs (Gecko)

Travis-ci Build Status

Full support for HTML5 (including FLEX)

More info: https://slimerjs.org/

Dependencies:

  • Firefox - free and open-source web browser
  • Xvfb - X virtual framebuffer
$ sudo apt-get install -y firefox xvfb

Usage:

$ npm i slimer-html-pdf --save
var slimerHtmlPdf = require('slimer-html-pdf')

var options = {
      paperSize: {
        format: 'A4',
        orientation: 'portrait',
        margin: '1cm'
      }
}

slimerHtmlPdf.convertXvfb('http://github.com', './github.pdf', options)
  .then( msg => {
    console.log('Successful', msg)
  })
  .catch( err => {
    console.log('Error!', err)
  })
slimerHtmlPdf.convert(source, output, options)
source - HTML source
output - save path
options - options (see more: http://docs.slimerjs.org/current/api/webpage.html)

slimerHtmlPdf.convertXvfb - for testing and production, uses Xvfb frame buffer

Tip:

How to break a page?

use styles!

page-break-inside: auto|avoid|initial|inherit;

auto	Default. Automatic page breaks
avoid	Avoid page break inside the element (if possible)
initial	Sets this property to its default value.
inherit	Inherits this property from its parent element.

e.g.

<div style="page-break-before:avoid;"><!-- content --></div>