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

gitbook-plugin-pdf-styling

v0.2.0

Published

Post-processing GitBook PDF made easy

Downloads

18

Readme

Post-processing your GitBook PDFs made easy

By default, GitBook generates very simple, clean, black-on-white PDF documents. Although one can achieve some degree of customization through styles/pdf.css and the use of book.json to provide custom headers and footers, some operations remain out of reach. For instance, one cannot set a background or foreground layers, although common use-cases include watermarking/stamping, or even simply adding a nice color/texture to the document.

This plugin allows you to perform some common post-processing operations. It features:

  • [x] setting an image as background (with fill-page mode supported)
  • [ ] setting a colorful background (soon)
  • [ ] setting a texture-based background (soon)
  • [ ] performing foreground stamping (soon)

Using the plugin

On gitbook.com

The plugin is available from the Plugin Store under the name pdf-styling.

To activate it, while editing your book, open the Plugin Store menu and look for "pdf-styling".

Do not use the GUI configuration feature from gitbook.com. Have a look at the "Usage" section below instead for further information on how to configure and use the plugin.

Local installation

If you plan on generating PDF documents locally, you should add pdf-styling to the plugins list in your book.json, then run gitbook install.

Some binary dependencies are bundled with the plugin:

You will need to have imagemagick installed locally, though.

Then, have a look at the "Usage" section below for further information on how to configure and use the plugin.

Configuration

In your book.json:

{
  "plugins": ["pdf-styling"],
  "pluginsConfig": {
    "pdf-styling": {
    }
  }
}

Usage

Simply append the configuration you need within the empty pdf-styling property.

Using an image as background

"pdf-styling": {
  "background": {
    "image": "path/to/image.ext"
  }
}

You must provide a valid path with the image property (there is no default value). The path is relative to your GitBook project.

Position

The image will be centered by default. You can specify the position by setting an aptly named position property:

"pdf-styling": {
  "background": {
    "image": "path/to/image.ext",
    "position": "northwest"
  }
}

Available positions: center (default), north, northeast, east, southeast, south, southwest, west, northwest.

Offsets

Depending on the position, you may specify horizontal and/or vertical offsets. For instance, the northwest position allows for both directions to be set, whereas the north position only allows for the vertical one. The "center" position is not affected by offsets. Think of offsetting as "unsticking from an edge or corner".

You can provide either one or two values:

"20x50" // 20pt offset on the horizontal axis, 50pt offset on the vertical axis.
"10" // 10pt offset on both directions.
"0x50" // Fits "north" or "south" positions.
"50x0" // Fits "west" and "east" positions.
"10" // Fits any corner position ("northwest", "northeast", etc.)
"20x70" // Fits any corner position.

An example configuration could then look like this:

"pdf-styling": {
  "background": {
    "image": "path/to/image.ext",
    "position": "northwest",
    "offset": "10x20"
  }
}

Using a full-page image as background

You can have your image filling the whole page by enabling the fill property:

"pdf-styling": {
  "background": {
    "image": "path/to/image.ext",
    "fill": true
  }
}

Note: all specified properties but image will be ignored in fill mode.

Using a color as background

You can use a solid color background by fulfilling fill with a color-ish value which can be an hexadecimal color code , or a X11-compliant color name.

Using an hexadecimal color:

"pdf-styling": {
  "background": {
    "fill": "#257896"
  }
}

Using a X11 name:

"pdf-styling": {
  "background": {
    "fill": "wheat"
  }
}

Note: when fill is set to a color code or name, any specified image property will be ignored.

Opacity

When using an hexadecimal color code, you may specify the opacity of the color (a number between 0 and 1):

"pdf-styling": {
  "background": {
    "fill": "wheat",
    "opacity": "0.65"
  }
}

*Note: this option is not supported for X11 color names yet".