Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/editor/pdf_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,7 @@ class PDFEditor {
acroForm.set("SigFlags", this.acroFormSigFlags);
}
acroForm.setIfArray("CO", this.acroFormCalculationOrder);
acroForm.setIfDict("DR", this.acroFormDefaultResources);
acroForm.setIfDefined("DR", this.acroFormDefaultResources);
if (this.acroFormDefaultAppearance) {
acroForm.set("DA", this.acroFormDefaultAppearance);
}
Expand Down
28 changes: 28 additions & 0 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7629,6 +7629,34 @@ small scripts as well as for`);
await loadingTask.destroy();
});

it("preserves indirect AcroForm default resources", async function () {
const pdfData = assemblePdf([
"1 0 obj\n<< /Type /Catalog /Pages 2 0 R " +
"/AcroForm 6 0 R >>\nendobj\n",
"2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n",
"3 0 obj\n<< /Type /Page /Parent 2 0 R " +
"/MediaBox [0 0 100 100] /Annots [4 0 R] >>\nendobj\n",
"4 0 obj\n<< /Type /Annot /Subtype /Widget /FT /Tx /T (field) " +
"/Rect [0 0 20 10] >>\nendobj\n",
"5 0 obj\n<< /Font << /Helv 7 0 R >> >>\nendobj\n",
"6 0 obj\n<< /Fields [4 0 R] /DR 5 0 R " +
"/DA (/Helv 10 Tf) >>\nendobj\n",
"7 0 obj\n<< /Type /Font /Subtype /Type1 " +
"/BaseFont /Helvetica >>\nendobj\n",
]);

let loadingTask = getDocument({ data: pdfData });
let pdfDoc = await loadingTask.promise;
const data = await pdfDoc.extractPages([{ document: null }]);
expect(countMarker(data, "/DR ")).toEqual(1);
await loadingTask.destroy();

loadingTask = getDocument({ data });
pdfDoc = await loadingTask.promise;
expect(Object.keys(await pdfDoc.getFieldObjects())).toEqual(["field"]);
await loadingTask.destroy();
});

it("extract page 2 and check AcroForm Fields T entries", async function () {
let loadingTask = getDocument(
buildGetDocumentParams("form_two_pages.pdf")
Expand Down
Loading