Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify whether the client machine supports PDF File format

Hii,

My requirment is to show a dynamically created pdf file directly to my web page. It works fine for the system which is having pdf reader software. But for the system which does not have the pdf software it is showing error like below

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


An invalid character was found in text content. Error processing resource 'http://localhost:4252/OmanePost/Customer/EBox/PD... I need to handle this situation bit differently.i.e In this situation the file should be save to the physical location of the system for that i need to identify whether the client machine has pdf software or not then i can manage properly

I m using ASP.NET 2.0 version

like image 901
Jibu P C_Adoor Avatar asked Dec 29 '22 11:12

Jibu P C_Adoor


2 Answers

It looks to me that you are serving your PDF with an XML mime/content-type. Make sure you set your content-type to application/pdf and you'll probably get a more suitable browser response.

like image 100
spender Avatar answered Dec 31 '22 00:12

spender


In this case the browser should ask the user to open the file in an external application.

Please verify that you are sending the correct Content-Type: application/pdf header. Certain versions of Microsoft's browser ignore the content-type header, so you need to specify a filename ending in .pdf in the content disposition header: Content-Disposition: inline; filename=filename.pdf;

Note: I have not verified that it works with "inline" instead of "attachment", but I think it is worth a try.

like image 21
Hendrik Brummermann Avatar answered Dec 31 '22 01:12

Hendrik Brummermann