Reputation: 2477
Inside my asp.net MVC web application i need to display pdf in safari browser in iPad. my code is like this.
<object data="@Model.StringPdfUrl" type="application/pdf">
<embed src="@Model.StringPdfUrl" type="application/pdf" />
</object>
Does anybody know about the fix for this issue.
Thank you in advanced
Upvotes: 0
Views: 1155
Reputation: 8750
I wonder if this is not the same issue I once had with Internet Explorer.
Even with the latest IE 11, if the url doesn't end with the extension .pdf
(which was the case with my MVC app: the url was like /File/Download/4587
), then IE plug-in could not render the PDF file. Same issue with <embed>
.
I tried the iframe
solution, but on some computers the document opened up in a new window.
In the end, the solution I implemented was to convert each page of the PDF document into an image with GhostscriptSharp
, and then to render the document online as images in an HTML page (with navigation controls to go to first/previous/next/last page).
Upvotes: 1
Reputation: 2477
I Found a solution.
I used iframe to render pdf in safari
if (Request.Browser.Type.Contains("Safari"))
{
<iframe src="@Model.StringPdfUrl" height="750" width="600" frameborder="0" id="myiframe" ></iframe>
}
else
{
<object height="750" width="600" data="@Model.StringPdfUrl" type="application/pdf">
<embed src="@Model.StringPdfUrl" type="application/pdf" />
</object>
}
Upvotes: 0