PDFFileElement: close() method

Works in all major browsers
Since July 2026

WebPDF works in Chrome and Edge 125, Firefox 153 and Safari 18, on desktop and mobile, and in every later version: the oldest versions its PDF.js build supports, which already have every platform feature WebPDF needs. Since July 2026, that is every major browser.

The close() method of the PDFFileElement interface forgets the files a <pdf-file> remembers from PDFFileElement.open() and the save pickers.

After close(), PDFFileElement.save() asks where to save again. The document stays loaded.

Syntax

js
close()

Parameters

None.

Return value

An Array of the FileSystemFileHandle objects the file forgot: its PDF and its XFDF. Without the File System Access API the file remembers no files, so the array is empty.

Exceptions

None.

Examples

Starting afresh

js
const [pdfHandle] = document.querySelector("pdf-file").close();

Specifications

Not part of any specification. <pdf-file> and <pdf-page> are autonomous custom elements defined by WebPDF.pro.

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
close()
1251251531111812515383182712518
  • close() · Firefox, Safari, Chrome Android, Firefox for Android, Opera Android, Safari on iOS, Samsung Internet, WebView Android, WebView on iOS: Without the File System Access API (Chrome Android 132, Opera Android 87, Samsung Internet 29 and WebView Android 132 have it), opening falls back to <input type=file> and saving to a download.

Legend

Full support
See implementation notes.

See also