Get the number of pages in a PDF document

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

    if you can't install any additional packages, you can use this simple one-liner:

    foundPages=$(strings < $PDF_FILE | sed -n 's|.*Count -\{0,1\}\([0-9]\{1,\}\).*|\1|p' | sort -rn | head -n 1)
    

提交回复
热议问题