determine if PDF file is openable and not corrupt

前端 未结 2 1305
盖世英雄少女心
盖世英雄少女心 2021-01-26 02:40

I am wandering if anybody has a reliable way of determine whether a PDF document is actually a PDF document, and that it isn\'t corrupted.

I generate reports on my syste

2条回答
  •  粉色の甜心
    2021-01-26 03:01

    You can use pdfinfo, centos installation command:

    yum install poppler-utils
    

    ... and use pdfinfo command. The PHP code is as follows:

    if(!exec("pdfinfo test.pdf")){
      echo "file is corrupted"
    }
    

提交回复
热议问题