1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Ensure that saving, in the viewer, works for partially loaded documents

Currently saving a modified PDF document may fail *intermittently*, if it's triggered before the entire document has been downloaded.
When saving was originally added we only supported forms, and such PDF documents are usually small/simple enough for this issue to be difficult to trigger. However, with editing-support now available as well it's possible to modify much larger documents and this issue thus becomes easier to trigger.

One way to reproduce this issue *consistently* is to:
 - Open http://localhost:8888/web/viewer.html?file=/test/pdfs/pdf.pdf#disableHistory=true&disableStream=true&disableAutoFetch=true
 - Add an annotation on the first page, it doesn't matter what kind.
 - Save the document.
 - Open the resulting document, and notice that with the `master` branch the annotation is missing.
This commit is contained in:
Jonas Jenwald 2024-06-15 17:39:59 +02:00
parent 2effc96021
commit 7c5e9cf8be

View file

@ -1109,8 +1109,6 @@ const PDFViewerApplication = {
await this.pdfScriptingManager.dispatchWillSave();
try {
this._ensureDownloadComplete();
const data = await this.pdfDocument.saveDocument();
this.downloadManager.download(
data,
@ -1119,8 +1117,7 @@ const PDFViewerApplication = {
options
);
} catch (reason) {
// When the PDF document isn't ready, or the PDF file is still
// downloading, simply fallback to a "regular" download.
// When the PDF document isn't ready, fallback to a "regular" download.
console.error(`Error when saving the document: ${reason.message}`);
await this.download(options);
} finally {