Michael Michael - 2 years ago 145
Node.js Question

HTML to PDF with Node.js

I'm looking to create a printable

version of my website webpages. Something like
only render the page as

Does anyone know a node module that does that ?

If not, how would you go about implementing one ? I've seen some methods talk about using headless browser like
, but not sure whats the flow.

Answer Source

Extending upon Mustafa's answer.

Install http://phantomjs.org/ and then install the phantom node module https://github.com/amir20/phantomjs-node

Here is an example of rendering a pdf

var phantom = require('phantom');   

phantom.create().then(function(ph) {
    ph.createPage().then(function(page) {
        page.open("http://www.google.com").then(function(status) {
            page.render('google.pdf').then(function() {
                console.log('Page Rendered');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download