PagedJS
Javascript library to transform HTML document into print-ready pdf
Declared in: projects/PagedJS/default.nix
Try the program in a shell
-
Install Nix
- Bash
-
$ apt install --yes curl git jq nix
- Bash
-
$ apt install --yes curl git jq nix
- Bash
-
$ pacman --sync --refresh --noconfirm curl git jq nix
-
Download a configuration file
# default.nix { ngipkgs ? import (fetchTarball "https://github.com/ngi-nix/ngipkgs/tarball/main") { }, }: ngipkgs.demo-shell ( { lib, pkgs, ... }: { # Enable X11 services.xserver.enable = true; programs.pagedjs.enable = true; environment.systemPackages = with pkgs; [ evince # PDF viewer ]; environment.etc."pagedjs.html".text = '' <!DOCTYPE html> <html> <head> <title>PagedJS Example</title> </head> <body> <h1>Hello, PagedJS!</h1> <p>This is a simple example of using PagedJS.</p> </body> </html> ''; } )
-
Enable binary substituters
- Bash
-
$ export NIX_CONFIG='substituters = https://cache.nixos.org/ https://ngi.cachix.org/ trusted-public-keys = cache.nixos.org-1:6nchdd59x431o0gwypbmraurkbj16zpmqfgspcdshjy= ngi.cachix.org-1:n+cal72roc3qqulxihpv+tw5t42whxmmhpragkrsrow='
-
Build and run the shell
- Bash
-
$ nix-build ./default.nix && ./result
- Bash
-
$ nix-build ./default.nix && ./result
- Bash
-
$ rev=$(nix-instantiate --eval --attr sources.nixpkgs.rev https://github.com/ngi-nix/ngipkgs/archive/master.tar.gz | jq --raw-output)$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/$rev.tar.gz --packages nix --run "nix-build ./default.nix && ./result"
- Bash
-
$ nix-build ./default.nix && ./result
-
Usage Instructions
-
A simple HTML file has been created at
/etc/pagedjs.htmlfor testing. -
Run
pagedjs-cli --helpto see available commands. -
To create a PDF from the HTML file, use:
$ pagedjs-cli -i /etc/pagedjs.html -o ~/pagedjs-example.pdf -
View the PDF using evince:
$ evince ~/pagedjs-example.pdf
-
Options
programs.pagedjs
-
Whether to enable PagedJS.
- Type:
boolean- Default:
false- Declared in:
- projects/PagedJS/programs/pagedjs/module.nix
-
The pagedjs-cli package to use.
- Type:
package- Default:
pkgs.pagedjs-cli- Declared in:
- projects/PagedJS/programs/pagedjs/module.nix
programs.pagedjs.enable
programs.pagedjs.package
Examples
Enable pagedjs
{ lib, pkgs, ... }: { # Enable X11 services.xserver.enable = true; programs.pagedjs.enable = true; environment.systemPackages = with pkgs; [ evince # PDF viewer ]; environment.etc."pagedjs.html".text = '' <!DOCTYPE html> <html> <head> <title>PagedJS Example</title> </head> <body> <h1>Hello, PagedJS!</h1> <p>This is a simple example of using PagedJS.</p> </body> </html> ''; }
Declared in: projects/PagedJS/programs/pagedjs/examples/pagedjs.nix
This project is funded by NLnet through these subgrants:
- Commons
- PagedJS
Related links: