1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58: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

@ -15,7 +15,6 @@
import {
assert,
bytesToString,
FormatError,
info,
InvalidPDFException,
@ -811,7 +810,7 @@ class PDFDocument {
};
if (isStream(xfa) && !xfa.isEmpty) {
try {
entries["xdp:xdp"] = stringToUTF8String(bytesToString(xfa.getBytes()));
entries["xdp:xdp"] = stringToUTF8String(xfa.getString());
return entries;
} catch (_) {
warn("XFA - Invalid utf-8 string.");
@ -841,7 +840,7 @@ class PDFDocument {
continue;
}
try {
entries[name] = stringToUTF8String(bytesToString(data.getBytes()));
entries[name] = stringToUTF8String(data.getString());
} catch (_) {
warn("XFA - Invalid utf-8 string.");
return null;