Fix coding style in src/core/core.js
This commit is contained in:
parent
53bbdcb0a1
commit
131a16b65e
@ -128,8 +128,9 @@ var Page = (function PageClosure() {
|
|||||||
var xref = this.xref;
|
var xref = this.xref;
|
||||||
var i, n = content.length;
|
var i, n = content.length;
|
||||||
var streams = [];
|
var streams = [];
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i) {
|
||||||
streams.push(xref.fetchIfRef(content[i]));
|
streams.push(xref.fetchIfRef(content[i]));
|
||||||
|
}
|
||||||
stream = new StreamsSequenceStream(streams);
|
stream = new StreamsSequenceStream(streams);
|
||||||
} else if (isStream(content)) {
|
} else if (isStream(content)) {
|
||||||
stream = content;
|
stream = content;
|
||||||
@ -181,17 +182,16 @@ var Page = (function PageClosure() {
|
|||||||
// Properties
|
// Properties
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var partialEvaluator = new PartialEvaluator(
|
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref,
|
||||||
pdfManager, this.xref, handler,
|
handler, this.pageIndex,
|
||||||
this.pageIndex, 'p' + this.pageIndex + '_',
|
'p' + this.pageIndex + '_',
|
||||||
this.idCounters, this.fontCache);
|
this.idCounters,
|
||||||
|
this.fontCache);
|
||||||
|
|
||||||
var dataPromises = Promise.all(
|
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise],
|
||||||
[contentStreamPromise, resourcesPromise], reject);
|
reject);
|
||||||
dataPromises.then(function(data) {
|
dataPromises.then(function(data) {
|
||||||
var contentStream = data[0];
|
var contentStream = data[0];
|
||||||
|
|
||||||
|
|
||||||
var opList = new OperatorList(intent, handler, self.pageIndex);
|
var opList = new OperatorList(intent, handler, self.pageIndex);
|
||||||
|
|
||||||
handler.send('StartRenderPage', {
|
handler.send('StartRenderPage', {
|
||||||
@ -249,10 +249,11 @@ var Page = (function PageClosure() {
|
|||||||
resourcesPromise]);
|
resourcesPromise]);
|
||||||
dataPromises.then(function(data) {
|
dataPromises.then(function(data) {
|
||||||
var contentStream = data[0];
|
var contentStream = data[0];
|
||||||
var partialEvaluator = new PartialEvaluator(
|
var partialEvaluator = new PartialEvaluator(pdfManager, self.xref,
|
||||||
pdfManager, self.xref, handler,
|
handler, self.pageIndex,
|
||||||
self.pageIndex, 'p' + self.pageIndex + '_',
|
'p' + self.pageIndex + '_',
|
||||||
self.idCounters, self.fontCache);
|
self.idCounters,
|
||||||
|
self.fontCache);
|
||||||
|
|
||||||
var bidiTexts = partialEvaluator.getTextContent(contentStream,
|
var bidiTexts = partialEvaluator.getTextContent(contentStream,
|
||||||
self.resources);
|
self.resources);
|
||||||
@ -273,7 +274,7 @@ var Page = (function PageClosure() {
|
|||||||
|
|
||||||
get annotations() {
|
get annotations() {
|
||||||
var annotations = [];
|
var annotations = [];
|
||||||
var annotationRefs = this.annotationRefs || [];
|
var annotationRefs = (this.annotationRefs || []);
|
||||||
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
|
||||||
var annotationRef = annotationRefs[i];
|
var annotationRef = annotationRefs[i];
|
||||||
var annotation = Annotation.fromRef(this.xref, annotationRef);
|
var annotation = Annotation.fromRef(this.xref, annotationRef);
|
||||||
@ -297,12 +298,13 @@ var Page = (function PageClosure() {
|
|||||||
*/
|
*/
|
||||||
var PDFDocument = (function PDFDocumentClosure() {
|
var PDFDocument = (function PDFDocumentClosure() {
|
||||||
function PDFDocument(pdfManager, arg, password) {
|
function PDFDocument(pdfManager, arg, password) {
|
||||||
if (isStream(arg))
|
if (isStream(arg)) {
|
||||||
init.call(this, pdfManager, arg, password);
|
init.call(this, pdfManager, arg, password);
|
||||||
else if (isArrayBuffer(arg))
|
} else if (isArrayBuffer(arg)) {
|
||||||
init.call(this, pdfManager, new Stream(arg), password);
|
init.call(this, pdfManager, new Stream(arg), password);
|
||||||
else
|
} else {
|
||||||
error('PDFDocument: Unknown argument type');
|
error('PDFDocument: Unknown argument type');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(pdfManager, stream, password) {
|
function init(pdfManager, stream, password) {
|
||||||
@ -317,16 +319,18 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
var pos = stream.pos;
|
var pos = stream.pos;
|
||||||
var end = stream.end;
|
var end = stream.end;
|
||||||
var strBuf = [];
|
var strBuf = [];
|
||||||
if (pos + limit > end)
|
if (pos + limit > end) {
|
||||||
limit = end - pos;
|
limit = end - pos;
|
||||||
|
}
|
||||||
for (var n = 0; n < limit; ++n) {
|
for (var n = 0; n < limit; ++n) {
|
||||||
strBuf.push(String.fromCharCode(stream.getByte()));
|
strBuf.push(String.fromCharCode(stream.getByte()));
|
||||||
}
|
}
|
||||||
var str = strBuf.join('');
|
var str = strBuf.join('');
|
||||||
stream.pos = pos;
|
stream.pos = pos;
|
||||||
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
|
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
return false; /* not found */
|
return false; /* not found */
|
||||||
|
}
|
||||||
stream.pos += index;
|
stream.pos += index;
|
||||||
return true; /* found */
|
return true; /* found */
|
||||||
}
|
}
|
||||||
@ -399,16 +403,18 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
if (linearization) {
|
if (linearization) {
|
||||||
// Find end of first obj.
|
// Find end of first obj.
|
||||||
stream.reset();
|
stream.reset();
|
||||||
if (find(stream, 'endobj', 1024))
|
if (find(stream, 'endobj', 1024)) {
|
||||||
startXRef = stream.pos + 6;
|
startXRef = stream.pos + 6;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Find startxref by jumping backward from the end of the file.
|
// Find startxref by jumping backward from the end of the file.
|
||||||
var step = 1024;
|
var step = 1024;
|
||||||
var found = false, pos = stream.end;
|
var found = false, pos = stream.end;
|
||||||
while (!found && pos > 0) {
|
while (!found && pos > 0) {
|
||||||
pos -= step - 'startxref'.length;
|
pos -= step - 'startxref'.length;
|
||||||
if (pos < 0)
|
if (pos < 0) {
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
}
|
||||||
stream.pos = pos;
|
stream.pos = pos;
|
||||||
found = find(stream, 'startxref', step, true);
|
found = find(stream, 'startxref', step, true);
|
||||||
}
|
}
|
||||||
@ -424,8 +430,9 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
ch = stream.getByte();
|
ch = stream.getByte();
|
||||||
}
|
}
|
||||||
startXRef = parseInt(str, 10);
|
startXRef = parseInt(str, 10);
|
||||||
if (isNaN(startXRef))
|
if (isNaN(startXRef)) {
|
||||||
startXRef = 0;
|
startXRef = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// shadow the prototype getter with a data property
|
// shadow the prototype getter with a data property
|
||||||
@ -434,8 +441,9 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
get mainXRefEntriesOffset() {
|
get mainXRefEntriesOffset() {
|
||||||
var mainXRefEntriesOffset = 0;
|
var mainXRefEntriesOffset = 0;
|
||||||
var linearization = this.linearization;
|
var linearization = this.linearization;
|
||||||
if (linearization)
|
if (linearization) {
|
||||||
mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
|
mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
|
||||||
|
}
|
||||||
// shadow the prototype getter with a data property
|
// shadow the prototype getter with a data property
|
||||||
return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
|
return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
|
||||||
},
|
},
|
||||||
@ -496,8 +504,8 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
var value = infoDict.get(key);
|
var value = infoDict.get(key);
|
||||||
// Make sure the value conforms to the spec.
|
// Make sure the value conforms to the spec.
|
||||||
if (validEntries[key](value)) {
|
if (validEntries[key](value)) {
|
||||||
docInfo[key] = typeof value !== 'string' ? value :
|
docInfo[key] = (typeof value !== 'string' ?
|
||||||
stringToPDFString(value);
|
value : stringToPDFString(value));
|
||||||
} else {
|
} else {
|
||||||
info('Bad value in document info for "' + key + '"');
|
info('Bad value in document info for "' + key + '"');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user