mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
[Editor] Don't forget to generate non-missing images when printing (bug 1844036)
This commit is contained in:
parent
43fc78899f
commit
7ac3bf6f17
3 changed files with 70 additions and 4 deletions
|
@ -492,13 +492,35 @@ class Driver {
|
|||
|
||||
if (task.annotationStorage) {
|
||||
for (const annotation of Object.values(task.annotationStorage)) {
|
||||
if (annotation.bitmapName) {
|
||||
const { bitmapName } = annotation;
|
||||
if (bitmapName) {
|
||||
promise = promise.then(async doc => {
|
||||
const response = await fetch(
|
||||
new URL(`./images/${annotation.bitmapName}`, window.location)
|
||||
new URL(`./images/${bitmapName}`, window.location)
|
||||
);
|
||||
const blob = await response.blob();
|
||||
annotation.bitmap = await createImageBitmap(blob);
|
||||
if (bitmapName.endsWith(".svg")) {
|
||||
const image = new Image();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const imagePromise = new Promise((resolve, reject) => {
|
||||
image.onload = () => {
|
||||
const canvas = new OffscreenCanvas(
|
||||
image.width,
|
||||
image.height
|
||||
);
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0);
|
||||
annotation.bitmap = canvas.transferToImageBitmap();
|
||||
URL.revokeObjectURL(url);
|
||||
resolve();
|
||||
};
|
||||
image.onerror = reject;
|
||||
});
|
||||
image.src = url;
|
||||
await imagePromise;
|
||||
} else {
|
||||
annotation.bitmap = await createImageBitmap(blob);
|
||||
}
|
||||
|
||||
return doc;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue