"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDPageLabels.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.

PDPageLabels.java  (pdfbox-2.0.23-src):PDPageLabels.java  (pdfbox-2.0.24-src)
skipping to change at line 102 skipping to change at line 102
if (dict == null) if (dict == null)
{ {
return; return;
} }
PDNumberTreeNode root = new PDNumberTreeNode(dict, PDPageLabelRange.clas s); PDNumberTreeNode root = new PDNumberTreeNode(dict, PDPageLabelRange.clas s);
findLabels(root); findLabels(root);
} }
private void findLabels(PDNumberTreeNode node) throws IOException private void findLabels(PDNumberTreeNode node) throws IOException
{ {
List<PDNumberTreeNode> kids = node.getKids();
if (node.getKids() != null) if (node.getKids() != null)
{ {
List<PDNumberTreeNode> kids = node.getKids();
for (PDNumberTreeNode kid : kids) for (PDNumberTreeNode kid : kids)
{ {
findLabels(kid); findLabels(kid);
} }
} }
else if (node.getNumbers() != null) else
{ {
Map<Integer, COSObjectable> numbers = node.getNumbers(); Map<Integer,COSObjectable> numbers = node.getNumbers();
for (Entry<Integer, COSObjectable> i : numbers.entrySet()) if (numbers != null)
{ {
if(i.getKey() >= 0) for (Entry<Integer, COSObjectable> i : numbers.entrySet())
{ {
labels.put(i.getKey(), (PDPageLabelRange) i.getValue()); if (i.getKey() >= 0)
{
labels.put(i.getKey(), (PDPageLabelRange) i.getValue());
}
} }
} }
} }
} }
/** /**
* Returns the number of page label ranges. * Returns the number of page label ranges.
* *
* <p> * <p>
* This will be always &gt;= 1, as the required default entry for the page * This will be always &gt;= 1, as the required default entry for the page
skipping to change at line 228 skipping to change at line 231
/** /**
* Returns a mapping with 0-based page indices as keys and corresponding * Returns a mapping with 0-based page indices as keys and corresponding
* page labels as values as an array. The array will have exactly as much * page labels as values as an array. The array will have exactly as much
* entries as the document has pages. * entries as the document has pages.
* *
* @return an array mapping from 0-based page indices to labels. * @return an array mapping from 0-based page indices to labels.
*/ */
public String[] getLabelsByPageIndices() public String[] getLabelsByPageIndices()
{ {
final String[] map = new String[doc.getNumberOfPages()]; final int numberOfPages = doc.getNumberOfPages();
final String[] map = new String[numberOfPages];
computeLabels(new LabelHandler() computeLabels(new LabelHandler()
{ {
@Override @Override
public void newLabel(int pageIndex, String label) public void newLabel(int pageIndex, String label)
{ {
if(pageIndex < doc.getNumberOfPages()) if (pageIndex < numberOfPages)
{ {
map[pageIndex] = label; map[pageIndex] = label;
} }
} }
}); });
return map; return map;
} }
/** /**
* Get an ordered set of page indices having a page label range. * Get an ordered set of page indices having a page label range.
 End of changes. 8 change blocks. 
8 lines changed or deleted 12 lines changed or added

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