Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
2.22/5 (2 votes)
See more:
Hi,
I have created a pdf file using pdf Sharp in my project. The created pdf is been downloaded also by the clients. It works fine in desktop browsers, but it doesn't be in correct format in some mobile device browsers. For example: iphone,ipad,android, windows phone etc.

I have tried this code
C#
public void download2(string fpath)
        {

            // string fileName = "detailed_syllabus.pdf";
            Response.ClearContent();


            FileInfo updateFile = new FileInfo(fpath);
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("content-disposition", "attachment;filename=\"" + Path.GetFileName(updateFile.FullName) + "\"");
            Response.AddHeader("content-length", updateFile.Length.ToString());
            Response.TransmitFile(updateFile.FullName);
            Response.Flush();
            
        }
Posted
Updated 11-May-15 18:35pm
v2
Comments
Sinisa Hajnal 8-May-15 2:57am    
You might try with "application/pdf" instead octet-stream...not sure if that would help, but it is worth a try.
RENJITH VS 8-May-15 3:12am    
Well try. But it's not a solution unfortunately.
Florian Braun 10-May-15 3:59am    
What do you meab by "not the right Format"? If it means your PDF is bot shown in browser, the reason might be that many mobile browsers don't support plugins for showing PDF. They just require to download that PDF and open it with another application.
RENJITH VS 12-May-15 0:25am    
Florian,
Assume my file name is abc. When I click on download button it shows adc.htm instead of abc.pdf in some browsers. There also some issue with Ipad, Iphone etc too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900