mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: allow generating accessible pdf with printToPDF (#39563)
* feat: allow generating accessible pdf with printToPDF * docs: mark generateTaggedPDF experimental
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user