check if PDF file is valid?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    check if PDF file is valid?

    Hi,

    I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
    file on my server, is there a way I can check if that file is of a PDF
    format? I'm guessing the answer to this may depend on some versioning
    info too, so if that's true, let's just consider for the latest verion
    of PDF.

    Thanks for your help, - Dave
  • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

    #2
    Re: check if PDF file is valid?

    laredotornado@z ipmail.com wrote:
    I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
    file on my server, is there a way I can check if that file is of a PDF
    format? I'm guessing the answer to this may depend on some versioning
    info too, so if that's true, let's just consider for the latest verion
    of PDF.
    If you're running your scripts on a linux (or unix) server, just run
    the "file" command to know the type of file.

    e.g.:

    $type = shell_exec("fil e $filename");

    --
    ----------------------------------
    Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

    Ruido en la línea cortesía de Telefónica.

    Comment

    • C. (http://symcbean.blogspot.com/)

      #3
      Re: check if PDF file is valid?

      On 14 Feb, 22:11, Iván Sánchez Ortega <ivansanchez-...@rroba-
      escomposlinux.-.punto.-.orgwrote:
      laredotorn...@z ipmail.com wrote:
      I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
      file on my server, is there a way I can check if that file is of a PDF
      format? I'm guessing the answer to this may depend on some versioning
      info too, so if that's true, let's just consider for the latest verion
      of PDF.
      >
      If you're running your scripts on a linux (or unix) server, just run
      the "file" command to know the type of file.
      >
      e.g.:
      >
      $type = shell_exec("fil e $filename");
      >
      For a given value of 'valid'. A more rigourous solution might be to
      run it through pdftops then back through pstopdf

      C.

      Comment

      Working...