diff --git a/docs/api/puppeteer.pdfoptions.md b/docs/api/puppeteer.pdfoptions.md
index eacffd30500..5015d0b2cc2 100644
--- a/docs/api/puppeteer.pdfoptions.md
+++ b/docs/api/puppeteer.pdfoptions.md
@@ -30,6 +30,6 @@ export interface PDFOptions
| preferCSSPageSize | optional
| boolean | Give any CSS @page
size declared in the page priority over what is declared in the width
or height
or format
option. | false
, which will scale the content to fit the paper size. |
| printBackground | optional
| boolean | Set to true
to print background graphics. | false
|
| scale | optional
| number | Scales the rendering of the web page. Amount must be between 0.1
and 2
. | 1
|
-| tagged | optional
| boolean | Generate tagged (accessible) PDF. | false
|
+| tagged | optional
| boolean | Generate tagged (accessible) PDF. | true
|
| timeout | optional
| number | Timeout in milliseconds. Pass 0
to disable timeout. | 30_000
|
| width | optional
| string \| number | Sets the width of paper. You can pass in a number or a string with a unit. | |
diff --git a/packages/puppeteer-core/src/common/PDFOptions.ts b/packages/puppeteer-core/src/common/PDFOptions.ts
index 0271faf7a5f..3d32294e3ed 100644
--- a/packages/puppeteer-core/src/common/PDFOptions.ts
+++ b/packages/puppeteer-core/src/common/PDFOptions.ts
@@ -158,7 +158,7 @@ export interface PDFOptions {
omitBackground?: boolean;
/**
* Generate tagged (accessible) PDF.
- * @defaultValue `false`
+ * @defaultValue `true`
* @experimental
*/
tagged?: boolean;
diff --git a/packages/puppeteer-core/src/common/util.ts b/packages/puppeteer-core/src/common/util.ts
index f8648d6d332..98d61d7425b 100644
--- a/packages/puppeteer-core/src/common/util.ts
+++ b/packages/puppeteer-core/src/common/util.ts
@@ -349,8 +349,8 @@ export function parsePDFOptions(
pageRanges: '',
preferCSSPageSize: false,
omitBackground: false,
- tagged: false,
outline: false,
+ tagged: true,
};
let width = 8.5;
diff --git a/test/TestExpectations.json b/test/TestExpectations.json
index 0af8981ed3b..8ddac7c9197 100644
--- a/test/TestExpectations.json
+++ b/test/TestExpectations.json
@@ -955,6 +955,12 @@
"parameters": ["webDriverBiDi"],
"expectations": ["FAIL"]
},
+ {
+ "testIdPattern": "[page.spec] Page Page.pdf can print to PDF without accessible tags",
+ "platforms": ["darwin", "linux", "win32"],
+ "parameters": ["webDriverBiDi"],
+ "expectations": ["SKIP"]
+ },
{
"testIdPattern": "[page.spec] Page Page.pdf should respect timeout",
"platforms": ["darwin", "linux", "win32"],
@@ -3094,6 +3100,12 @@
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
+ {
+ "testIdPattern": "[page.spec] Page Page.pdf can print to PDF without accessible tags",
+ "platforms": ["darwin", "linux", "win32"],
+ "parameters": ["cdp", "firefox"],
+ "expectations": ["SKIP"]
+ },
{
"testIdPattern": "[page.spec] Page Page.removeExposedFunction should work",
"platforms": ["darwin", "linux", "win32"],
diff --git a/test/src/page.spec.ts b/test/src/page.spec.ts
index 8e585df9993..271296b5dba 100644
--- a/test/src/page.spec.ts
+++ b/test/src/page.spec.ts
@@ -1940,6 +1940,25 @@ describe('Page', function () {
}
});
+ it('can print to PDF without accessible tags', async () => {
+ const {page, server} = await getTestState();
+
+ const outputFile = __dirname + '/../assets/output.pdf';
+ const outputFileAccessible =
+ __dirname + '/../assets/output-accessible.pdf';
+ await page.goto(server.PREFIX + '/pdf.html');
+ await page.pdf({path: outputFile});
+ await page.pdf({path: outputFileAccessible, tagged: false});
+ try {
+ expect(fs.readFileSync(outputFileAccessible).byteLength).toBeLessThan(
+ fs.readFileSync(outputFile).byteLength
+ );
+ } finally {
+ fs.unlinkSync(outputFileAccessible);
+ fs.unlinkSync(outputFile);
+ }
+ });
+
it('can print to PDF and stream the result', async () => {
const {page} = await getTestState();