Reading a particular page from a PDF document using PDFBox

后端 未结 6 2042
醉话见心
醉话见心 2020-12-03 10:41

How do I read a particular page (given a page number) from a PDF document using PDFBox?

6条回答
  •  Happy的楠姐
    2020-12-03 11:00

    This should work:

    PDPage firstPage = (PDPage)doc.getAllPages().get( 0 );
    

    as seen in the BookMark section of the tutorial

    Update 2015, Version 2.0.0 SNAPSHOT

    Seems this was removed and put back (?). getPage is in the 2.0.0 javadoc. To use it:

    PDDocument document = PDDocument.load(new File(filename));
    PDPage doc = document.getPage(0);
    

    The getAllPages method has been renamed getPages

    PDPage page = (PDPage)doc.getPages().get( 0 );
    

提交回复
热议问题