Reputation: 103
document = PDDocument.load(filePath);
System.out.println(" pages count = " + document.getNumberOfPages());
PDDocumentCatalog docCata = new PDDocumentCatalog(document);
Map<String,Integer> pmap = document.getPageMap();
System.out.println("count = "+ pmap.size() ); //This prints count = 562
pnode =docCata.getPages();
kidList = pnode.getKids();
System.out.println("Size of kidList =" + kidList.size()); //this also prints Size of kidList = 0
//System.out.println("-------size= "+pnode.getRotation()) //throws null pointer exception
Hi I tried working with the above code , however I am not able to get the kids using the pnode.getKids.
The above gives the following output:
pages count = 562
count = 562
Size of kidList =0
I am not getting why kidList is not getting populated even when the PDF has pages. Please provide some help in this context.
Thanks.
Upvotes: 0
Views: 70
Reputation: 95888
Most likely you want to do
PDDocumentCatalog docCata = document.getDocumentCatalog();
instead of
PDDocumentCatalog docCata = new PDDocumentCatalog(document);
getDocumentCatalog()
retrieves the existing document catalog while new PDDocumentCatalog(document)
creates a new one without any pages.
Upvotes: 1