Let the PdfManager.requestLoadedStream method return the stream

*This is very old code, and it could thus do with some simplification.*

Note how in the `src/core/worker.js` file we're combining both the `PdfManager.requestLoadedStream` and `PdfManager.onLoadedStream` methods in order to access the stream-data. This seems unnecessary, and it's simple enough to always let the `PdfManager.requestLoadedStream` method return the stream-data as well.
This commit is contained in:
Jonas Jenwald 2022-10-24 16:59:25 +02:00
parent 987062c302
commit bcffbf74f3
2 changed files with 11 additions and 13 deletions

View file

@ -398,8 +398,7 @@ class WorkerMessageHandler {
onFailure(reason);
return;
}
pdfManager.requestLoadedStream();
pdfManager.onLoadedStream().then(function () {
pdfManager.requestLoadedStream().then(function () {
ensureNotTerminated();
loadDocument(true).then(onSuccess, onFailure);
@ -521,8 +520,7 @@ class WorkerMessageHandler {
});
handler.on("GetData", function wphSetupGetData(data) {
pdfManager.requestLoadedStream();
return pdfManager.onLoadedStream().then(function (stream) {
return pdfManager.requestLoadedStream().then(function (stream) {
return stream.bytes;
});
});
@ -559,20 +557,18 @@ class WorkerMessageHandler {
handler.on(
"SaveDocument",
function ({ isPureXfa, numPages, annotationStorage, filename }) {
pdfManager.requestLoadedStream();
const newAnnotationsByPage = !isPureXfa
? getNewAnnotationsMap(annotationStorage)
: null;
const promises = [
pdfManager.onLoadedStream(),
pdfManager.requestLoadedStream(),
pdfManager.ensureCatalog("acroForm"),
pdfManager.ensureCatalog("acroFormRef"),
pdfManager.ensureDoc("xref"),
pdfManager.ensureDoc("startXRef"),
];
const newAnnotationsByPage = !isPureXfa
? getNewAnnotationsMap(annotationStorage)
: null;
if (newAnnotationsByPage) {
for (const [pageIndex, annotations] of newAnnotationsByPage) {
promises.push(