feat: allow generating accessible pdf with printToPDF
(#39563)
* feat: allow generating accessible pdf with printToPDF * docs: mark generateTaggedPDF experimental
This commit is contained in:
parent
381c955bca
commit
2affecd4dd
6 changed files with 51 additions and 98 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue