Skip to content

Instantly share code, notes, and snippets.

@parweb
Created June 15, 2020 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parweb/1a2c2a29e8560caed30a3d176f94af63 to your computer and use it in GitHub Desktop.
Save parweb/1a2c2a29e8560caed30a3d176f94af63 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const emlformat = require('eml-format');
const htmlToImage = require('html-to-image');
const nodeHtmlToImage = require('node-html-to-image');
const input = 'sample.eml';
const output = 'image.png';
const eml = fs.readFileSync(input, 'utf-8');
emlformat.read(eml, function (error, data) {
if (error) return console.log(error);
nodeHtmlToImage({
output,
html: data.html
}).then(() => console.log('The image was created successfully!'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment