當前位置: 首頁>>代碼示例>>Java>>正文


Java PDDocument.getPage方法代碼示例

本文整理匯總了Java中org.sejda.sambox.pdmodel.PDDocument.getPage方法的典型用法代碼示例。如果您正苦於以下問題:Java PDDocument.getPage方法的具體用法?Java PDDocument.getPage怎麽用?Java PDDocument.getPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.sejda.sambox.pdmodel.PDDocument的用法示例。


在下文中一共展示了PDDocument.getPage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findDestinationPage

import org.sejda.sambox.pdmodel.PDDocument; //導入方法依賴的package包/類
/**
 * This method will attempt to find the page in this PDF document that this outline points to. If the outline does
 * not point to anything then this method will return null. If the outline is an action that is not a GoTo action
 * then this method will also return null.
 *
 * @param doc The document to get the page from.
 *
 * @return The page that this outline will go to when activated or null if it does not point to anything.
 * @throws IOException If there is an error when trying to find the page.
 */
public PDPage findDestinationPage(PDDocument doc) throws IOException
{
    PDDestination dest = getDestination();
    if (dest == null)
    {
        PDAction outlineAction = getAction();
        if (outlineAction instanceof PDActionGoTo)
        {
            dest = ((PDActionGoTo) outlineAction).getDestination();
        }
    }
    if (dest == null)
    {
        return null;
    }

    PDPageDestination pageDestination = null;
    if (dest instanceof PDNamedDestination)
    {
        pageDestination = doc.getDocumentCatalog().findNamedDestinationPage(
                (PDNamedDestination) dest);
        if (pageDestination == null)
        {
            return null;
        }
    }
    else if (dest instanceof PDPageDestination)
    {
        pageDestination = (PDPageDestination) dest;
    }
    else
    {
        throw new IOException("Error: Unknown destination type " + dest);
    }

    PDPage page = pageDestination.getPage();
    if (page == null)
    {
        // Malformed PDF: local destinations must have a page object,
        // not a page number, these are meant for remote destinations.
        int pageNumber = pageDestination.getPageNumber();
        if (pageNumber != -1)
        {
            page = doc.getPage(pageNumber);
        }
    }
    return page;
}
 
開發者ID:torakiki,項目名稱:sambox,代碼行數:59,代碼來源:PDOutlineItem.java


注:本文中的org.sejda.sambox.pdmodel.PDDocument.getPage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。