Skip to content
Snippets Groups Projects
Benjamin Baer's avatar
Benjamin Baer authored
a702d6cc
History

qfqPDF

CLI Tool to create PDF and Screenshots using puppeteer

Installation

  • Use most recent binary
  • Checkout this repository and run it with node:
git clone 
cd qfqpdf
npm install
node . --help

Usage

Example:

./qfqpdf "https://www.math.uzh.ch" --page-size A5 --margin-top 22mm --template-header "<h1>Test</h1>" -Fvbc "name:firstCookie,value:tunjngvnjfr23r" "name:secondCookie,value:249ur4jn233d"

All commands can be listed with --help / -h

qfqpdf-win.exe <source> [output]

Generate PDF files from URL using puppeteer

Positionals:
  output  file to generate, default: output.pdf          [default: "output.pdf"]
  source  URL to be printed

Options:
      --help                     Show help                             [boolean]
      --version                  Show version number                   [boolean]
  -c, --cookies                  multiple cookie strings inline, ex:
                                 "key:value,key:value" "key:value,key:value"
                                                                         [array]
      --cookie-file              path to a JSON file with multiple cookies
                                                                        [string]
  -F, --print-header-and-footer  Print with header and footer          [boolean]
  -b, --print-background         Print background images               [boolean]
  -l, --landscape                Print in landscape                    [boolean]
  -s, --paper-size               Set papersize to: A0 - A6, Letter, Legal, etc.
                                 (Default: A4)                          [string]
      --margin-top               Page margin in units (px, mm, in), default 15mm
                                                                        [string]
      --margin-bottom            Page margin in units (px, mm, in), default 15mm
                                                                        [string]
      --margin-left              Page margin in units (px, mm, in), default 15mm
                                                                        [string]
      --margin-right             Page margin in units (px, mm, in), default 15mm
                                                                        [string]
      --template-header          Provide an inline header template      [string]
      --template-header-file     Path to file containing header template[string]
      --template-footer          Provide an inline footer template      [string]
      --template-footer-file     Path to file containing footer template[string]
  -v, --verbose                  Run with verbose output               [boolean]

QFQPDF 2021, detailed information and sources:
https://git.math.uzh.ch/bbaer/qfqpdf

Cookie File

It is possible to provide a JSON file with all cookies, syntax is:

{
    cookies: [
        {
            "name": "first Cookie",
            "value": "49f33n3jr3jop23j",
            "url": "https://www.example.com",
            "path": "/"
        },
        {
            "name": "second Cookie",
            "value": "49f989uu313jr3jop23j",
            "url": "https://www.example.com",
            "path": "/"
        }
    ]
}

All Cookie values can be set. You can also combine inline cookies with static JSON file cookies.

Templates

Templates for header can be supplied inline or with files. Please note, that while templates are supplied in html, they only should contain the body of a page. You can access classes from the site you are printing for styling.