Make iOS 7 Safari open PDF that is forced in other browsers
-
05-10-2022 - |
Question
I have looked around on stackowerflow and i cant find the answer i'm looking for so here is my problem.
I'm building a application that is forcing download of a pdf on every browser and the application is creating this pdf by geting values from a server so a direct link is not the answer.
This is my code:
private bool SendPDF(string geoCode, string period)
{
bool result = false;
using (var db = new prerenderedreportsDataContext())
{
var q = (from r in db.RenderedReports where r.GeographicCode == geoCode && r.Period == period select r).SingleOrDefault();
if (q != null && q.ReportPDF != null)
{
byte[] data = q.ReportPDF.ToArray();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream .pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=\"landfaktablad_" + geoCode + "_" + period + ".pdf\"");
Response.AppendHeader("Content-Length:", data.Length.ToString());
Response.AppendHeader("Cache-Control", "public");
Response.AppendHeader("Content-Transfer-Encoding", "Binary");
Response.BinaryWrite(data);
Response.Flush();
Response.End();
result = true;
}
}
return result;
}
I understand that iOS 7 doesen't support downloading so how can i get safari views the pdf instead of try to downloading it. Now it works on previous iOS and IE etc but iOS safari crashes.
Someone how have a solution?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow