From 0246a5da19c7335fc27d114b105bf21d82839a33 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Thu, 7 Jan 2016 18:34:43 -0500 Subject: [PATCH] Remove html-pdf-generator class. PDF generation now performed via html-pdf-cli-generator. --- src/gen/html-pdf-generator.js | 82 ----------------------------------- src/hackmyapi.js | 2 +- 2 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 src/gen/html-pdf-generator.js diff --git a/src/gen/html-pdf-generator.js b/src/gen/html-pdf-generator.js deleted file mode 100644 index 42dc347..0000000 --- a/src/gen/html-pdf-generator.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -Definition of the HtmlPdfGenerator class. -@module html-pdf-generator.js -@license MIT. See LICENSE.md for details. -*/ - -(function() { - - var TemplateGenerator = require('./template-generator') - , FS = require('fs-extra') - , HTML = require( 'html' ); - - /** - An HTML-driven PDF resume generator for HackMyResume. - */ - var HtmlPdfGenerator = module.exports = TemplateGenerator.extend({ - - init: function() { - this._super( 'pdf', 'html' ); - }, - - /** - Generate the binary PDF. - */ - onBeforeSave: function( info ) { - engines[ info.opts.pdf || 'wkhtmltopdf' ] - .call( this, info.mk, info.outputFile ); - return null; // halt further processing - } - - }); - - - var engines = { - /** - Generate a PDF from HTML using wkhtmltopdf. - */ - wkhtmltopdf: function(markup, fOut) { - var wk; - try { - wk = require('wkhtmltopdf'); - wk( markup, { pageSize: 'letter' } ) - .pipe( FS.createWriteStream( fOut ) ); - } - catch(ex) { - // { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', ... } - // { [Error: ENOENT] } - throw { fluenterror: this.codes.pdfGeneration, inner: ex }; - } - }, - - /** - Generate a PDF from HTML using Phantom. - See: https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js - */ - phantom: function( markup, fOut ) { - require('phantom').create( function( ph ) { - ph.createPage( function( page ) { - page.setContent( markup ); - page.set('paperSize', { - format: 'A4', - orientation: 'portrait', - margin: '1cm' - }); - page.set("viewportSize", { - width: 1024, // TODO: option-ify - height: 768 // TODO: Use "A" sizes - }); - page.set('onLoadFinished', function(success) { - page.render( fOut ); - ph.exit(); - }); - }, - { dnodeOpts: { weak: false } } ); - }); - } - - }; - - - -}()); diff --git a/src/hackmyapi.js b/src/hackmyapi.js index 574f792..223df31 100644 --- a/src/hackmyapi.js +++ b/src/hackmyapi.js @@ -35,7 +35,7 @@ External API surface for HackMyResume. FluentDate: require('./core/fluent-date'), HtmlGenerator: require('./gen/html-generator'), TextGenerator: require('./gen/text-generator'), - HtmlPdfGenerator: require('./gen/html-pdf-generator'), + HtmlPdfCliGenerator: require('./gen/html-pdf-cli-generator'), WordGenerator: require('./gen/word-generator'), MarkdownGenerator: require('./gen/markdown-generator'), JsonGenerator: require('./gen/json-generator'),