Add support for saving forms

This commit is contained in:
Calixte Denizet 2020-08-03 19:44:04 +02:00 committed by calixteman
parent 3380f2a7fc
commit 1a6816ba98
16 changed files with 1060 additions and 8 deletions

View file

@ -13,10 +13,10 @@
* limitations under the License.
*/
import { isRef, Ref } from "../../src/core/primitives.js";
import { Page, PDFDocument } from "../../src/core/document.js";
import { assert } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { isRef } from "../../src/core/primitives.js";
import { StringStream } from "../../src/core/stream.js";
class DOMFileReaderFactory {
@ -70,6 +70,7 @@ class XRefMock {
streamTypes: Object.create(null),
fontTypes: Object.create(null),
};
this._newRefNum = null;
for (const key in array) {
const obj = array[key];
@ -77,6 +78,17 @@ class XRefMock {
}
}
getNewRef() {
if (this._newRefNum === null) {
this._newRefNum = Object.keys(this._map).length;
}
return Ref.get(this._newRefNum++, 0);
}
resetNewRef() {
this.newRef = null;
}
fetch(ref) {
return this._map[ref.toString()];
}