|
|
@ -14,8 +14,8 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/* globals assert, calculateMD5, Catalog, Dict, error, info, isArray, |
|
|
|
/* globals assert, bytesToString, calculateMD5, Catalog, Dict, error, info, |
|
|
|
isArrayBuffer, isName, isStream, isString, createPromiseCapability, |
|
|
|
isArray, isArrayBuffer, isName, isStream, isString, |
|
|
|
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer, |
|
|
|
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer, |
|
|
|
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef, |
|
|
|
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef, |
|
|
|
MissingDataException, Promise, Annotation, ObjectLoader, OperatorList |
|
|
|
MissingDataException, Promise, Annotation, ObjectLoader, OperatorList |
|
|
@ -301,14 +301,10 @@ var PDFDocument = (function PDFDocumentClosure() { |
|
|
|
function find(stream, needle, limit, backwards) { |
|
|
|
function find(stream, needle, limit, backwards) { |
|
|
|
var pos = stream.pos; |
|
|
|
var pos = stream.pos; |
|
|
|
var end = stream.end; |
|
|
|
var end = stream.end; |
|
|
|
var strBuf = []; |
|
|
|
|
|
|
|
if (pos + limit > end) { |
|
|
|
if (pos + limit > end) { |
|
|
|
limit = end - pos; |
|
|
|
limit = end - pos; |
|
|
|
} |
|
|
|
} |
|
|
|
for (var n = 0; n < limit; ++n) { |
|
|
|
var str = bytesToString(stream.getBytes(limit)); |
|
|
|
strBuf.push(String.fromCharCode(stream.getByte())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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) { |
|
|
|