mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-12 13:11:07 +02:00
Merge pull request #20734 from Snuffleupagus/GetOperatorList-fix-transfers
Include transfers correctly in the "GetOperatorList" message (PR 16588 follow-up)
This commit is contained in:
commit
17a4d2e123
@ -330,15 +330,21 @@ class AnnotationStorage {
|
||||
* contents. (Necessary since printing is triggered synchronously in browsers.)
|
||||
*/
|
||||
class PrintAnnotationStorage extends AnnotationStorage {
|
||||
#serializable;
|
||||
#serializable = SerializableEmpty;
|
||||
|
||||
constructor(parent) {
|
||||
super();
|
||||
const { map, hash, transfer } = parent.serializable;
|
||||
|
||||
const { serializable } = parent;
|
||||
if (serializable === SerializableEmpty) {
|
||||
return;
|
||||
}
|
||||
const { map, hash, transfer } = serializable;
|
||||
// Create a *copy* of the data, since Objects are passed by reference in JS.
|
||||
const clone = structuredClone(map, transfer ? { transfer } : null);
|
||||
|
||||
this.#serializable = { map: clone, hash, transfer };
|
||||
// The `PrintAnnotationStorage` instance is re-used for all pages,
|
||||
// hence we cannot transfer the data since that breaks printing.
|
||||
this.#serializable = { map: clone, hash, transfer: [] };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1898,6 +1898,7 @@ class PDFPageProxy {
|
||||
annotationStorage: map,
|
||||
modifiedIds,
|
||||
},
|
||||
/* queueingStrategy = */ undefined,
|
||||
transfer
|
||||
);
|
||||
const reader = readableStream.getReader();
|
||||
|
||||
@ -803,6 +803,10 @@ class Driver {
|
||||
}
|
||||
|
||||
task.pdfDoc = doc;
|
||||
if (!task.save && task.print && task.annotationStorage) {
|
||||
doc.annotationStorage._setValues(task.annotationStorage);
|
||||
task.printAnnotationStorage = doc.annotationStorage.print;
|
||||
}
|
||||
task.optionalContentConfigPromise = doc.getOptionalContentConfig({
|
||||
intent: task.print ? "print" : "display",
|
||||
});
|
||||
@ -969,7 +973,7 @@ class Driver {
|
||||
pageColors = null,
|
||||
partialCrop = null;
|
||||
|
||||
if (task.annotationStorage) {
|
||||
if (!task.print && task.annotationStorage) {
|
||||
task.pdfDoc.annotationStorage._setValues(task.annotationStorage);
|
||||
}
|
||||
|
||||
@ -1079,6 +1083,8 @@ class Driver {
|
||||
} else if (renderPrint) {
|
||||
if (task.annotationStorage) {
|
||||
renderContext.annotationMode = AnnotationMode.ENABLE_STORAGE;
|
||||
renderContext.printAnnotationStorage =
|
||||
task.printAnnotationStorage;
|
||||
}
|
||||
renderContext.intent = "print";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user