[Editor] Add support for printing/saving newly added Stamp annotations

In order to minimize the size the of a saved pdf, we generate only one
image and use a reference in each annotation using it.
When printing, it's slightly different since we have to render each page
independantly but we use the same image within a page.
This commit is contained in:
Calixte Denizet 2023-06-22 19:48:40 +02:00
parent ccb72073b0
commit 599b9498f2
9 changed files with 519 additions and 19 deletions

View file

@ -1812,6 +1812,15 @@ class PDFPageProxy {
);
}
const transfers = [];
if (annotationStorageMap) {
for (const annotation of annotationStorageMap.values()) {
if (annotation.bitmap) {
transfers.push(annotation.bitmap);
}
}
}
const readableStream = this._transport.messageHandler.sendWithStream(
"GetOperatorList",
{
@ -1819,7 +1828,8 @@ class PDFPageProxy {
intent: renderingIntent,
cacheKey,
annotationStorage: annotationStorageMap,
}
},
transfers
);
const reader = readableStream.getReader();
@ -2898,13 +2908,26 @@ class WorkerTransport {
"please use the getData-method instead."
);
}
const annotationStorage = this.annotationStorage.serializable;
const transfers = [];
if (annotationStorage) {
for (const annotation of annotationStorage.values()) {
if (annotation.bitmap) {
transfers.push(annotation.bitmap);
}
}
}
return this.messageHandler
.sendWithPromise("SaveDocument", {
isPureXfa: !!this._htmlForXfa,
numPages: this._numPages,
annotationStorage: this.annotationStorage.serializable,
filename: this._fullReader?.filename ?? null,
})
.sendWithPromise(
"SaveDocument",
{
isPureXfa: !!this._htmlForXfa,
numPages: this._numPages,
annotationStorage,
filename: this._fullReader?.filename ?? null,
},
transfers
)
.finally(() => {
this.annotationStorage.resetModified();
});