I have given a source in a Iframe tag, my is issue is that when the page loads on IE the download begins automatically and it generally happens on IE installed on windows 8.
<div> <iframe src="../../Images/Sample.pdf" width="800px" height="800px" ></iframe> </div>
It's downloaded probably because there is not Adobe Reader plug-in
installed. In this case IE (it doesn't matter which version) doesn't
know how to render it and it'll simply download file (Chrome, for
example, has its own embedded PDF renderer).
That said. is not best way to display a PDF (do not forget
compatibility with mobile browsers, for example Safari). Some browsers
will always open that file inside an external application (or in
another browser window). Best and most compatible way I found is a
little bit tricky but works on all browsers I tried (even pretty
outdated):
Keep your but do not display a PDF inside it, it'll be filled
with an HTML page that consists of an tag. Create an HTML
wrapping page for your PDF, it should look like this:
<html>
<body>
<object data="your_url_to_pdf" type="application/pdf">
<embed src="your_url_to_pdf" type="application/pdf" />
</object>
</body>
</html>
Of course you still need the appropriate plug-in installed in the
browser. Also take a look to this post if you need to support Safari
on mobile devices.
1st. Why nesting inside ? You'll find answer here on
SO. Instead of nested tag you may even provide a custom
message for your users (or a built-in viewer, see next paragraph).
2nd. Why an HTML page? So you can provide a fallback if PDF viewer
isn't supported. Internal viewer, plain HTML error messages/options
and so on...
It's tricky to check PDF support so you may provide an alternate
viewer for your customers, take a look to PDF.JS project, it's pretty
good but rendering quality - for desktop browsers - isn't as good as a
native PDF renderer (I didn't see any difference in mobile browsers
because of screen size, I suppose).
See also: HTML embedded PDF iframe
Related
I have looked around the web and have found that appending #page=?? to the end of a PDF link will automatically take the visitor to that specific page in the PDF file.
I was wondering if this is still best practice as it doesn't seem to be working for me (Chrome on Windows 7). Also, all the articles I have found so far date back to 2006-2008, have things changed recently?
This is still valid code but it may require that some version of Acrobat (Reader, Pro, etc) be installed as a plugin on the browser in order for it to work as expected. Since multiple commonly-used browsers now have a built-in reader (Chrome, Safari for iOS are the big two that come to mind) support for direct page linking is somewhat spotty now. You can still do it...the worst case scenario is that the PDF just opens to the first page for those users but I would advise to just leave off the direct page link. If the page is that important, extract it to a separate PDF and link to that.
Is it possible to display <svg> content inside an <html> in an iOS browser without the use of the <embed> or <img> tags which require me to store the <svg> content in a separate file?
The embedding of <svg> content inside <html> seems to work on all other modern browsers (IE9, Chrome, even Safari on Window!).
I have found some references that suggest changing the content-type to 'text/xml' might work, but I am not able to change it as my code is running as part of a mobile server control in SharePoint 2010.
My page contains several <svg> areas, each of which displays a simple graph. The data for these graphs is stored in a serialized object which needs to be deserialized before the svg polylines can be drawn. Since the deserialization process is time-consuming I prefer to do it once and generate all graphs in a single pass, rather than generating resource references to individual svg files which can be referenced by an <embed> tag.
Edit: There are indications that inline <svg> is supported in iOS5.
If you need to embed the SVG directly in the document
Use XHTML (not just HTML), serve it with the correct mime type, and your SVG will work correctly in all major browsers, including on the iPhone and iPad.
This example file uses inline SVG in XHTML, and even uses JavaScript and CSS in the host document to manipulate the SVG:
http://phrogz.net/SVG/svg_in_xhtml5.xhtml
It works fine in iPhone/iPad.
If you need to reference an external file
Use the <img> tag to reference your SVG directly. This works on iOS.
For example, open this on your iPhone/iPad:
http://phrogz.net/SVG/svg-via-img.html
which references
http://phrogz.net/SVG/heart.svg
Note that there is a bug with WebKit related to rendering variable-sized SVGs inside fixed-size <img> tags. (It appears to draw the aspect ratio for the SVG from the aspect ratio of the containing window instead of the dimensions of the <img> element.) You can see the weirdness in Chrome or Safari if you resize your browser window with that test file.
You may need to use inline SVG inside an XHTML compound document. In this case, XML namespaces are used for both the HTML root element and the inline SVG element. See here for a relevant example:
http://www.croczilla.com/bits_and_pieces/svg/samples/dom1/dom1.xml
Other useful examples may be found here:
http://www.croczilla.com/bits_and_pieces/svg/samples
Have you tried using <object>? I haven't done this in a while but you can Google for that.
In rails is there anything available that if a user uploads a document to me through paperclip (like maybe a .doc or .pdf or .odf, etc.) That i can embed there document into my page (Like perhaps is there some sort of gem available to handle that
I found a solution to the pdf part of my problem.
theres a simple html line that solves this
<iframe src="thispdf.pdf" style="width:718px; height:700px;" frameborder="0"></iframe>
I've tried the same with .odt, but this just downloads the file (maybe this was more of an html problem than rails) -- note i only tested this in chrome
By embed do you mean display? There's no native way to display any of those documents in html, so you will have to either somehow convert them to html or use another layer, like flash or a third-party tool, to do the embedding for you.
Maybe one of the embed.ly providers can give a nice display for your documents.
I used the following code to make mine work in the view (with the example object #person) using the most current (as of 2013) Google Docs embedded pdf code specifications:
<iframe src="https://docs.google.com/viewer?url=http://www.mysite.com/<%= #person.pdf.url %>&embedded=true"
width="100%" height="800" frameborder="0" >
<p>Your browser does not support iframes.</p>
</iframe>
I want to have a web page coded with HTML5, and I want to be able to put a pdf file onto this page so you can view it without having to click on any links to download it separately. Anyone know how to do this?
I want it to keep the text, images, and layout of the pdf file also. If that weren't the case I would just use an image. Thanks!
Edit: This will be hopefully going onto the ipad. So it won't support adobe. I need to just find a way to somehow make the pdf file show up in an html5 page without using a viewer. I want to keep all of its layers. It doesn't have to stay a pdf file when its on the page, I just need to find a way to transfer all of those layers there without having to do this manually with divs for each image, paragraph, etc.
I don't think this is possible without using Flash. Instead, you might want to convert the PDF to a different format (HTML for example) that can be rendered by the browser. There are tools that can do this from the command line, so making a script to do it on your site won't be too difficult.
You can use the embed tag like this:
<embed src="/path/to/your/file.pdf" />
Maybe you could convert the pdf to images on the server and display the images instead of the original pdf. As far as i know, Apache pdfbox can be used to do such a convert.
A little bit late and maybe issuu is gonna fix it soon but for now you can embed with issuu.com using an iframe and your magazine address ending in ?mode=mobile. Tested in ipad:
<iframe width="850px" height="580px" src="http://www.issuu.com/your_username/docs/your_magazine_name?mode=mobile" frameborder="0" allowfullscreen></iframe>
I would like same mobile version loading in desktop so there is no advertising. If you know how to make the browser to think it's an ipad let me know.
This code would directly embed a pdf viewer in a webpage
<object data="path to pdf " type="application/pdf" width="100" height="100">
<p>Alternative text - include a link to the PDF!</p>
</object>
If you are using ASP.NET, this link may be of interest to you.
Browser Based PDF Viewing And Editing
Hosted entirely on your server,
activePDF Portal is an ASP.NET
WebControl that enables your users to
interactively view and modify PDF
documents from any source - adding
comments, form fields, bookmarks, and
more – directly from within a standard
web browser, without requiring any
client-side software such as Adobe
Reader or Flash, or the use of ActiveX
controls.
- http://portal.activepdf.com/
PDFObject looks promising, but it doesn't work on iPads at the moment.
Does anybody use bare .SWF files as webpages?
I know it's possible; it seems to work fine for me.
Why would I embed a SWF inside an HTML page if it's just going to be full screen (I mean the size of the browser's normal viewable page area, not COMPLETELY fullscreen)?
Is there a lack of browser support?
Or is this functionality determined by the browser's Flash plugin?
If you embed it in html page and the client doesn't have the flash plugin, most browsers show a missing plugin message. If u directly host the swf, a plugin-less browser might consider it as a download link and try to download the swf into the client machine instead of showing the missing plugin message.
My opinion is that if the browser has the Flash plugin it will render it, and it's up to you to implement how the swf behaves when you scale/resize the browser window/etc.
You can embed a swf in an HTML page and have it full browser screen offcourse, and you could interact with the browser a bit better ( some nice javascript/flash action going on ), not mention it would be more SEO/standards friendly.
I would recommend using SWFObject. Have a look at the fullpage demo.