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

js
let saving = browser.tabs.saveAsPDF(
  pageSettings   // object
)

Parameters

pageSettings

object. Settings for the saved page, as a 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 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:

js
browser.browserAction.onClicked.addListener(() => {
  browser.tabs.saveAsPDF({}).then((status) => {
    console.log(status);
  });
});

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
saveAsPDF
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox 56 – 80 (Release date: 2017-09-28)
footnote This function does not work on macOS.
Firefox – Full support
Firefox 81 (Release date: 2020-09-22)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Has more compatibility info.