Yesterday I published the very first version of
metalsmith-pdfize on npm (and
of course on Github as well).
As its name suggests, it is a Metalsmith plugin to
generate PDF files as part of the build process (Metalsmith is among other
things a static site generator I use to generate this website). To do so, this plugin uses
Puppeteer to drive a Chrome instance
in headless
mode in
order to export a PDF from a file generated by Metalsmith. This headless Chrome
instance just loads the corresponding page (and related assets) with the print
media and generates a PDF from that. It just acts as if you print the
corresponding page to a PDF file with a regular Chrome instance.
I wrote this plugin for my own use so it is integrated into the build process
of this
website
to generate a PDF version of my
résumé (by the way, I'm looking for a new job ;)). So far, I'm
pretty satisfied with the end result, even if at the moment, the fonts in the
generated PDF files are not exactly the expected ones. I guess it is because the
build happens on TravisCI where the environment is minimal, I'll have to look at
that soon.