[api-major] Remove the PDFDocumentProxy.prototype.destroy method

This is a left-over from very old code, which pre-dates the introduction of the `PDFDocumentLoadingTask` and it's nothing more than an alias for its `destroy` method.
Given that `PDFDocumentProxy` already provides a way to access the underlying `PDFDocumentLoadingTask` instance, it shouldn't be necessary to have an alias for one of its methods.

*Please note:* For any existing code relying on the removed method, updating it should be as simple as replacing `pdfDocument.destroy()` with `pdfDocument.loadingTask.destroy()`.

---

[1] If the `PDFDocumentProxy` class was added today, there's no chance that it'd include a `destroy` method.
This commit is contained in:
Jonas Jenwald 2026-05-09 12:22:10 +02:00
parent 2e7a2215e3
commit 43ce1bb491
4 changed files with 3 additions and 10 deletions

View File

@ -1026,13 +1026,6 @@ class PDFDocumentProxy {
return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
}
/**
* Destroys the current document instance and terminates the worker.
*/
destroy() {
return this.loadingTask.destroy();
}
/**
* @param {RefProxy} ref - The page reference.
* @returns {number | null} The page number, if it's cached.

View File

@ -969,7 +969,7 @@ class Driver {
// Wipe out the link to the pdfdoc so it can be GC'ed.
for (const task of [this.currentTask, ...this.taskQueue]) {
if (task?.pdfDoc) {
destroyedPromises.push(task.pdfDoc.destroy());
destroyedPromises.push(task.pdfDoc.loadingTask.destroy());
delete task.pdfDoc;
}
}

View File

@ -3203,7 +3203,7 @@ describe("api", function () {
params.url = url.href;
loadingTask = getDocument(params);
return loadingTask.promise
.then(pdf => pdf.destroy())
.then(() => loadingTask.destroy())
.then(
function () {
expect(expectSuccess).toEqual(true);

View File

@ -95,7 +95,7 @@ async function openDocument(source, name) {
if (pdfDoc) {
pageView.reset();
await pdfDoc.destroy();
await pdfDoc.loadingTask.destroy();
pdfDoc = null;
}