Merge pull request #16706 from calixteman/bug1844036
[Editor] Don't forget to generate non-missing images when printing (bug 1844036)
This commit is contained in:
commit
e83febcbb6
@ -450,7 +450,7 @@ class Page {
|
||||
|
||||
const { isOffscreenCanvasSupported } = this.evaluatorOptions;
|
||||
if (missingBitmaps.size > 0) {
|
||||
const annotationWithBitmaps = [];
|
||||
const annotationWithBitmaps = newAnnotations.slice();
|
||||
for (const [key, annotation] of annotationStorage) {
|
||||
if (!key.startsWith(AnnotationEditorPrefix)) {
|
||||
continue;
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -7964,5 +7964,49 @@
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bug1844036",
|
||||
"file": "pdfs/tracemonkey.pdf",
|
||||
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
|
||||
"rounds": 1,
|
||||
"lastPage": 2,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"pdfjs_internal_editor_0": {
|
||||
"annotationType": 13,
|
||||
"pageIndex": 0,
|
||||
"bitmapName": "firefox_logo.png",
|
||||
"bitmapId": "image_c29eaeb9-8839-4a09-bf7c-75a5785805cd_0",
|
||||
"rect": [37.5, 32.406246185302734, 496.5000057220459, 519.1875],
|
||||
"rotation": 0
|
||||
},
|
||||
"pdfjs_internal_editor_1": {
|
||||
"annotationType": 13,
|
||||
"bitmapId": "image_c29eaeb9-8839-4a09-bf7c-75a5785805cd_0",
|
||||
"pageIndex": 1,
|
||||
"rect": [
|
||||
458.06250572204584,
|
||||
473.04686737060547,
|
||||
571.5000057220459,
|
||||
582.7187461853027
|
||||
],
|
||||
"rotation": 0
|
||||
},
|
||||
"pdfjs_internal_editor_2": {
|
||||
"annotationType": 13,
|
||||
"bitmapName": "firefox_logo.svg",
|
||||
"bitmapId": "image_c29eaeb9-8839-4a09-bf7c-75a5785805cd_1",
|
||||
"pageIndex": 1,
|
||||
"rect": [
|
||||
182.04545454545453,
|
||||
607.011364329945,
|
||||
424.0227231112393,
|
||||
687
|
||||
],
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user