Convert entire docusaurus contents to a portable PDF
1.4K
Extract rendered data from Docusaurus and generate a PDF, the hard way.
This project offers the following options and flags:
Options:
--version Show version number [boolean]
-u, --url Base URL, should be the baseUrl of the Docusaurus inst
ance (e.g. https://docusaurus.io/docs/) [string]
-s, --selector CSS selector to find the link of the next page[string]
-d, --dest Working directory. Default to ./pdf [string]
-f, --file Change default list output filename [string]
-o, --output Change PDF output filename [string]
--include-index Include / (passed URL) in generated PDF
--prepend Prepend additional pages, split with comma [string]
--append Append additional pages, split with comma [string]
--wkhtmltopdf-args Additional options for wkhtmltopdf [string]
--list-only Fetch list without generating PDF
--pdf-only Generate PDF without fetching list. Ensure list exists
--toc Generate the PDF with a table of contents
--compress Compress the output file. REQUIRES ghostscript!
--stdout Stream PDF to stdout
--quiet silence console output.
-h, --help Show help [boolean]
The docker image comes with a working environment so no other external software is needed. Here are a few examples of this software in action. Run the following commands to generate your desired PDF:
# Generate PDF from specific site under `docs` scope. Please note that the folder with the generated file can be found in /tmp/pdf
docker run --rm -v /tmp/pdf:/d2p/pdf nuxnik/docusaurus-to-pdf -u https://docusaurus.io/docs
# Let's use some more flags: create table of contents, compress the file, and pipe from stdout to documentation.pdf
docker run --rm nuxnik/docusaurus-to-pdf -u https://docusaurus.io/docs --toc --compress --stdout > documentation.pdf
Like mr-pdf, this package looks for the next pagination links on generated Docusaurus site. Collect them in a list and then pass the list to wkhtmltopdf to generate the PDF. You can specify the CSS selector if you're using a custom Docusaurus theme:
docker run --rm nuxnik/docusaurus-to-pdf -u https://docusaurus.io/docs --selector 'nav.custom-pagination-item--next > a'
You can also customize the CSS of the pages which are scraped by the crawler by modifying "print.css" file located in the project root. This CSS file is applied to the pages before being processed through Wkhtmltopdf. Depending on how this file is modified, will change the overall look of the generated PDF file.
For more information check out this project's GitHub Repo
Content type
Image
Digest
sha256:9f6c8811f…
Size
110.6 MB
Last updated
over 3 years ago
docker pull nuxnik/docusaurus-to-pdf