Socket
Book a DemoInstallSign in
Socket

@diplodoc/pdf-generator

Package Overview
Dependencies
Maintainers
7
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diplodoc/pdf-generator

Package to turn Diplodoc projects into PDFs

latest
Source
npmnpm
Version
1.1.7
Version published
Weekly downloads
248
-6.06%
Maintainers
7
Weekly downloads
 
Created
Source

pdf-generator

Package to turn Diplodoc projects into PDFs.

Installation

npm i -g @diplodoc/pdf-generator

Usage

Step 1: Generate Single Page Files

Run @diplodoc/cli command. This will create an output folder with a single page file for each Table of Contents (ToC) file.

npx -- @diplodoc/cli@latest -i ./docs -o ./docs-output --pdf

Step 2: Convert Single Page Files to PDFs

Run the @diplodoc/pdf-generator command. This will create PDF files right next to the single page ones.

npx -- @diplodoc/pdf-generator@latest -i ./docs-output

The tool also provides users with flexible customization of headers and footers in the form of HTML format files, the paths to which can be passed through the corresponding options --custom-header and --custom-footer.

By default, the header is not set, but the page numbering in the lower right corner is set in the footer, as shown in the example below.

npx -- @diplodoc/pdf-generator@latest -i ./docs-output

Also below is an example of a command with custom header (example-custom-header.html) and custom footer (example-custom-footer.html).
Even if you specify a custom footer, the numbering still remains in the lower right corner.

npx -- @diplodoc/pdf-generator@latest -i ./docs-output --custom-header ./example-custom-header.html --custom-footer ./example-custom-footer.html

Passed parameters

OptionTypeNecessaryDefault valueDescription
custom-headerstring (filepath)No""Path to HTML file with custom header content for generated PDF pages.
custom-footerstring (filepath)No<div style="position: relative;width: 100%;height: 0;"><div style="position: absolute;right: 20px;bottom: 0;font-size: 10px;z-index: 0;padding: 0 5px;background: white;"><span class="pageNumber"></span></div></div>Path to HTML file with custom footer content for generated PDF pages.

Examples of generated pdf pages with custom headers and footers are available on screenshots tests/image_snapshots /custom-headers-test-ts-integration-works-on-page-*

Development

Prerequisites

  • node >= 18.x
  • graphicsmagick
  • ghostscript

Don't have graphicsmagick and ghostscript yet?

Follow this guide to install the required dependencies.

Run test

npm run test

FAQs

Package last updated on 15 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts