Merge pull request #14171 from Snuffleupagus/issue-14170

Prevent run-time errors in Node.js versions with `URL.createObjectURL` support (issue 14170)
This commit is contained in:
Tim van der Meij 2021-10-22 21:07:19 +02:00 committed by GitHub
commit 11f030d301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -110,7 +110,11 @@ const loadingTask = pdfjsLib.getDocument({
console.log();
const opList = await page.getOperatorList();
const svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
const svgGfx = new pdfjsLib.SVGGraphics(
page.commonObjs,
page.objs,
/* forceDataSchema = */ true
);
svgGfx.embedFonts = true;
const svg = await svgGfx.getSVG(opList, viewport);
await writeSvgToFile(svg, getFilePathForPage(pageNum));

View File

@ -1030,7 +1030,7 @@ function createPromiseCapability() {
}
function createObjectURL(data, contentType = "", forceDataSchema = false) {
if (URL.createObjectURL && !forceDataSchema) {
if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) {
return URL.createObjectURL(new Blob([data], { type: contentType }));
}
// Blob/createObjectURL is not available, falling back to data schema.