Merge pull request #14328 from Snuffleupagus/node-examples-page-cleanup

Update (primarily) the Node.js examples to release page resources
This commit is contained in:
Tim van der Meij 2021-12-02 19:44:17 +01:00 committed by GitHub
commit aee4b7c73f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,8 @@ loadingTask.promise
});
console.log("## Text Content");
console.log(strings.join(" "));
// Release page resources.
page.cleanup();
})
.then(function () {
console.log();

View File

@ -103,6 +103,8 @@ const loadingTask = pdfjsLib.getDocument({
);
}
});
// Release page resources.
page.cleanup();
} catch (reason) {
console.log(reason);
}

View File

@ -118,6 +118,8 @@ const loadingTask = pdfjsLib.getDocument({
svgGfx.embedFonts = true;
const svg = await svgGfx.getSVG(opList, viewport);
await writeSvgToFile(svg, getFilePathForPage(pageNum));
// Release page resources.
page.cleanup();
} catch (err) {
console.log(`Error: ${err}`);
}

View File

@ -58,6 +58,8 @@ async function pageLoaded() {
// building SVG and adding that to the DOM
const svg = buildSVG(viewport, textContent);
document.getElementById("pageContainer").appendChild(svg);
// Release page resources.
page.cleanup();
}
document.addEventListener("DOMContentLoaded", function () {