Example usage for org.apache.pdfbox.pdmodel.common PDPageLabels getPageIndicesByLabels

List of usage examples for org.apache.pdfbox.pdmodel.common PDPageLabels getPageIndicesByLabels

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.common PDPageLabels getPageIndicesByLabels.

Prototype

public Map<String, Integer> getPageIndicesByLabels() 

Source Link

Document

Returns a mapping with computed page labels as keys and corresponding 0-based page indices as values.

Usage

From source file:com.trollworks.gcs.pdfview.PdfPanel.java

License:Open Source License

public void goToPage(PdfRef pdfRef, int page, String highlight) {
    if (!mIgnorePageChange && mPdf != null) {
        int lastPageIndex = mPageIndex;
        mPageIndex = page;//  ww w  .j a  va 2 s. c  o  m
        try {
            PDPageLabels pageLabels = mPdf.getDocumentCatalog().getPageLabels();
            if (pageLabels != null) {
                Integer result = pageLabels.getPageIndicesByLabels().get(Integer.toString(page));
                if (result != null) {
                    mPageIndex = result.intValue();
                }
            }
        } catch (Exception exception) {
            // Had no catalog... we will just use the original page number
        }
        mPageIndex += pdfRef.getPageToIndexOffset();
        if (mPageIndex != lastPageIndex || isHighlightNew(highlight)) {
            mHighlight = highlight;
            markPageForLoading();
        }
    }
}