← All procedures

pdf.render

Render HTML to a PDF file with a headless Chromium browser

CLI
Package
@procedures/pdf · README
Path
["pdf","render"]
CLI
mark pdf render
As data
{"$proc":["pdf","render"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/pdf/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["pdf","render"], {});
console.log(JSON.stringify(result));

From the command line

$ mark pdf render

As data, in a program

{ "$proc": ["pdf", "render"], "input": {} }

Input

FieldTypeRequiredDefaultDescription
htmlstringnoThe HTML text of the page
filestringnoThe path of an HTML file
outputstringnoThe path of the PDF file (default: a file in a new temporary folder)
executablestringnoThe browser program (default: PDF_BROWSER, CHROME_PATH, then a search)
argsstring[]noMore flags for the browser, for example --no-sandbox
timeoutintegernoThe time limit, in milliseconds (default: 60000)

Output

FieldTypeRequiredDefaultDescription
pathstringyesThe absolute path of the PDF file
bytesnumberyesThe size of the PDF file, in bytes
browserstringyesThe browser program that made the file
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "html": {
        "description": "The HTML text of the page",
        "type": "string"
      },
      "file": {
        "description": "The path of an HTML file",
        "type": "string",
        "minLength": 1
      },
      "output": {
        "description": "The path of the PDF file (default: a file in a new temporary folder)",
        "type": "string",
        "minLength": 1
      },
      "executable": {
        "description": "The browser program (default: PDF_BROWSER, CHROME_PATH, then a search)",
        "type": "string",
        "minLength": 1
      },
      "args": {
        "description": "More flags for the browser, for example --no-sandbox",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "timeout": {
        "description": "The time limit, in milliseconds (default: 60000)",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 9007199254740991
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The absolute path of the PDF file"
      },
      "bytes": {
        "type": "number",
        "description": "The size of the PDF file, in bytes"
      },
      "browser": {
        "type": "string",
        "description": "The browser program that made the file"
      }
    },
    "required": [
      "path",
      "bytes",
      "browser"
    ],
    "additionalProperties": false
  }
}