Get the number of pages in a PDF document

后端 未结 12 1820
你的背包
你的背包 2020-12-07 09:00

This question is for referencing and comparing. The solution is the accepted answer below.

Many hours have I searched for a fast and easy, but mostly a

12条回答
  •  一向
    一向 (楼主)
    2020-12-07 09:21

    The R package pdftools and the function pdf_info() provides information on the number of pages in a pdf.

    library(pdftools)
    pdf_file <- file.path(R.home("doc"), "NEWS.pdf")
    info <- pdf_info(pdf_file)
    nbpages <- info[2]
    nbpages
    
    $pages
    [1] 65
    

提交回复
热议问题