Determine if a byte[] is a pdf file

前端 未结 5 2078

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:15

    First four bytes should be: 0x25 0x50 0x44 0x46 (in hex format, in ASCII it's %PDF). "Magic numbers" for another formats you can find here

提交回复
热议问题