mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-07 18:51:09 +02:00
Merge pull request #21176 from calixteman/bug2035197
Fix merging PDFs with conflicting AcroForm /DR (bug 2035197)
This commit is contained in:
commit
01b315a8f3
@ -2000,7 +2000,7 @@ class PDFEditor {
|
||||
const resourcesValuesCache = new Map();
|
||||
for (const field of drToFix) {
|
||||
const ap = field.get("AP");
|
||||
for (const value of ap.getValues()) {
|
||||
for (const [, value] of ap) {
|
||||
if (!(value instanceof BaseStream)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
2
test/pdfs/.gitignore
vendored
2
test/pdfs/.gitignore
vendored
@ -906,3 +906,5 @@
|
||||
!issue13520.pdf
|
||||
!22060_A1_01_Plans.pdf
|
||||
!issue21126.pdf
|
||||
!bug2035197_1.pdf
|
||||
!bug2035197_2.pdf
|
||||
|
||||
41
test/pdfs/bug2035197_1.pdf
Normal file
41
test/pdfs/bug2035197_1.pdf
Normal file
@ -0,0 +1,41 @@
|
||||
%PDF-1.7
|
||||
%âãÏÓ
|
||||
1 0 obj
|
||||
<</Type/Catalog/Pages 2 0 R/AcroForm 3 0 R>>
|
||||
endobj
|
||||
2 0 obj
|
||||
<</Type/Pages/Kids[4 0 R]/Count 1>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<</Fields[5 0 R]/DR<</Font<</Helv 6 0 R>>>>/DA(/Helv 12 Tf 0 g)>>
|
||||
endobj
|
||||
4 0 obj
|
||||
<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Resources<<>>/Annots[5 0 R]>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<</Type/Annot/Subtype/Widget/FT/Tx/T(field1)/Rect[100 100 200 120]/AP<</N 7 0 R>>/P 4 0 R>>
|
||||
endobj
|
||||
6 0 obj
|
||||
<</Type/Font/Subtype/Type1/BaseFont/Helvetica>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<</Type/XObject/Subtype/Form/BBox[0 0 100 20]/Length 0>>
|
||||
stream
|
||||
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 8
|
||||
0000000000 65535 f
|
||||
0000000019 00000 n
|
||||
0000000079 00000 n
|
||||
0000000130 00000 n
|
||||
0000000211 00000 n
|
||||
0000000304 00000 n
|
||||
0000000411 00000 n
|
||||
0000000474 00000 n
|
||||
trailer
|
||||
<</Size 8/Root 1 0 R>>
|
||||
startxref
|
||||
564
|
||||
%%EOF
|
||||
34
test/pdfs/bug2035197_2.pdf
Normal file
34
test/pdfs/bug2035197_2.pdf
Normal file
@ -0,0 +1,34 @@
|
||||
%PDF-1.7
|
||||
%âãÏÓ
|
||||
1 0 obj
|
||||
<</Type/Catalog/Pages 2 0 R/AcroForm 3 0 R>>
|
||||
endobj
|
||||
2 0 obj
|
||||
<</Type/Pages/Kids[4 0 R]/Count 1>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<</Fields[5 0 R]/DR<</Font<</TiRo 6 0 R>>>>/DA(/TiRo 12 Tf 0 g)>>
|
||||
endobj
|
||||
4 0 obj
|
||||
<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Resources<<>>/Annots[5 0 R]>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<</Type/Annot/Subtype/Widget/FT/Tx/T(field2)/Rect[100 100 200 120]/P 4 0 R>>
|
||||
endobj
|
||||
6 0 obj
|
||||
<</Type/Font/Subtype/Type1/BaseFont/Times-Roman>>
|
||||
endobj
|
||||
xref
|
||||
0 7
|
||||
0000000000 65535 f
|
||||
0000000019 00000 n
|
||||
0000000079 00000 n
|
||||
0000000130 00000 n
|
||||
0000000211 00000 n
|
||||
0000000304 00000 n
|
||||
0000000396 00000 n
|
||||
trailer
|
||||
<</Size 7/Root 1 0 R>>
|
||||
startxref
|
||||
461
|
||||
%%EOF
|
||||
@ -6586,6 +6586,29 @@ small scripts as well as for`);
|
||||
|
||||
await loadingTask.destroy();
|
||||
});
|
||||
|
||||
it("merges PDFs with conflicting AcroForm /DR (bug 2035197)", async function () {
|
||||
// Two PDFs with different `AcroForm.DR`.
|
||||
const loadingTask = getDocument(
|
||||
buildGetDocumentParams("bug2035197_1.pdf")
|
||||
);
|
||||
const pdfDoc = await loadingTask.promise;
|
||||
const pdfData2 = await DefaultFileReaderFactory.fetch({
|
||||
path: TEST_PDFS_PATH + "bug2035197_2.pdf",
|
||||
});
|
||||
|
||||
const data = await pdfDoc.extractPages([
|
||||
{ document: null },
|
||||
{ document: pdfData2 },
|
||||
]);
|
||||
expect(data).not.toBeNull();
|
||||
await loadingTask.destroy();
|
||||
|
||||
const newLoadingTask = getDocument(data);
|
||||
const newPdfDoc = await newLoadingTask.promise;
|
||||
expect(newPdfDoc.numPages).toEqual(2);
|
||||
await newLoadingTask.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Outlines", function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user