@@ -1245,8 +1245,62 @@ async def pdf(self, options: dict = None, **kwargs: Any) -> bytes:
12451245 * ``bottom`` (str): Bottom margin, accepts values labeled with units.
12461246 * ``left`` (str): Left margin, accepts values labeled with units.
12471247
1248- :return bytes: Return generated PDF ``bytes`` object.
1249- """
1248+ :return: Return generated PDF ``bytes`` object.
1249+
1250+ .. note::
1251+ Generating a pdf is currently only supported in headless mode.
1252+
1253+ :meth:`pdf` generates a pdf of the page with ``print`` css media. To
1254+ generate a pdf with ``screen`` media, call
1255+ ``page.emulateMedia('screen')`` before calling :meth:`pdf`.
1256+
1257+ .. note::
1258+ By default, :meth:`pdf` generates a pdf with modified colors for
1259+ printing. Use the ``--webkit-print-color-adjust`` property to force
1260+ rendering of exact colors.
1261+
1262+ .. code::
1263+
1264+ await page.emulateMedia('screen')
1265+ await page.pdf({'path': 'page.pdf'})
1266+
1267+ The ``width``, ``height``, and ``margin`` options accept values labeled
1268+ with units. Unlabeled values are treated as pixels.
1269+
1270+ A few exapmles:
1271+
1272+ - ``page.pdf({'width': 100})``: prints with width set to 100 pixels.
1273+ - ``page.pdf({'width': '100px'})``: prints with width set to 100 pixels.
1274+ - ``page.pdf({'width': '10cm'})``: prints with width set to 100 centimeters.
1275+
1276+ All available units are:
1277+
1278+ - ``px``: pixel
1279+ - ``in``: inch
1280+ - ``cm``: centimeter
1281+ - ``mm``: millimeter
1282+
1283+ The format options are:
1284+
1285+ - ``Letter``: 8.5in x 11in
1286+ - ``Legal``: 8.5in x 14in
1287+ - ``Tabloid``: 11in x 17in
1288+ - ``Ledger``: 17in x 11in
1289+ - ``A0``: 33.1in x 46.8in
1290+ - ``A1``: 23.4in x 33.1in
1291+ - ``A2``: 16.5in x 23.4in
1292+ - ``A3``: 11.7in x 16.5in
1293+ - ``A4``: 8.27in x 11.7in
1294+ - ``A5``: 5.83in x 8.27in
1295+ - ``A6``: 4.13in x 5.83in
1296+
1297+ .. note::
1298+ ``headerTemplate`` and ``footerTemplate`` markup have the following
1299+ limitations:
1300+
1301+ 1. Script tags inside templates are not evaluated.
1302+ 2. Page styles are not visible inside templates.
1303+ """ # noqa: E501
12501304 options = merge_dict (options , kwargs )
12511305 scale = options .get ('scale' , 1 )
12521306 displayHeaderFooter = bool (options .get ('displayHeaderFooter' ))
0 commit comments