Example usage for org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline PDOutlineNode children

List of usage examples for org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline PDOutlineNode children

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline PDOutlineNode children.

Prototype

public Iterable<PDOutlineItem> children() 

Source Link

Usage

From source file:org.pdfsam.pdfbox.component.PDFBoxOutlineUtils.java

License:Open Source License

private static int getMaxBookmarkLevel(PDOutlineNode node, PDDestinationNameTreeNode destinations,
        int parentLevel) {
    int maxLevel = parentLevel;
    if (node != null) {
        for (PDOutlineItem current : node.children()) {
            if (isPageDestination(current, destinations)) {
                int maxBookmarkBranchLevel = getMaxBookmarkLevel(current, destinations, parentLevel + 1);
                if (maxBookmarkBranchLevel > maxLevel) {
                    maxLevel = maxBookmarkBranchLevel;
                }/* w ww.  ja v  a2  s . com*/
            }
        }
    }
    return maxLevel;
}

From source file:org.pdfsam.pdfbox.PDFBoxOutlineLevelsHandler.java

License:Open Source License

private void addPageIfBookmarkLevel(PDOutlineNode outline, int currentLevel,
        OutlinePageDestinations destinations, int levelToAdd) {
    if (outline != null) {
        for (PDOutlineItem current : outline.children())
            if (currentLevel <= levelToAdd) {
                toPageDestination(current, namedDestinations).ifPresent(d -> {
                    if (isLevelToBeAdded(currentLevel, levelToAdd)) {
                        addPageIfValid(destinations, d, current.getTitle());
                    } else {
                        addPageIfBookmarkLevel(current, currentLevel + 1, destinations, levelToAdd);
                    }// w w w  . ja  v a2s  . c  o m
                });
            }
    }
}