Ho preso spunto da qui:
https://stackoverflow.com/questions/238 ... wn-css-pdf
Codice: Seleziona tutto
# Install pandoc and dependencies
sudo apt update
sudo apt install pandoc
sudo apt install wkhtmltopdf # a dependency to convert HTML To pdf
# Download the github.css CSS style theme
wget https://raw.githubusercontent.com/simov/markdown-viewer/master/themes/github.css
# Convert test.md to test.pdf using the github.css CSS style theme
pandoc -f gfm -t html5 --metadata pagetitle="test.md" --css github.css \
test.md -o test.pdf
Però a quanto pare pandoc vuole utilizzare un javascript per la conversione da html a pdf, mi dava errore e si lamentava dell'assenza di questo qui:
https://github.com/pubpub/pagedjs-cli
Allora l'ho installato, però creando un pacchetto slackware con:
Codice: Seleziona tutto
npm2tgz pagedjs-cli
Codice: Seleziona tutto
$ pagedjs-cli template.html -o test.pdf
◴ Loading: template.htmlError: Could not find Chromium (rev. 1108766). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/user/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
at ChromeLauncher.resolveExecutablePath (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:101:27)
at ChromeLauncher.executablePath (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:178:25)
at ChromeLauncher.launch (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:64:37)
at async Printer.setup (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:65:19)
at async Printer.render (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:78:4)
at async Printer.pdf (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:267:14)
at async file:///usr/lib64/node_modules/pagedjs-cli/src/cli.js:165:10
Codice: Seleziona tutto
$ pandoc -f gfm -t html5 --metadata pagetitle="test.md" --css github.css test.md -o test.pdf
◴ Loading: ./html2pdf24192-0.htmlError: Could not find Chromium (rev. 1108766). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/user/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
at ChromeLauncher.resolveExecutablePath (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:101:27)
at ChromeLauncher.executablePath (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:178:25)
at ChromeLauncher.launch (file:///usr/lib64/node_modules/pagedjs-cli/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:64:37)
at async Printer.setup (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:65:19)
at async Printer.render (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:78:4)
at async Printer.pdf (file:///usr/lib64/node_modules/pagedjs-cli/src/printer.js:267:14)
at async file:///usr/lib64/node_modules/pagedjs-cli/src/cli.js:165:10
Error producing PDF.
Insomma per fare una cosa abbastanza banale è saltata fuori una complicazione assurda.
Avete per caso qualche idea su come risolvere?