feat: allow generating accessible pdf with printToPDF (#39563)

* feat: allow generating accessible pdf with printToPDF

* docs: mark generateTaggedPDF experimental
This commit is contained in:
Shelley Vohr 2023-08-24 17:01:59 +02:00 committed by GitHub
parent 381c955bca
commit 2affecd4dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 98 deletions

View file

@ -2081,6 +2081,28 @@ describe('webContents module', () => {
// Check that correct # of pages are rendered.
expect(doc.numPages).to.equal(3);
});
it('does not tag PDFs by default', async () => {
await w.loadFile(path.join(__dirname, 'fixtures', 'api', 'print-to-pdf-small.html'));
const data = await w.webContents.printToPDF({});
const doc = await pdfjs.getDocument(data).promise;
const markInfo = await doc.getMarkInfo();
expect(markInfo).to.be.null();
});
it('can generate tag data for PDFs', async () => {
await w.loadFile(path.join(__dirname, 'fixtures', 'api', 'print-to-pdf-small.html'));
const data = await w.webContents.printToPDF({ generateTaggedPDF: true });
const doc = await pdfjs.getDocument(data).promise;
const markInfo = await doc.getMarkInfo();
expect(markInfo).to.deep.equal({
Marked: true,
UserProperties: false,
Suspects: false
});
});
});
describe('PictureInPicture video', () => {