Skip to main content
nbprint nbprint

A framework for building print media with nbconvert.

Build Status Coverage GitHub issues License PyPI

Background

Jupyter Notebooks are widely used for reports via nbconvert, but most development work has been on enabling building interactive websites. The goal of nbprint is to focus on print-oriented workflows, e.g. PDF, by leveraging new developments in nbconvert and the pagedjs print-oriented layout library.

For a deeper dive, see the documentation.

Quickstart

nbprint provides an nbconvert template and a configuration framework. The simplest example can be run with defaults by calling the nbprint executable on an existing notebook:

nbprint examples/basic.ipynb

This CLI supports configuration-driven customization with hydra syntax:

nbprint examples/basic.ipynb +nbprint.name=test ++nbprint.outputs.target=pdf

# First cell is papermill-style parameters
nbprint examples/parameters.ipynb +nbprint.parameters.a=test

# Overlay a config group, e.g. title and table of contents
nbprint examples/basic.ipynb nbprint/content/frontmatter=nbprint/title_toc
graph TB
    subgraph author["authoring"]
        nb("notebook<br>(.ipynb)")
        yaml[/"YAML config<br>(hydra)"/]
    end

    subgraph build["build time — Python"]
        nbc{"nbconvert"}
        nbct[/"nbprint template<br>(Jinja2)"/]
        html@{ shape: doc, label: "standalone html<br>+ embedded JS/CSS" }
    end

    subgraph browser["render time — browser"]
        direction TB
        init["1 · initialize<br>decode images"]
        proc["2 · process<br>reparent DOM · hoist styles"]
        pre["3 · preprocess<br>measure · scale · split"]
        esm["4 · cell render()<br>await trackRender barrier"]
        pjs[/"5 · paged.js<br>paginate"/]
        post["6 · postvalidate<br>drop blanks · warn overflow"]
    end

    out@{ shape: doc, label: "final output<br>(html · pdf via webpdf)" }

    nb e1@--> nbc
    yaml --> nbc
    nbct --> nbc
    e1@{animate: true}

    nbc e2@--> html
    e2@{animate: true}

    html --> init
    init --> proc --> pre --> esm --> pjs --> post

    post e3@--> out
    e3@{animate: true}

    classDef browserPhase fill:#eef,stroke:#557,color:#000
    class init,proc,pre,esm,pjs,post browserPhase

nbprint splits work across three stages. Authoring happens in the notebook (plus optional YAML overrides via hydra). At build time, nbconvert runs the nbprint Jinja2 template to emit a single self-contained HTML file with all JS, CSS, and data embedded. At render time, the browser does the heavy lifting: reparenting the DOM by parent-id, hoisting global styles, running a preprocessing pass that measures and scales oversized content, awaiting every cell's render() function through a lifecycle barrier so pagination only starts after the DOM is stable, then handing off to paged.js for layout, and finally running a postvalidation pass that drops blank pages and surfaces overflow warnings. PDF output is produced by rendering the same HTML with nbconvert --to webpdf (headless Chromium); there is no separate PDF codepath.

For more information, see the architecture documentation.

Configuration

See the configuration framework documentation for more information on building pure YAML-based report workflows with hydra.

Installation

Install with pip:

pip install nbprint

Install with conda

conda install nbprint -c conda-forge

Development

Warning: This project is under active development, so all APIs are subject to change!

License

This software is licensed under the Apache 2.0 license. See the LICENSE file for details.

Metadata

Release files for nbprint 0.12.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbprint 0.12.3
File Size Uploaded
nbprint-0.12.3.tar.gz 47.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbprint 0.12.3
File Interpreter ABI Platform
nbprint-0.12.3-py3-none-any.whl Python 3 none any Details

Total release size: 51.7 MB

Release files / nbprint-0.12.3.tar.gz

Download URL nbprint-0.12.3.tar.gz
Size 47.6 MB
Tags Source
SHA-256 checksum
How to use checksums
54384f47cefa3cba80206f2b106220110af84da9d65898fa9013f6efc00ee2ed
BLAKE2b-256 checksum
How to use checksums
9cdcaa34ca2c6c2b3cdd105a3abc3db281d3a2ed9a51aa6854cdaa062ab69801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / nbprint-0.12.3-py3-none-any.whl

Download URL nbprint-0.12.3-py3-none-any.whl
Size 4.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c6b57b15f4dfd01bc62c5015a3eb92f3c1a6e78a2ca297b43645e49cdf265c09
BLAKE2b-256 checksum
How to use checksums
e48c244dcc2fe05ad2081ec0024388c781943cb053581232fb30f02c26e930b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

0.13.0

2 release files

This release

0.12.3 This release

2 release files

0.12.2

2 release files

0.12.0

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page