1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Refactor the password handling so that it's stored in the PdfManagers, instead of in the XRef

We're already passing in a, currently unused, `PdfManager` instance when initializing the `XRef`. To avoid having to pass a single `password` parameter around, we could thus simply get the `password` through the `PdfManager` instance instead.
This commit is contained in:
Jonas Jenwald 2017-01-03 12:39:38 +01:00
parent 27513cd23b
commit 14b8523314
3 changed files with 19 additions and 16 deletions

View file

@ -370,22 +370,20 @@ var PDFDocument = (function PDFDocumentClosure() {
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' +
'\x00\x00\x00\x00\x00\x00\x00\x00\x00';
function PDFDocument(pdfManager, arg, password) {
function PDFDocument(pdfManager, arg) {
var stream;
if (isStream(arg)) {
init.call(this, pdfManager, arg, password);
stream = arg;
} else if (isArrayBuffer(arg)) {
init.call(this, pdfManager, new Stream(arg), password);
stream = new Stream(arg);
} else {
error('PDFDocument: Unknown argument type');
}
}
function init(pdfManager, stream, password) {
assert(stream.length > 0, 'stream must have data');
this.pdfManager = pdfManager;
this.stream = stream;
var xref = new XRef(this.stream, password, pdfManager);
this.xref = xref;
this.xref = new XRef(stream, pdfManager);
}
function find(stream, needle, limit, backwards) {