how to check a byte array is valid PDF file or not RRS feed

  • Question

  • HI every one ,

    i have blob data  for PDF files in my database , i want to check that the available blob  file in database is   a valid PDF file or not .can some one help me for this .

    Wednesday, October 25, 2017 7:40 AM

All replies

  • Personally I would recommend you use a PDF library to verify the PDF. It is the safest route.

    But if you want a quick and dirty solution then look at the first couple of bytes of the file. PDFs start with %PDF- Not foolproof but it would eliminate accidental "PDFs".

    Michael Taylor

    Wednesday, October 25, 2017 2:02 PM