Forum How do I...?

How to valdate that passed input stream is a html file.

satyavati
Hi Mikeday,

For Validation I have converted a .pdf file in an inputstream and passed that in prince.convert(). It is returning true (file is getting converted to pdf but not same as the 1st pdf).
Is there a way to validate that if passed inputstream is from html then only convert to pdf other wise return false.
Means is there any way to specify document type.
I have set the setHtml(true);
mikeday
You don't know if your input is HTML or not?
satyavati
Yes, but it should be html only, if not throw not valid html
mikeday
Prince is not a HTML validator. For example, sometimes documents will be missing end tags, or have mismatched tags, technically this is invalid, but Prince can still parse it and generate a PDF file.

If you have no idea whether the document is actually HTML or random noise, you could try searching for "<html" or "<!DOCTYPE" or similar content near the start of the file.
satyavati
ok thanks Mikeday :)