Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/tabs/saveaspdf/index.md
6554 views
------{{AddonSidebar()}}
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
Parameters
pageSettings:
object. Settings for the saved page, as a {{WebExtAPIRef("tabs.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 the {{WebExtAPIRef("tabs.PageSettings", "PageSettings")}} 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 compatibility
{{Compat}}