(Created on )

Puppeteer: page.pdf() Cannot handle parameter type:

PDF dimension input is neither a supported number nor a string.


PDF dimension input is neither a supported number nor a string.

Error message

page.pdf() Cannot handle parameter type:

How this error happens

A PDF width or height must be a number or string. Passing an object from a form or configuration parser is not supported.

The snippets use an open Puppeteer page named page.

await page.pdf({
    width: {
        value: 210,
        unit: "mm",
    },
});

How to fix

Convert structured configuration into the string or number the PDF API expects.

const paperWidth = {
    value: 210,
    unit: "mm",
};

await page.pdf({
    width: paperWidth.value + paperWidth.unit,
    height: "297mm",
});

Things to keep in mind

Numeric dimensions are interpreted as pixels. Add an explicit unit if your configuration uses millimeters or inches.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →