Use the fetchData helper function in more cases

- Extend the `fetchData` helper function to also support fetching of "blob" data.

 - Use the `fetchData` helper function more in the code-base, when fetching non-PDF data. Given that the Fetch API isn't supported for all protocols, this should improve compatibility for the PDF.js library.
This commit is contained in:
Jonas Jenwald 2023-11-24 12:56:22 +01:00
parent d679078beb
commit fd7a7e2859
3 changed files with 19 additions and 16 deletions

View file

@ -27,7 +27,12 @@ import {
Util,
warn,
} from "../../shared/util.js";
import { getColorValues, getRGB, PixelsPerInch } from "../display_utils.js";
import {
fetchData,
getColorValues,
getRGB,
PixelsPerInch,
} from "../display_utils.js";
function bindEvents(obj, element, names) {
for (const name of names) {
@ -116,12 +121,7 @@ class ImageManager {
let image;
if (typeof rawData === "string") {
data.url = rawData;
const response = await fetch(rawData);
if (!response.ok) {
throw new Error(response.statusText);
}
image = await response.blob();
image = await fetchData(rawData, "blob");
} else {
image = data.file = rawData;
}