Skip to content

Commit 01b315a

Browse files
authored
Merge pull request #21176 from calixteman/bug2035197
Fix merging PDFs with conflicting AcroForm /DR (bug 2035197)
2 parents d9f175d + c9a7ff0 commit 01b315a

5 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/core/editor/pdf_editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ class PDFEditor {
20002000
const resourcesValuesCache = new Map();
20012001
for (const field of drToFix) {
20022002
const ap = field.get("AP");
2003-
for (const value of ap.getValues()) {
2003+
for (const [, value] of ap) {
20042004
if (!(value instanceof BaseStream)) {
20052005
continue;
20062006
}

test/pdfs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,3 +906,5 @@
906906
!issue13520.pdf
907907
!22060_A1_01_Plans.pdf
908908
!issue21126.pdf
909+
!bug2035197_1.pdf
910+
!bug2035197_2.pdf

test/pdfs/bug2035197_1.pdf

784 Bytes
Binary file not shown.

test/pdfs/bug2035197_2.pdf

661 Bytes
Binary file not shown.

test/unit/api_spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6586,6 +6586,29 @@ small scripts as well as for`);
65866586

65876587
await loadingTask.destroy();
65886588
});
6589+
6590+
it("merges PDFs with conflicting AcroForm /DR (bug 2035197)", async function () {
6591+
// Two PDFs with different `AcroForm.DR`.
6592+
const loadingTask = getDocument(
6593+
buildGetDocumentParams("bug2035197_1.pdf")
6594+
);
6595+
const pdfDoc = await loadingTask.promise;
6596+
const pdfData2 = await DefaultFileReaderFactory.fetch({
6597+
path: TEST_PDFS_PATH + "bug2035197_2.pdf",
6598+
});
6599+
6600+
const data = await pdfDoc.extractPages([
6601+
{ document: null },
6602+
{ document: pdfData2 },
6603+
]);
6604+
expect(data).not.toBeNull();
6605+
await loadingTask.destroy();
6606+
6607+
const newLoadingTask = getDocument(data);
6608+
const newPdfDoc = await newLoadingTask.promise;
6609+
expect(newPdfDoc.numPages).toEqual(2);
6610+
await newLoadingTask.destroy();
6611+
});
65896612
});
65906613

65916614
describe("Outlines", function () {

0 commit comments

Comments
 (0)