1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

add: png format

This commit is contained in:
Ya Zhuang
2015-12-29 03:29:13 +08:00
parent dfa19899b0
commit 6b0ea0c7bd
7 changed files with 56 additions and 4 deletions

View File

@ -0,0 +1,48 @@
/**
Definition of the HtmlPngGenerator class.
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
@module html-png-generator.js
*/
(function() {
var TemplateGenerator = require('./template-generator')
, FS = require('fs-extra')
, HTML = require( 'html' );
/**
An HTML-based PDF resume generator for HackMyResume.
*/
var HtmlPngGenerator = module.exports = TemplateGenerator.extend({
init: function() {
console.log('png generator init');
this._super( 'png', 'html' );
},
/**
Generate the binary PDF.
*/
onBeforeSave: function( info ) {
console.log('png generator onBeforeSave');
png( info.mk, info.outputFile );
return null; // halt further processing
}
});
/**
Generate a PDF from HTML.
*/
function png( markup, fOut ) {
console.log('>> #png()');
console.log(markup);
console.log(fOut);
require('webshot')( markup , { encoding: 'binary', siteType: 'html' } )
.pipe( FS.createWriteStream( fOut ) );
}
}());