File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -330,15 +330,21 @@ class AnnotationStorage {
330330 * contents. (Necessary since printing is triggered synchronously in browsers.)
331331 */
332332class PrintAnnotationStorage extends AnnotationStorage {
333- #serializable;
333+ #serializable = SerializableEmpty ;
334334
335335 constructor ( parent ) {
336336 super ( ) ;
337- const { map, hash, transfer } = parent . serializable ;
337+
338+ const { serializable } = parent ;
339+ if ( serializable === SerializableEmpty ) {
340+ return ;
341+ }
342+ const { map, hash, transfer } = serializable ;
338343 // Create a *copy* of the data, since Objects are passed by reference in JS.
339344 const clone = structuredClone ( map , transfer ? { transfer } : null ) ;
340-
341- this . #serializable = { map : clone , hash, transfer } ;
345+ // The `PrintAnnotationStorage` instance is re-used for all pages,
346+ // hence we cannot transfer the data since that breaks printing.
347+ this . #serializable = { map : clone , hash, transfer : [ ] } ;
342348 }
343349
344350 /**
Original file line number Diff line number Diff line change @@ -1898,6 +1898,7 @@ class PDFPageProxy {
18981898 annotationStorage : map ,
18991899 modifiedIds,
19001900 } ,
1901+ /* queueingStrategy = */ undefined ,
19011902 transfer
19021903 ) ;
19031904 const reader = readableStream . getReader ( ) ;
Original file line number Diff line number Diff line change @@ -803,6 +803,10 @@ class Driver {
803803 }
804804
805805 task . pdfDoc = doc ;
806+ if ( ! task . save && task . print && task . annotationStorage ) {
807+ doc . annotationStorage . _setValues ( task . annotationStorage ) ;
808+ task . printAnnotationStorage = doc . annotationStorage . print ;
809+ }
806810 task . optionalContentConfigPromise = doc . getOptionalContentConfig ( {
807811 intent : task . print ? "print" : "display" ,
808812 } ) ;
@@ -969,7 +973,7 @@ class Driver {
969973 pageColors = null ,
970974 partialCrop = null ;
971975
972- if ( task . annotationStorage ) {
976+ if ( ! task . print && task . annotationStorage ) {
973977 task . pdfDoc . annotationStorage . _setValues ( task . annotationStorage ) ;
974978 }
975979
@@ -1079,6 +1083,8 @@ class Driver {
10791083 } else if ( renderPrint ) {
10801084 if ( task . annotationStorage ) {
10811085 renderContext . annotationMode = AnnotationMode . ENABLE_STORAGE ;
1086+ renderContext . printAnnotationStorage =
1087+ task . printAnnotationStorage ;
10821088 }
10831089 renderContext . intent = "print" ;
10841090 }
You can’t perform that action at this time.
0 commit comments