tabs.saveAsPDF() 编辑
Saves the current page as a PDF file. This will open a dialog, supplied by the underlying operating system, asking the user where they want to save the PDF file.
This is an asynchronous function that returns a Promise
.
Syntax
var saving = browser.tabs.saveAsPDF(
pageSettings // object
)
Parameters
pageSettings
object
. Settings for the saved page, as atabs.PageSettings
object. This object must be given, but all its properties are optional. Any properties not specified here will get the default values listed in thePageSettings
documentation.
Return value
A Promise
that will be fulfilled with a status string when the dialog has closed. The string may be any of:
- "saved"
- "replaced"
- "canceled"
- "not_saved"
- "not_replaced"
Examples
In this example a background script listens for a click on a browser action, then tries to save the currently active tab as a PDF file, then logs the result:
browser.browserAction.onClicked.addListener(() => {
browser.tabs.saveAsPDF({})
.then((status) => {
console.log(status);
});
});
Browser compatibility
BCD tables only load in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论