Am 15.05.2017 um 15:20 schrieb David Patterson:
I've now got my code working to iterate through a PDDocument and process it
page by page.

Next hurdle: Is there a way to get the page number as printed? I've got
page numbers like "TOC-1", "TOC-2", "Page 1", ...

How much work is it to get the "TOC-1"?

Thanks.

Dave Patterson


    /**
     * Convenience method to get the page label if available.
     *
     * @param document
     * @param pageIndex 0-based page number.
     * @return a page label or null if not available.
     */
    public static String getPageLabel(PDDocument document, int pageIndex)
    {
        PDPageLabels pageLabels;
        try
        {
            pageLabels = document.getDocumentCatalog().getPageLabels();
        }
        catch (IOException ex)
        {
            return ex.getMessage();
        }
        if (pageLabels != null)
        {
            String[] labels = pageLabels.getLabelsByPageIndices();
            if (labels[pageIndex] != null)
            {
                return labels[pageIndex];
            }
        }
        return null;
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to