larviturltopdf

    0.2.3 • Public • Published

    Build Status Dependencies

    larviturltopdf

    Render an URL to a PDF using phantomjs.

    Example usage:

    'use strict';
     
    const urltopdf = require('larviturltopdf'),
          fs       = require('fs');
     
    urltopdf('http://www.fsf.org/', function(err, pdfBuffer) {
        if (err) throw err;
     
        // Write to disk
        fs.writeFile('output.pdf', pdfBuffer, function(err) {
            if (err) throw err;
     
            console.log('done');
        });
    });

    Wait for dynamic content

    In case javascript is used to alter the DOM, you can tell the renderer to wait until the class "html-ready" exists in the body tag.

    'use strict';
     
    const urltopdf = require('larviturltopdf'),
          fs       = require('fs');
     
    urltopdf({'url': 'http://www.fsf.org/', 'waitForHtmlReadyClass': true}, function(err, pdfBuffer) {
        if (err) throw err;
     
        // Do something with pdfBuffer
    });

    Custom execFile options

    You can pass an optional object as execOptions property with options for the execFile.

    'use strict';
     
    const urltopdf = require('larviturltopdf'),
          fs       = require('fs');
     
    urltopdf({'url': 'http://www.fsf.org/', execOptions: {'maxBuffer': 500 * 1024}}, function(err, pdfBuffer) {
        if (err) throw err;
     
        // Do something with pdfBuffer
    });

    Keywords

    Install

    npm i larviturltopdf

    DownloadsWeekly Downloads

    0

    Version

    0.2.3

    License

    ISC

    Unpacked Size

    12.7 kB

    Total Files

    8

    Last publish

    Collaborators

    • lilleman