How to select print format based on the user agent of the device?

I am currently working on a customization where I need to automatically select one print format out of 3 based on the browser/user-agent the user requesting?

Any lead to this request would be much helpful.

Thanks.