@@ -135,6 +135,7 @@ export default class PDFDocument {
135
135
throwOnInvalidObject = false ,
136
136
updateMetadata = true ,
137
137
capNumbers = false ,
138
+ password
138
139
} = options ;
139
140
140
141
assertIs ( pdf , 'pdf' , [ 'string' , Uint8Array , ArrayBuffer ] ) ;
@@ -160,7 +161,7 @@ export default class PDFDocument {
160
161
capNumbers ,
161
162
pdfDoc . cryptoFactory
162
163
) . parseDocument ( ) ;
163
- return new PDFDocument ( context , true , updateMetadata , true ) ;
164
+ return new PDFDocument ( context , true , updateMetadata , true , password ) ;
164
165
}
165
166
return pdfDoc ;
166
167
}
@@ -210,7 +211,8 @@ export default class PDFDocument {
210
211
context : PDFContext ,
211
212
ignoreEncryption : boolean ,
212
213
updateMetadata : boolean ,
213
- isDecrypted : boolean
214
+ isDecrypted : boolean ,
215
+ password ?: string
214
216
) {
215
217
assertIs ( context , 'context' , [ [ PDFContext , 'PDFContext' ] ] ) ;
216
218
assertIs ( ignoreEncryption , 'ignoreEncryption' , [ 'boolean' ] ) ;
@@ -222,7 +224,7 @@ export default class PDFDocument {
222
224
if ( this . isEncrypted && ! isDecrypted ) {
223
225
const encryptDict = context . lookup ( context . trailerInfo . Encrypt , PDFDict ) ;
224
226
const fileIds = context . lookup ( context . trailerInfo . ID , PDFArray ) ;
225
- this . cryptoFactory = new CipherTransformFactory ( encryptDict , ( fileIds . get ( 0 ) as PDFHexString ) . asBytes ( ) )
227
+ this . cryptoFactory = new CipherTransformFactory ( encryptDict , ( fileIds . get ( 0 ) as PDFHexString ) . asBytes ( ) , password )
226
228
} else if ( this . isEncrypted ) {
227
229
// context.delete(context.trailerInfo.Encrypt);
228
230
delete context . trailerInfo . Encrypt ;
0 commit comments