Get the number of pages in a PDF document

后端 未结 12 1852
你的背包
你的背包 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:31

    Here is a R function that reports the PDF file page number by using the pdfinfo command.

    pdf.file.page.number <- function(fname) {
        a <- pipe(paste("pdfinfo", fname, "| grep Pages | cut -d: -f2"))
        page.number <- as.numeric(readLines(a))
        close(a)
        page.number
    }
    if (F) {
        pdf.file.page.number("a.pdf")
    }
    

提交回复
热议问题