For the complete documentation index, see llms.txt. This page is also available as Markdown.

Print

Type: print

Request that the browser print the page to a PDF.

Tips for using print action
  • The PDF uses the site's print styles, so it may not look like the page on screen.

  • Use "orientation": "landscape" for wide content, such as tables and dashboards.

  • Set "margin": 0 if you want the content to reach the edge of the page. The default is 20px.

  • Don't use print on a page that's already a PDF. Use download_file to get the original instead.

Parameters

Name
Type
Required
Description

size

string

The size of paper the page should be printed to. Default: A4 Accepted: ["A4"]

margin

integer

The margin of the page in pixels when the page is printed to PDF. Default: 20

orientation

string

The orientation of the printed PDF page. Default: portrait Accepted: ["portrait", "landscape"]

See universal parameters.

Usage

The following JSON prints the page to a PDF in landscape orientation with a 20px margin.

"actions": [
    {
        "type": "print",
        "size": "A4",
        "orientation": "landscape",
        "margin": 20
    }
]

Example Output

Open

FAQs

When do I use the print action?

Use it when you need a PDF of a web page — for a report, a record, or something to share. It gives you a paginated A4 document rather than an image or HTML.

How do I convert a web page to PDF with Gaffa?

Add a print action to your request. It renders the page to an A4 PDF using the site's print styles. Use orientation and margin to control the layout.

How do I print a page in landscape?

Set "orientation": "landscape". Use it for wide tables, dashboards and anything that loses columns when squeezed into portrait A4.

Why does my PDF look different to the web page?

Most sites have a separate print stylesheet that hides navigation or changes colours. If you need the page as it looks on screen, use capture_screenshot with size: "fullscreen" instead.

What paper sizes can I use?

A4 only at the moment, and it's the default. Use orientation and margin to control everything else about the layout.

How do I remove the margins?

Set "margin": 0. The default is 20 pixels, which suits documents but crops designs meant to reach the edge of the page.

When should I use download_file action instead of print action?

Use download_file when the browser already has a PDF open, and you want the original file. Use print to create a PDF from a page that isn't one yet.

Last updated