Skip to content

[Bug]: Playwright adds margin to generated PDFs when specifying @page #2716

Open
@Jwiggiff

Description

Version

1.49.1

Steps to reproduce

A simple python program to reproduce the issue:
https://gist.github.com/Jwiggiff/b451f65fc6910c29ff50ffd3f118f2b4

Expected behavior

I expect no margin to be added to the printed PDF. i.e. the crop marks should be at the edge of the page, and it should be a one page PDF.

Actual behavior

It seems playwright adds a margin to the PDF.

Additional context

This specifically happens when the HTML contains a CSS @page rule, but the page.pdf call has prefer_css_page_size=False.

I've also tried adding margin: 0 in the @page rule as well as setting all margins to 0 in the page.pdf call.

Environment

- Operating System: [Ubuntu 22.04, MacOS 15.1.1]
- CPU: [Apple M2 Pro]
- Browser: [Chromium]
- Python Version: [3.12]
- Other info:

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions