Currently, this package is not catching up with docusaurus v2 and not actively developed, it is under MIT license, so feel free to fork and modify it.
This is a PDF generator from docusaurus document.
- This plugin is not intended to be used during build process. But you can run it as a post build script. See the instructions below.
This is generated PDF of official docusaurus website: https://drive.google.com/file/d/19P3qSwLLUHYigrxH3QXIMXmRpTFi4pKB/view
npx docusaurus-pdf <initialDocsUrl> [filename]
For example
npx docusaurus-pdf http://localhost:3000/myBaseUrl/docs/doc1 hoge.pdf
*NOTE!
initialDocsUrl
is required. You can spin up your dev-webserver of docusaurus withyarn start
or use an already hosted page.filename
is optional (default isdocusaurus.pdf
).
npx docusaurus-pdf from-build [options] <dirPath> <firstDocPagePath> [baseUrl]
For example
npx docusaurus-pdf from-build build/ docs/doc1 /myBaseUrl/
You can also try to automatically load the firstDocPagePath
and baseUrl
from docusaurus.config.js
:
npx docusaurus-pdf from-build-config
- Mandatory:
dirPath
which points to the build directory created withdocusaurus build
. - Mandatory:
firstDocPagePath
is the URL path segment (withoutbaseUrl
) of your first docs page you whish to have included in the PDF. - Optional: If you have a
baseUrl
configured in yourdocusaurus.config.js
then pass this value asbaseUrl
. - Note: There is a optional parameter to set a custom filename. You can see further details using
npx docusaurus-pdf from-build --help
.
All dependencies needed to create a PDF from your docusaurus site are bundled in our Dockerfile.
docker run --rm -it -v /someDir/my-docusaurus:/workspace maxys/docusaurus-pdf:latest from-build --no-sandbox -o /workspace/build/docs.pdf /workspace/build docs/doc1 myBaseUrl
You can create the image locally without pulling maxys/docusaurus-pdf:latest
from the Docker Hub with:
docker build -t "docusaurus-pdf" .
- Move generated pdf file to
static/img
folder. <a>
tag withtarget="_blank"
<a href={useBaseUrl('img/docusaurus.pdf')} target="_blank">
Download PDF
</a>
- If this plugin cannot find next page link, PDF generation will stop.
- Dark theme PDF cannot be generated correctly now.