PDF is not display in safari i-Pad - ipad

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

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).

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>
}

Related

How to view a doc/pdf file in grails application?

I am a grails beginner, and finding a way to view the doc/pdf files in the view. I tried embedding the file but got no output for it. How can i view the file?
Assuming that you don't just want to link to some other file on your server (if you do, Rahul's answer is perfectly fine) then you may want to consider something like this in a controller:
def retrieveFile() {
File fileToReturn = new File("${params.filePath}")
String filename = "whatever your filename is"
byteOutput = fileToReturn.readBytes()
response.setHeader("Content-disposition", "attachment; filename=\"${filename}\"");
outputStream << byteOutput
}
Then link to that (g.createLink or whatever) with the appropriate file path.
Add <embed> or <object>tag in your gsp file
<embed> tag Example:
<embed src="http://example.com/your-file.pdf" width="800" height="500" type='application/pdf'>
<object> tag Example:
<object width="800" height="500" type="application/pdf" data="http://example.com/your-file.pdf">
<p>Insert your error message here, if the PDF cannot be displayed.</p>
</object>
Above code tested and working with chrome and Firefox.
Basically there are many solutions, where you can you third party plugins and or using <iframe>
Thanks, Hope it helps you

Browse Another Website Inside MVC Application

I have an existing web application which I want to display inside my new application, so as to the complete application works inside the new application.
In the image i've attached google.com so on search of something is should show the result or even open the website.
I'm not sure how to achieve that.
One way I found is IFrame, so would I to know any other possibilities are their as I do want to use IFrame
Attaching an Image for an example
Thanks in advance.
Maybe you can use something like fancybox tools. http://fancyapps.com/fancybox/#examples
But usually these tools are also using iframes. Maybe you can find another way for fancybox.
edit:Embed an External Page Without an Iframe?
edit 2: did you try this?
http://www.felgall.com/noiframe.htm
<html>
<head>
<title>example</title>
</head>
<body>
Ilker Test
<br />
<!--[if lte IE 6]>
<object classid="CLSID:25336920-03F9-11CF-8FD0-00AA00686F13"
data="http://www.w3schools.com/html/html_examples.asp" style="height:800px; width:1200px; overflow:hidden;">
</object>
<![endif]-->
<!--[if gte IE 7]><!-->
<object type="text/html" data="http://www.w3schools.com/html/html_examples.asp"
style="height:800px; width:1200px;">
<p>Alternate text.</p>
</object>
<!--><![endif]-->
</object>
</body>

Bootstrap Modal vs Youtube Video z-index Issue

I am using a Twitter Bootstrap Modal and Youtube Video on the same page. I am facing Z-Index Problem where the Video is being displayed above the modal window in Chrome Browser.
How can i solve this issue ?
http://mink7.com/projects/cmrc/home.html
You should use YouTube urls with ?wmode=transparent param.
<iframe src="http://www.youtube.com/embed/EBSnWlpTPSk?wmode=transparent"></iframe>
If you include your object/embed tag then you should add <param name="wmode" value="opaque" /> for object tags, wmode=transparent for embed tags.
The YouTube video you put on your page is flash-based. Flash objects are rendered separately on the top of the window, because they're not the part of HTML5 stack. Z-index has no effect on these.
See e.g. http://www.google.com/search?q=flash+z-index
As suggested by Fatih, solution is to pass wmode=transparent. For the IFrame API, I used following:
var player = new YT.Player(pContainer, {
height: 300,
width: 400,
videoId: contentID,
playerVars : {wmode: "transparent"},
events: {
...
}
}
});
you can easily fix this.
USE:
<param name="wmode" value="opaque" />
inside object tag.
<object title="YouTube video player" width="480" height="390"
data="http://www.youtube.com/embed/EBSnWlpTPSk"
frameborder="0" wmode="Opaque">
<param name="wmode" value="opaque" />
</object>
OBJECT method is now deprecated:
https://developers.google.com/youtube/player_parameters

How to upload vimeo videos using Media plugin (and not HTML option)

I'm working on Ruby on Rails 2.3.8 and the last version of rails tinyMCE plugin.
I would like users to have the ability of adding all kind of videos into the text editor. As it's now, they can add Youtube videos, and also they can upload them from their computer.
The problem is that Vimeo videos don't only create a common HTML <object> code, but they create an iframe for them, and if I try to import one of them using the Media plugin, I'll have to paste this video for example: http://vimeo.com/16430948, and it will generate the following HTML (which won't work):
<object width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="http://vimeo.com/16430948" name="src"><embed width="100" height="100" type="application/x-shockwave-flash" src="http://vimeo.com/16430948">
</object>
While Vimeo videos need the following HTML for being displayed:
<p><iframe frameborder="0" height="225" src="http://player.vimeo.com/video/16430948" width="400"></iframe></p>
<p>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="100" width="100">
<param name="src" value="http://vimeo.com/16430948" /><embed src="http://vimeo.com/16430948" width="100" height="100" type="application/x-shockwave-flash"></embed>
</object>
Now, which is the difference between this two generated HTML? It's that the iframe is missing in the first code I've posted, so it doesn't work.
So, the question is: how do I add that iframe to the tinyMCE programmability so it's automatically added when a Vimeo video is embedded?
Well, you should write your own plugin (it is pretty simple) to check for changes the user made.
When a user entered a vimeo link you just grab the relevant content from the editor and put it into a new element (an iframe).
Your code should look something like this (you will have to modify it, but i am sure you will get the right direction):
// you may choose an other event to check for
ed.onChange.add(function(ed){
var body = ed.getBody();
// check for vimeo using jquery object
$(body).find('param').each(function(index, Element){
// vimeo adress is found in value
if (this.value.search('http://vimeo.com') == -1) return;
var node = this;
var iframe_not_parent = 1;
while(node.nodeName !== 'body'){
node = node.parentNode;
if (node.nodeName !== 'iframe'){
iframe_not_parent = 0;
break;
}
}
// ok, this vimeo thing is not inside an iframe - put it inside
if (iframe_not_parent){
with(document.getElementById(iframe_id).contentWindow){
var new_iframe = document.createElement("iframe");
this.parentNode.parentNode.append(new_iframe);
new_iframe.append(this.parentNode);
}
}
});
});

Putting a link to a flash object swf in a asp.net MasterPage

I have a asp.net master page that gets used by pages many /levels/deep/
I will put a link to a flash file in this template.
I tried doing it like this but it did not work, what the best practice here?
<object width="924" height="200">
<param name="movie" value="/live.swf">
<embed src="/live.swf" width="924" height="200">
</object>
If you using .net and putting an swf into a master.page, use this:
<script type="text/javascript">
swfobject.embedSWF("<%= this.ResolveUrl("~/live.swf") %>", "headerFlash", "924", "200", "9.0.0");
</script>

Resources