"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

PDFMergerUtilityTest.java  (pdfbox-2.0.23-src):PDFMergerUtilityTest.java  (pdfbox-2.0.24-src)
skipping to change at line 607 skipping to change at line 607
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInp utStream(file))); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInp utStream(file)));
String line; String line;
while ((line = br.readLine()) != null) while ((line = br.readLine()) != null)
{ {
if (line.equals("/Type /StructTreeRoot")) if (line.equals("/Type /StructTreeRoot"))
{ {
++count; ++count;
} }
} }
br.close(); br.close();
assertEquals(1, count); assertEquals(file.getPath(), 1, count);
} }
/** /**
* PDFBOX-4408: Check that /StructParents values from pages and /StructParen t values from * PDFBOX-4408: Check that /StructParents values from pages and /StructParen t values from
* annotations are found in the /ParentTree. * annotations are found in the /ParentTree.
* *
* @param document * @param document
*/ */
void checkWithNumberTree(PDDocument document) throws IOException void checkWithNumberTree(PDDocument document) throws IOException
{ {
skipping to change at line 685 skipping to change at line 685
merger.addSource(inFile1); merger.addSource(inFile1);
merger.addSource(inFile2); merger.addSource(inFile2);
merger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly()); merger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
out.close(); out.close();
assertTrue(inFile1.delete()); assertTrue(inFile1.delete());
assertTrue(inFile2.delete()); assertTrue(inFile2.delete());
assertTrue(outFile.delete()); assertTrue(outFile.delete());
} }
/**
* Check that there is a top level Document and Parts below in a merge of 2
documents.
*
* @param file
* @throws IOException
*/
public void testPDFBox5198_2() throws IOException
{
PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
pdfMergerUtility.addSource(new File(SRCDIR, "PDFA3A.pdf"));
pdfMergerUtility.addSource(new File(SRCDIR, "PDFA3A.pdf"));
pdfMergerUtility.setDestinationFileName(TARGETTESTDIR + "PDFA3A-merged2.
pdf");
pdfMergerUtility.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly()
);
checkParts(new File(TARGETTESTDIR + "PDFA3A-merged2.pdf"));
}
/**
* Check that there is a top level Document and Parts below in a merge of 3
documents.
*
* @param file
* @throws IOException
*/
public void testPDFBox5198_3() throws IOException
{
PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
pdfMergerUtility.addSource(new File(SRCDIR, "PDFA3A.pdf"));
pdfMergerUtility.addSource(new File(SRCDIR, "PDFA3A.pdf"));
pdfMergerUtility.addSource(new File(SRCDIR, "PDFA3A.pdf"));
pdfMergerUtility.setDestinationFileName(TARGETTESTDIR + "PDFA3A-merged3.
pdf");
pdfMergerUtility.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly()
);
checkParts(new File(TARGETTESTDIR + "PDFA3A-merged3.pdf"));
}
/**
* Check that there is a top level Document and Parts below.
* @param file
* @throws IOException
*/
private void checkParts(File file) throws IOException
{
PDDocument doc = PDDocument.load(file);
PDStructureTreeRoot structureTreeRoot = doc.getDocumentCatalog().getStru
ctureTreeRoot();
COSDictionary topDict = (COSDictionary) structureTreeRoot.getK();
assertEquals(COSName.DOCUMENT, topDict.getItem(COSName.S));
assertEquals(structureTreeRoot.getCOSObject(), topDict.getCOSDictionary(
COSName.P));
COSArray kArray = topDict.getCOSArray(COSName.K);
assertEquals(doc.getNumberOfPages(), kArray.size());
for (int i = 0; i < kArray.size(); ++i)
{
COSDictionary dict = (COSDictionary) kArray.getObject(i);
assertEquals(COSName.PART, dict.getItem(COSName.S));
assertEquals(topDict, dict.getCOSDictionary(COSName.P));
}
doc.close();
}
private void checkForPageOrphans(PDDocument doc) throws IOException private void checkForPageOrphans(PDDocument doc) throws IOException
{ {
// check for orphan pages in the StructTreeRoot/K, StructTreeRoot/Parent Tree and // check for orphan pages in the StructTreeRoot/K, StructTreeRoot/Parent Tree and
// StructTreeRoot/IDTree trees. // StructTreeRoot/IDTree trees.
PDPageTree pageTree = doc.getPages(); PDPageTree pageTree = doc.getPages();
PDStructureTreeRoot structureTreeRoot = doc.getDocumentCatalog().getStru ctureTreeRoot(); PDStructureTreeRoot structureTreeRoot = doc.getDocumentCatalog().getStru ctureTreeRoot();
checkElement(pageTree, structureTreeRoot.getParentTree().getCOSObject()) ; checkElement(pageTree, structureTreeRoot.getParentTree().getCOSObject()) ;
checkElement(pageTree, structureTreeRoot.getK()); checkElement(pageTree, structureTreeRoot.getK());
checkForIDTreeOrphans(pageTree, structureTreeRoot); checkForIDTreeOrphans(pageTree, structureTreeRoot);
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 67 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)