@@ -0,0 +1,2993 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.pdfbox.multipdf;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.URL;%0A%0Aimport org.apache.pdfbox.cos.COSName;%0Aimport org.apache.pdfbox.pdmodel.PDDocument;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A * Test merging different PDFs with AcroForms.%0A * %0A * %0A */%0Apublic class MergeAcroFormsTest%0A%7B%0A    private static final File OUT_DIR = new File(%22target/test-output/merge/%22);%0A%0A    @Before%0A    public void setUp()%0A    %7B%0A        OUT_DIR.mkdirs();%0A    %7D%0A    %0A    /*%0A     * PDFBOX-1031 Ensure that after merging the PDFs there is an Annots entry per page.%0A     */%0A    @Test%0A    public void testAnnotsEntry() throws IOException %7B%0A        %0A        // Merge the PDFs form PDFBOX-1031%0A        PDFMergerUtility merger = new PDFMergerUtility();%0A        %0A        URL url1 = new URL(%22https://issues.apache.org/jira/secure/attachment/12481683/1.pdf%22);%0A        InputStream is1 = url1.openStream();%0A%0A        URL url2 = new URL(%22https://issues.apache.org/jira/secure/attachment/12481684/2.pdf%22);%0A        InputStream is2 = url2.openStream();%0A        File pdfOutput = new File(OUT_DIR,%22PDFBOX-1031.pdf%22);%0A        merger.setDestinationFileName(pdfOutput.getAbsolutePath());%0A        merger.addSource(is1);%0A        merger.addSource(is2);%0A        merger.mergeDocuments(null);%0A        %0A        // Test merge result%0A        PDDocument mergedPDF = PDDocument.load(pdfOutput);%0A        assertEquals(%22There shall be 2 pages%22, 2, mergedPDF.getNumberOfPages());%0A        %0A        assertNotNull(%22There shall be an /Annots entry for the first page%22, mergedPDF.getPage(0).getCOSObject().getDictionaryObject(COSName.ANNOTS));%0A        assertEquals(%22There shall be 1 annotation for the first page%22, 1, mergedPDF.getPage(0).getAnnotations().size());%0A        %0A        assertNotNull(%22There shall be an /Annots entry for the second page%22, mergedPDF.getPage(1).getCOSObject().getDictionaryObject(COSName.ANNOTS));%0A        assertEquals(%22There shall be 1 annotation for the second page%22, 1, mergedPDF.getPage(0).getAnnotations().size());%0A%0A        mergedPDF.close();%0A    %7D%0A%7D%0A

add test that Annots entry is created per page