1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-02 20:37:08 +01:00

Add weasyprint pdf generator support.

Note: This is based off
<https://github.com/hacksalot/HackMyResume/pull/185> because I changed
the generator expected arguments in that branch.
This commit is contained in:
ryneeverett
2017-01-16 00:15:04 -05:00
parent 7e2a3c3e7e
commit 419c935d82
3 changed files with 35 additions and 4 deletions

View File

@ -117,6 +117,19 @@ Definition of the HtmlPdfCLIGenerator class.
sourcePath = SLASH(PATH.relative(process.cwd(), tempFile));
destPath = SLASH(PATH.relative(process.cwd(), fOut));
SPAWN('phantomjs', [scriptPath, sourcePath, destPath], false, on_error, this);
},
/**
Generate a PDF from HTML using WeasyPrint's CLI interface.
Spawns a child process with `weasyprint <source> <target>`. Weasy Print
must be installed and path-accessible.
TODO: If HTML generation has run, reuse that output
*/
weasyprint: function(markup, fOut, opts, on_error) {
var tempFile;
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
FS.writeFileSync(tempFile, markup, 'utf8');
SPAWN('weasyprint', [tempFile, fOut], false, on_error, this);
}
};