New programmatic API
md-to-pdf
can now be used programmatically instead of just from the CLI. For now, the API is very simplistic, exposing only one function mdToPdf(mdFile, config)
:
const mdToPdf = require('md-to-pdf');
(async () => {
const pdf = await mdToPdf('readme.md', { dest: 'readme.pdf' }).catch(console.error);
if (pdf) {
console.log(pdf.filename);
}
})();
dest
was added as a new config option so the pdf output path can be set.
The plan for the future is to expose an API that can take a list of files and process them concurrently, i. e. reusing the same Chromium instance. However that requires a breaking change/major release and needs a few internal changes (e. g. finding the common parent directory for all files), so I want to do some restructuring of the code first.