How to determine if a PDF file is valid?



I use PDFCreator to generate PDF file in a batch

My problem is that I don't know when PDFCreator has finished to generate the PDF file.

As I use this PDF file directly after PDFCreator, I sometimes read the file before it is completly generated.


Even if the PDFCreator job has disappeared from the spooler, the generation isn't really finished in some cases. I have made all the checks done in the samples scripts. I also check if the size of the file don't change in a period of time. But i still have some file that pass through theese tests.


So my question is : is there a way to check the validity of a PDF file?



I have finaly found a workaround.

I now test the last line of the PDF file: if this line is equal to '%%EOF', I consider that the file is OK.

My batch now make a loop and read each PDF file until the file ends with '%%EOF'.