mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-28 09:57:21 +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:
parent
2effc96021
commit
7c5e9cf8be
@ -1109,8 +1109,6 @@ const PDFViewerApplication = {
|
|||||||
await this.pdfScriptingManager.dispatchWillSave();
|
await this.pdfScriptingManager.dispatchWillSave();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._ensureDownloadComplete();
|
|
||||||
|
|
||||||
const data = await this.pdfDocument.saveDocument();
|
const data = await this.pdfDocument.saveDocument();
|
||||||
this.downloadManager.download(
|
this.downloadManager.download(
|
||||||
data,
|
data,
|
||||||
@ -1119,8 +1117,7 @@ const PDFViewerApplication = {
|
|||||||
options
|
options
|
||||||
);
|
);
|
||||||
} catch (reason) {
|
} catch (reason) {
|
||||||
// When the PDF document isn't ready, or the PDF file is still
|
// When the PDF document isn't ready, fallback to a "regular" download.
|
||||||
// downloading, simply fallback to a "regular" download.
|
|
||||||
console.error(`Error when saving the document: ${reason.message}`);
|
console.error(`Error when saving the document: ${reason.message}`);
|
||||||
await this.download(options);
|
await this.download(options);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user