node.js - pass HTML to phantom and render it to PDF -


normally in phantom able this:

phantom = require('phantom')   phantom.create(function(ph){   ph.createpage(function(page) {     page.open("http://www.google.com", function(status) {       page.render('google.pdf', function(){          console.log('page rendered');         ph.exit();        });     });   }); }); 

however instead of loading webpage have html want pass , render pdf.

how able pass html , convert pdf , phantomjs right appraoch or ffmpeg better approach , if how use ffmpeg?

you can set content property of page.

phantom = require('phantom') phantom.create(function(ph){     ph.createpage(function(page) {         page.content = "some html"//set html here         page.render('google.pdf', function(){             console.log('page rendered');             ph.exit();         });     }); }); 

Comments