File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,24 @@ class DocumentData {
5252 }
5353}
5454
55+ class XRefWrapper {
56+ constructor ( entries ) {
57+ this . entries = entries ;
58+ }
59+
60+ fetch ( ref ) {
61+ return ref instanceof Ref ? this . entries [ ref . num ] : ref ;
62+ }
63+ }
64+
5565class PDFEditor {
5666 constructor ( { useObjectStreams = true , title = "" , author = "" } = { } ) {
5767 this . hasSingleFile = false ;
5868 this . currentDocument = null ;
5969 this . oldPages = [ ] ;
6070 this . newPages = [ ] ;
6171 this . xref = [ null ] ;
72+ this . xrefWrapper = new XRefWrapper ( this . xref ) ;
6273 this . newRefCount = 1 ;
6374 [ this . rootRef , this . rootDict ] = this . newDict ;
6475 [ this . infoRef , this . infoDict ] = this . newDict ;
@@ -173,9 +184,11 @@ class PDFEditor {
173184 let dict ;
174185 if ( obj instanceof BaseStream ) {
175186 ( { dict } = obj = obj . getOriginalStream ( ) . clone ( ) ) ;
187+ dict . xref = this . xrefWrapper ;
176188 } else if ( obj instanceof Dict ) {
177189 if ( mustClone ) {
178190 obj = obj . clone ( ) ;
191+ obj . xref = this . xrefWrapper ;
179192 }
180193 dict = obj ;
181194 }
You can’t perform that action at this time.
0 commit comments