mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-04 14:15:48 +02:00
Merge pull request #20829 from Snuffleupagus/Blob-bytes
Start using `Blob.prototype.bytes()` in the code-base
This commit is contained in:
commit
3f75c4e511
@ -5105,9 +5105,9 @@ class StampAnnotation extends MarkupAnnotation {
|
|||||||
ctx.drawImage(bitmap, 0, 0);
|
ctx.drawImage(bitmap, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const jpegBufferPromise = canvas
|
const jpegBytesPromise = canvas
|
||||||
.convertToBlob({ type: "image/jpeg", quality: 1 })
|
.convertToBlob({ type: "image/jpeg", quality: 1 })
|
||||||
.then(blob => blob.arrayBuffer());
|
.then(blob => blob.bytes());
|
||||||
|
|
||||||
const xobjectName = Name.get("XObject");
|
const xobjectName = Name.get("XObject");
|
||||||
const imageName = Name.get("Image");
|
const imageName = Name.get("Image");
|
||||||
@ -5144,7 +5144,7 @@ class StampAnnotation extends MarkupAnnotation {
|
|||||||
|
|
||||||
smaskStream = new Stream(alphaBuffer, 0, 0, smask);
|
smaskStream = new Stream(alphaBuffer, 0, 0, smask);
|
||||||
}
|
}
|
||||||
const imageStream = new Stream(await jpegBufferPromise, 0, 0, image);
|
const imageStream = new Stream(await jpegBytesPromise, 0, 0, image);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
imageStream,
|
imageStream,
|
||||||
|
|||||||
@ -1259,6 +1259,17 @@ if (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Blob/bytes#browser_compatibility
|
||||||
|
if (
|
||||||
|
typeof PDFJSDev !== "undefined" &&
|
||||||
|
!PDFJSDev.test("SKIP_BABEL") &&
|
||||||
|
typeof Blob.prototype.bytes !== "function"
|
||||||
|
) {
|
||||||
|
Blob.prototype.bytes = async function () {
|
||||||
|
return new Uint8Array(await this.arrayBuffer());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes#browser_compatibility
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes#browser_compatibility
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev !== "undefined" &&
|
typeof PDFJSDev !== "undefined" &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user