Support password and add the relevant l10n strings

This commit is contained in:
Jakob Miland 2012-05-14 20:45:07 +02:00
parent b7ea788b0c
commit 0a30d3961b
9 changed files with 122 additions and 39 deletions

View file

@ -320,19 +320,19 @@ var Page = (function PageClosure() {
* `PDFDocument` objects on the main thread created.
*/
var PDFDocument = (function PDFDocumentClosure() {
function PDFDocument(arg, callback) {
function PDFDocument(arg, password) {
if (isStream(arg))
init.call(this, arg);
init.call(this, arg, password);
else if (isArrayBuffer(arg))
init.call(this, new Stream(arg));
init.call(this, new Stream(arg), password);
else
error('PDFDocument: Unknown argument type');
}
function init(stream) {
function init(stream, password) {
assertWellFormed(stream.length > 0, 'stream must have data');
this.stream = stream;
this.setup();
this.setup(password);
this.acroForm = this.catalog.catDict.get('AcroForm');
}
@ -423,11 +423,12 @@ var PDFDocument = (function PDFDocumentClosure() {
}
// May not be a PDF file, continue anyway.
},
setup: function PDFDocument_setup(ownerPassword, userPassword) {
setup: function PDFDocument_setup(password) {
this.checkHeader();
var xref = new XRef(this.stream,
this.startXRef,
this.mainXRefEntriesOffset);
this.mainXRefEntriesOffset,
password);
this.xref = xref;
this.catalog = new Catalog(xref);
},