PhantomJS

PhantomJs: Convert a String to an Image/PDF.

To convert a string or HTML to PNG or PDF using phantomjs:

Create a File say texttoimage.js

Add this code:

var page = require(‘webpage’).create();
page.viewportSize = { width: 200, height : 200 };
page.content =  “This Text will be converted to Image”;
page.setContent(page.content,page);
window.setTimeout(function () {
page.render(‘newimage.png’);
phantom.exit();
}, 1000);

Save and Run the Script from console: phantomjs texttoimage.js

A image named newimage.png will be generated on same directory where your script is saved.

Here is the output:

PhantomJS : Converted Text to Image


Notice: Undefined variable: bk_thumb_size in /home/content/76/12438476/html/mindgeekblog/wp-content/themes/yeahthemes-sparkle/includes/templates/single-ymal.php on line 159