mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Add support for saving forms
This commit is contained in:
parent
3380f2a7fc
commit
1a6816ba98
16 changed files with 1060 additions and 8 deletions
|
@ -227,6 +227,43 @@ class Page {
|
|||
return stream;
|
||||
}
|
||||
|
||||
save(handler, task, annotationStorage) {
|
||||
const partialEvaluator = new PartialEvaluator({
|
||||
xref: this.xref,
|
||||
handler,
|
||||
pageIndex: this.pageIndex,
|
||||
idFactory: this._localIdFactory,
|
||||
fontCache: this.fontCache,
|
||||
builtInCMapCache: this.builtInCMapCache,
|
||||
globalImageCache: this.globalImageCache,
|
||||
options: this.evaluatorOptions,
|
||||
});
|
||||
|
||||
// Fetch the page's annotations and save the content
|
||||
// in case of interactive form fields.
|
||||
return this._parsedAnnotations.then(function (annotations) {
|
||||
const newRefsPromises = [];
|
||||
for (const annotation of annotations) {
|
||||
if (!isAnnotationRenderable(annotation, "print")) {
|
||||
continue;
|
||||
}
|
||||
newRefsPromises.push(
|
||||
annotation
|
||||
.save(partialEvaluator, task, annotationStorage)
|
||||
.catch(function (reason) {
|
||||
warn(
|
||||
"save - ignoring annotation data during " +
|
||||
`"${task.name}" task: "${reason}".`
|
||||
);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.all(newRefsPromises);
|
||||
});
|
||||
}
|
||||
|
||||
loadResources(keys) {
|
||||
if (!this.resourcesPromise) {
|
||||
// TODO: add async `_getInheritableProperty` and remove this.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue