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

@ -206,7 +206,8 @@ WebContents.prototype.printToPDF = async function (options) {
marginLeft: 0.4,
marginRight: 0.4,
pageRanges: '',
preferCSSPageSize: false
preferCSSPageSize: false,
shouldGenerateTaggedPDF: false
};
if (options.landscape !== undefined) {
@ -322,6 +323,13 @@ WebContents.prototype.printToPDF = async function (options) {
printSettings.preferCSSPageSize = options.preferCSSPageSize;
}
if (options.generateTaggedPDF !== undefined) {
if (typeof options.generateTaggedPDF !== 'boolean') {
throw new Error('generateTaggedPDF must be a Boolean');
}
printSettings.shouldGenerateTaggedPDF = options.generateTaggedPDF;
}
if (this._printToPDF) {
if (pendingPromise) {
pendingPromise = pendingPromise.then(() => this._printToPDF(printSettings));