You have to parse the PDf file to make sure it's valid and even then there
are some surprises. The following quick check will eliminate files that
aren't PDF. Those that pass the check have a good chance of being PDF but
not 100%. Files that are PDF always have in the first 1024 bytes the string
"%PDF-1." and in the last 1024 bytes the string "%%EOF".

Best Regards,
Paulo Soares

----- Original Message -----
From: "J. B." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 30, 2004 16:54
Subject: [iText-questions] How to determine if a file is of valid PDF format


> Hi,
>
>
>
> I have a class which takes a list of filenames as argument.  Before
processing
>
> them, I want to make sure they are PDF files. Right now, what I do is to
start
>
> processing and catch the associated exception, then I know it's not a
valid PDF.
>
>
>
> But I'm convinced there's a better way of doing this.  Is there a method
>
> such as isValidPDF(), or something similar, I can use to validate a
document
>
> before starting to process it?
>
>
>
> What I want to do is simple:
>
> 1. loop through all files
>
> 2. if not PDF, print error message, discard file, move to next file
>
> 3. Process remaining (valid) files.
>
>
>
> Thx.
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to