npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

danroscigno-to-pdf

v0.6.5

Published

Generate PDF from Docusaurus

Downloads

36

Readme

Docs to PDF

npm node-current npm Codecov GitHub

📌 Introduction

This is a PDF generator from document website such as docusaurus. This is a fork of mr-pdf which was not maintained anymore. Feel free to contribute to this project.

📦 Installation

npm install -g docs-to-pdf

🚀 Quick Start

npx docs-to-pdf --initialDocURLs="https://docusaurus.io/docs/" --contentSelector="article" --paginationSelector="a.pagination-nav__link.pagination-nav__link--next" --excludeSelectors=".margin-vert--xl a,[class^='tocCollapsible'],.breadcrumbs,.theme-edit-this-page" --coverImage="https://docusaurus.io/img/docusaurus.png" --coverTitle="Docusaurus v2"

⚡ Usage

For Docusaurus v2

npx docs-to-pdf docusaurus --initialDocURLs="https://docusaurus.io/docs/"

OR

npx docs-to-pdf --initialDocURLs="https://docusaurus.io/docs/" --contentSelector="article" --paginationSelector="a.pagination-nav__link.pagination-nav__link--next" --excludeSelectors=".margin-vert--xl a,[class^='tocCollapsible'],.breadcrumbs,.theme-edit-this-page" --coverImage="https://docusaurus.io/img/docusaurus.png" --coverTitle="Docusaurus v2"

🍗 CLI Global Options

| Option | Required | Description | | ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --initialDocURLs | Yes | set URL to start generating PDF from. | | --contentSelector | No | used to find the part of main content | | --paginationSelector | No | CSS Selector used to find next page to be printed for looping. | | --excludeURLs | No | URLs to be excluded in PDF | | --excludeSelectors | No | exclude selectors from PDF. Separate each selector with comma and no space. But you can use space in each selector. ex: --excludeSelectors=".nav,.next > a" | | --cssStyle | No | CSS style to adjust PDF output ex: --cssStyle="body{padding-top: 0;}" *If you're project owner you can use @media print { } to edit CSS for PDF. | | --outputPDFFilename | No | name of the output PDF file. Default is docs-to-pdf.pdf | | --pdfMargin | No | set margin around PDF file. Separate each margin with comma and no space. ex: --pdfMargin="10,20,30,40". This sets margin top: 10px, right: 20px, bottom: 30px, left: 40px | | --paperFormat | No | pdf format ex: --paperFormat="A3". Please check this link for available formats Puppeteer document| | --disableTOC | No | Optional toggle to show the table of contents or not | | --coverTitle | No | Title for the PDF cover. | | --coverImage | No | <src> Image for PDF cover (does not support SVG) | | --coverSub | No | Subtitle the for PDF cover. Add <br/> tags for multiple lines. | | --headerTemplate | No | HTML template for the print header. Please check this link for details of injecting values Puppeteer document | | --footerTemplate | No | HTML template for the print footer. Please check this link for details of injecting values Puppeteer document | | --puppeteerArgs | No | Add puppeteer BrowserLaunchArgumentOptions arguments ex: --sandbox Puppeteer document | | --protocolTimeout | No | Timeout setting for individual protocol calls in milliseconds. If omitted, the default value of 180000 ms (3 min) is used | | --filterKeyword | No | Only adds pages to the PDF containing a given meta keywords. Makes it possible to generate PDFs of selected pages | | --baseUrl | No | Base URL for all relative URLs. Allows to render the pdf on localhost (ci/Github Actions) while referencing the deployed page. | | --excludePaths | No | URL Paths to be excluded | | --restrictPaths | No | Keep Only URL Path with the same rootPath as --initialDocURLs | | | | |

Docusaurus Options

| Option | Required | Description | | ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --version | No | Docusaurus version. Default is 2. | | --builDir | No | Path to Docusaurus build dir. Either absolute or relative from path of the shell |

🎨 Examples and Demo PDF

Docusaurus v2

20210603060438

https://docusaurus.io/

initialDocURLs: https://docusaurus.io/docs

demoPDF: https://github.com/jean-humann/docs-to-pdf/blob/master/pdf/v2-docusaurus.pdf

command:

npx docs-to-pdf docusaurus --initialDocURLs="https://docusaurus.io/docs/"

OR

npx docs-to-pdf --initialDocURLs="https://docusaurus.io/docs/" --contentSelector="article" --paginationSelector="a.pagination-nav__link.pagination-nav__link--next" --excludeSelectors=".margin-vert--xl a,[class^='tocCollapsible'],.breadcrumbs,.theme-edit-this-page" --coverImage="https://docusaurus.io/img/docusaurus.png" --coverTitle="Docusaurus v2"

Docusaurus v1 - Legacy

https://docusaurus.io/en/

initialDocURLs: https://docusaurus.io/docs/en/installation

demoPDF: https://github.com/jean-humann/docs-to-pdf/blob/master/pdf/v1-docusaurus.pdf

command:

npx docs-to-pdf docusaurus --initialDocURLs="https://docusaurus.io/docs/en/installation" --version=1

OR

npx docs-to-pdf --initialDocURLs="https://docusaurus.io/docs/en/installation" --contentSelector="article" --paginationSelector=".docs-prevnext > a.docs-next" --excludeSelectors=".fixedHeaderContainer,footer.nav-footer,#docsNav,nav.onPageNav,a.edit-page-link,div.docs-prevnext" --cssStyle=".navPusher {padding-top: 0;}" --pdfMargin="20"

PR to add new docs is welcome here... 😸

📄 How docs-to-pdf works

  1. puppeteer can make html to PDF like you can print HTML page in chrome browser
  2. so, the idea of docs-to-pdf is generating one big HTML through looping page link, then run page.pdf() from puppeteer to generate PDF.

docs-to-pdf-diagram

🎉 Thanks

This repo's code is coming from https://github.com/KohheePeace/mr-pdf.

Thanks for awesome code made by @KohheePeace, @maxarndt and @aloisklink.

@bojl approach to make TOC was awesome and breakthrough.