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

Add a new BaseStream.getString(...) method to replace manual bytesToString(BaseStream.getBytes(...)) calls

Given that the `bytesToString(BaseStream.getBytes(...))` pattern is somewhat common throughout the `src/core/` code, it cannot hurt to add a new `BaseStream`-method which handles that case internally.
This commit is contained in:
Jonas Jenwald 2021-05-01 12:11:09 +02:00
parent f6f335173d
commit 3624f9eac7
6 changed files with 33 additions and 32 deletions

View file

@ -31,7 +31,7 @@ function writeDict(dict, buffer, transform) {
function writeStream(stream, buffer, transform) {
writeDict(stream.dict, buffer, transform);
buffer.push(" stream\n");
let string = bytesToString(stream.getBytes());
let string = stream.getString();
if (transform !== null) {
string = transform.encryptString(string);
}
@ -129,7 +129,7 @@ function updateXFA(datasetsRef, newRefs, xref) {
return;
}
const datasets = xref.fetchIfRef(datasetsRef);
const str = bytesToString(datasets.getBytes());
const str = datasets.getString();
const xml = new SimpleXMLParser({ hasAttributes: true }).parseFromString(str);
for (const { xfa } of newRefs) {