mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Simplify the PDFDocument.fingerprint
method slightly
The way that this method handles documents without an `ID` entry in the Trailer dictionary feels overly complicated to me. Hence this patch adds `getByteRange` methods to the various Stream implementations[1], and utilize that rather than manually calling `ensureRange` when computing a fallback `fingerprint`. --- [1] Note that `PDFDocument` is only ever initialized with either a `Stream` or a `ChunkedStream`, hence why the `DecodeStream.getByteRange` method isn't implemented.
This commit is contained in:
parent
c7de6dbe41
commit
bea15b6ce5
3 changed files with 30 additions and 10 deletions
|
@ -218,6 +218,12 @@ class ChunkedStream {
|
|||
}
|
||||
|
||||
getByteRange(begin, end) {
|
||||
if (begin < 0) {
|
||||
begin = 0;
|
||||
}
|
||||
if (end > this.end) {
|
||||
end = this.end;
|
||||
}
|
||||
this.ensureRange(begin, end);
|
||||
return this.bytes.subarray(begin, end);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue