Custom Preview Handler

How can I Setup a own preview handler ? E.g. having a specific document Extension like .tiri and want to process this for preview having run tiri2pdf.sh for example, to have it in browser. How could this being implemented?
Any Help and ideas are highly appreciated.
Best regards
Thomas