Git Product home page Git Product logo

docusaurus-pdf's Introduction

npm version code style: prettier Github Action: Test

Introduction

This is a PDF generator from docusaurus document.

*Note

  • 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.

Demo

This is generated PDF of official docusaurus website: https://drive.google.com/file/d/19P3qSwLLUHYigrxH3QXIMXmRpTFi4pKB/view

Usage

Use with already hosted docusaurus instance (locally or somewhere in the net)

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 with yarn start or use an already hosted page.
  • filename is optional (default is docusaurus.pdf).

Use with the build artifact of docusaurus build

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

Parameters

  • Mandatory: dirPath which points to the build directory created with docusaurus build.
  • Mandatory: firstDocPagePath is the URL path segment (without baseUrl) of your first docs page you whish to have included in the PDF.
  • Optional: If you have a baseUrl configured in your docusaurus.config.js then pass this value as baseUrl.
  • Note: There is a optional parameter to set a custom filename. You can see further details using npx docusaurus-pdf from-build --help.

Docker usage

All dependencies needed to create a PDF from your docusaurus site are bundled in our Dockerfile.

Create PDF from build artifact

Run docusaurus-pdf with prebuild image

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

Build Docker image locally

You can create the image locally without pulling maxys/docusaurus-pdf:latest from the Docker Hub with:

docker build -t "docusaurus-pdf" .

Link of PDF

  1. Move generated pdf file to static/img folder.
  2. <a> tag with target="_blank"
<a href={useBaseUrl('img/docusaurus.pdf')} target="_blank">
  Download PDF
</a>

NOTE!

  1. If this plugin cannot find next page link, PDF generation will stop.

note

  1. Dark theme PDF cannot be generated correctly now.

docusaurus-pdf's People

Contributors

kohheepeace avatar aloisklink avatar maxarndt avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.