mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat!: generate accessible PDFs by default (#11778)
This commit is contained in:
parent
b3bfdd2024
commit
4fc14026e9
@ -30,6 +30,6 @@ export interface PDFOptions
|
||||
| preferCSSPageSize | <code>optional</code> | boolean | Give any CSS <code>@page</code> size declared in the page priority over what is declared in the <code>width</code> or <code>height</code> or <code>format</code> option. | <code>false</code>, which will scale the content to fit the paper size. |
|
||||
| printBackground | <code>optional</code> | boolean | Set to <code>true</code> to print background graphics. | <code>false</code> |
|
||||
| scale | <code>optional</code> | number | Scales the rendering of the web page. Amount must be between <code>0.1</code> and <code>2</code>. | <code>1</code> |
|
||||
| tagged | <code>optional</code> | boolean | Generate tagged (accessible) PDF. | <code>false</code> |
|
||||
| tagged | <code>optional</code> | boolean | Generate tagged (accessible) PDF. | <code>true</code> |
|
||||
| timeout | <code>optional</code> | number | Timeout in milliseconds. Pass <code>0</code> to disable timeout. | <code>30_000</code> |
|
||||
| width | <code>optional</code> | string \| number | Sets the width of paper. You can pass in a number or a string with a unit. | |
|
||||
|
@ -158,7 +158,7 @@ export interface PDFOptions {
|
||||
omitBackground?: boolean;
|
||||
/**
|
||||
* Generate tagged (accessible) PDF.
|
||||
* @defaultValue `false`
|
||||
* @defaultValue `true`
|
||||
* @experimental
|
||||
*/
|
||||
tagged?: boolean;
|
||||
|
@ -349,8 +349,8 @@ export function parsePDFOptions(
|
||||
pageRanges: '',
|
||||
preferCSSPageSize: false,
|
||||
omitBackground: false,
|
||||
tagged: false,
|
||||
outline: false,
|
||||
tagged: true,
|
||||
};
|
||||
|
||||
let width = 8.5;
|
||||
|
@ -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"],
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user