I'ts pretty easy: Each PDF document start with %PDF-<version number>
for example %PDF-1.4. So you only have to compare the first 4 bytes of
your document.
 
On Fri, 2004-01-30 at 17:54, J.B. wrote:
> 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
-- 
Christian Lauer <[EMAIL PROTECTED]>



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