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:
13
dist/generators/html-pdf-cli-generator.js
vendored
13
dist/generators/html-pdf-cli-generator.js
vendored
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user