1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-03 04:47:07 +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

@ -99,3 +99,17 @@ engines =
destPath = SLASH PATH.relative( process.cwd(), fOut)
SPAWN 'phantomjs', [ scriptPath, sourcePath, destPath ], false, on_error, @
return
###*
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: ( markup, fOut, opts, on_error ) ->
# Save the markup to a temporary file
tempFile = fOut.replace /\.pdf$/i, '.pdf.html'
FS.writeFileSync tempFile, markup, 'utf8'
SPAWN 'weasyprint', [tempFile, fOut], false, on_error, @
return