Determine if a byte[] is a pdf file

前端 未结 5 2072

Is there any way of checking if a byte[] is a pdf without opening?

I have some code to display a list of byte[] as pdf thumbnails. I previously knew all the byte[] w

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 03:08

    As far as I know all PDF's start with %PDF, so you could check the first bytes against this string.

提交回复
热议问题