Initial Zoom Parameter for PDF Object in HTML5 - html

I am building a page that will display a PDF file on the page. When viewing this page in Chrome, the zoom level is set by default so that the document is wider and taller than the allotted space. Safari seems to have a preferable default of fitting the page to the available space, just FYI.
I would like to know if there are any parameters that can be set in <object> to force the initial zoom level of the document. It might be name=initZoom with values like "fitToPage" or "fitToWidth" or "70" (for 70% zoom). It might look something like this:
<object data="/path/to/file.pdf" type="application/pdf">
<param name="initZoom" value="fitToPage" />
</object>

Does Adobe's document 'Parameters for opening PDF files' help you?
According to that document, something like
<object data="/path/to/file.pdf" type="application/pdf">
<param name="view" value="Fit" />
</object>
could work, or even
<object
data="/path/to/file.pdf#toolbar=1&navpanes=0&scrollbar=1&page=3&view=FitV"
type="application/pdf">
<p>It appears you don't have a PDF plugin for this browser.
No problem though...
You can click here to download the PDF.
</p>
</object>

See demo here http://jsfiddle.net/6TNrw/68/
The above works if the pdf viewer object is adobe.
Google chrome has its own pdf viewer so changing its zoom parameter wont work for that.
<object data="http://www.nclabor.com/wh/faqs.pdf?#view=fitH"
type="application/pdf"
width="100%" height="100%">
<param name="view" value="fitH" />
</object>

Adding a late answer since none of the existing ones worked for me, and someone might need it.
Instead of adding '#view=fitH' or '#view=fitV' to the pdf url, which didn't work for me, i got it working by adding '#zoom=scale', like this:
<object data="/path/to/file.pdf#zoom=scale" type="application/pdf">
</object>
Hope this helps someone, and sorry for any inconvenience.
EDIT:
Found more parameters here. Found the link in this thread, which is basically the same question as this.

Another late answer (looks like we're on a 2-year cycle...)
I found that setting the parameter #zoom=Fit finally did the trick. This is only in FF so far. Chrome is laughing at every parameter I feed it.
Note that the documentation states that view gets the Fit values, but zoom is the one that seems to do anything with them.
I hope this helps someone down the line.

Related

Uploading Flash File in blogspot

I've been trying to upload my flash file to my blog but after several attempts, nothing came out .
i even tried using online swf generator
Does anybody came across a solution on how to upload flash swf file on blog?
In my blog , in html view, ive tried using this code below after i generated it through http://www.fastswf.com/ . There was no error when i publish , but the thing is, nothing appeared(No swf / flash) when i went to preview mode to see the post.
these are the embedded codes i tried.
<object type="application/x-shockwave-flash" id="" data="http://cdn.fastswf.com/files/XASY3qs/XASY3qs.swf?AWSAccessKeyId=AKIAIWTOYM4XXIVL5IGQ&Expires=1472073138&Signature=n%2Fjw%2FeyscBCoeovQq8KqFx8Y0aI%3D" width="400" height="299"><param name="menu" value="false"><param name="scale" value="noScale"><param name="allowFullscreen" value="true"><param name="allowScriptAccess" value="never"><param name="bgcolor" value=""><param name="wmode" value="direct"></object>
i tried creating new html and paste this code in my test.html i created using notepad , it works perfectly fine,
but when i paste it in my blog in html view, nothing came out. anybody ever did came across this problem?
That should work, but if it is not working here are workarounds you should try out:
Check whether your browser has latest flash plugin.
Check where you have placed HTML tag under <body> tag or <head> tag.
As this link says, "HTML 5 does not support object tags in Head section of HTML."
Try with one <param> at a time to find out whether its problem with
any parameter altogether.
Let me know if anyone works out. Hope it helps!

HTML embedded PDF iframe

I have used the tag to embed a pdf file.
<iframe id="iframepdf" src="files/example.pdf"></iframe>
This works fine in Chrome, IE8+, Firefox etc, but for some reason, when some people are viewing it in IE8, the files are downloading instead of embedding. I know this browser is outdated but it is the standard browser within my office and as such, the website has to be designed for this.
Does anyone have any ideas on why this is happening, how I can fix it or else put an error message instead of letting the files download?
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 the file (Chrome, for example, has its own embedded PDF renderer).
If you want to try to detect PDF support you could:
!!navigator.mimeTypes["application/pdf"]?.enabledPlugin (now deprecated, possibly supported only in some browsers).
navigator.pdfViewerEnabled (live standard, it might change and it's not currently widely supported).
2021: nowadays the original answer is definitely outdated. Unless you need to support relatively old browsers then you should simply use <object> (eventually with a fallback) and leave it at that.
That said. <iframe> 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 <iframe> but do not display a PDF inside it, it'll be filled with an HTML page that consists of an <object> 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">
<div>No online PDF viewer installed</div>
</object>
</body>
</html>
Of course, you still need the appropriate plug-in installed in the browser. Also, look at this post if you need to support Safari on mobile devices.
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 that you may provide an alternate viewer for your customers, take a look at 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).
If the browser has a pdf plugin installed it executes the object, if not it uses Google's PDF Viewer to display it as plain HTML:
<object data="your_url_to_pdf" type="application/pdf">
<iframe src="https://docs.google.com/viewer?url=your_url_to_pdf&embedded=true"></iframe>
</object>
Iframe
<iframe id="fred" style="border:1px solid #666CCC" title="PDF in an i-Frame" src="PDFData.pdf" frameborder="1" scrolling="auto" height="1100" width="850" ></iframe>
Object
<object data="your_url_to_pdf" type="application/pdf">
<embed src="your_url_to_pdf" type="application/pdf" />
</object>
Try this out.
<iframe src="https://docs.google.com/viewerng/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" frameborder="0" height="100%" width="100%">
</iframe>
Use Adobe Embed PDF API. This is the solution i used in the end, Works perfectly.

.SWF Object Shrinking in IE 8

I am having an issue in WordPress. I've embedded a .swf as an object, but in IE 8 it shows really small. I've attached a screenshot of the IE issue. It's that really small picture on the left. To see a working version, check out the page here on another browser.
I would love to disregard this issue, but unfortunately our company runs on IE so I need to fix this.
This is all created in WordPress. The .swf is hosted externally. Here is the code:
<object width="680px" height="300px">
<param name="movie" value="http://www.pplweb.com/ppl-generation/~/media/PPLWeb/Generation/Media/PPL%20Susquehanna/nuclear.swf">
<embed src="http://www.pplweb.com/ppl-generation/~/media/PPLWeb/Generation/Media/PPL%20Susquehanna/nuclear.swf" width="100" height="100">
</embed>
</object>
Embed it using SWFObject, it's the most reliable way to insert SWF files. WordPress already comes bundled with it, so you just need wp_enqueue_script('swfobject');, and then use the script embedding accordingly.
Or you can use a plugin: wordpress.org/plugins/search.php?q=swfobject.

Ruby: how to ouput PDF object element?

I am embedding a pdf file in rails view using embed tag, i have write it in simple html and its working fine but i need to write this tag in rails conventions.
The code is like:-
<object data="file1.pdf#toolbar=0&navpanes=0&scrollbar=0" type="application/pdf" width="100%" height="720">
<embed src="file2.pdf#toolbar=0&navpanes=0&scrollbar=0" type="application/pdf" width="100%" height="720" />
</object>
It seems Ruby uses print to output to a client...
print 'Hello World!'
There is no "embed tag", that is an "object element"; using the correct terminology not only makes you look more professional to others though also greatly improves your ability to communicate in fewer steps. 99.9% of the time people are referring to an element, it is the whole element. A very rare correct reference to a tag would be something like, "In XHTML does the meta element self close or does it have an end tag?" (e.g. < meta / > or < meta >< / meta >).
Internet Explorer (as usual) has a bug that is unable to display flash objects correctly in certain situations such as with your code, I'm not sure if this applies to a PDF but they're both Adobe products so best to try this in IE7 to be sure. You need to have a movie parameter element.
Here is everything put together along with Ruby...
<object class="pdf" data="something.pdf" type="application/pdf">
<param name="movie" value="something.pdf" />
<p>This is alternative content that displays if the plugin is not suppoted.</p>
</object>
Another very important clarification: you need to have a height/width set or at least a minimum height and width set otherwise certain browsers (e.g. Firefox) will not load the resource. In fact when I change themes on my site if the dimensions change in the middle of the music playing the whole Flash object resets. Not such a big issue for a PDF though if it forces the browser to reload the PDF it may annoy your visitor and it's ALL about making sure your visitors aren't annoyed by doing things right the first time.
Lastly alternative content is any (X)HTML that appears inside the object element. You can add a link to download a PDF plugin if the client's browser doesn't already support one.
Hope this helps, feel free to ask for clarifications if need be.

flash not rendering in Internet Explorer

Hi have the following flash object placed in HTML, flash seems to be rendering good in Firefox, Chrome, Safari but not in any version of IE!!!
Can someone please let me know whats wrong in this object, or what I miss specially for IE!!
Thanks in advance,
Tanmay
Use SWFObject for embedding Flash elements, it will solve all your cross-browser issues.
I believe you need the movie param. This works for me:
<!doctype html>
<object data="http://jquery.thewikies.com/swfobject/fireworks.swf" width="440" height="550" name="demoLaunch" id="demoLaunch" type="application/x-shockwave-flash">
<param value="true" name="democonnect">
<param value="always" name="allowscriptaccess">
<param value="transparent" name="wmode">
<param value="demo1=1&demo2=3&demo3=12&demo4=19" name="flashvars">
<param name="movie" value="http://jquery.thewikies.com/swfobject/fireworks.swf">
</object>
It is better to rely on Javascript to control no flash fallbacks in addition to cross-browser JS for this purpose. I would recommend jquery swfobject.
Have you tried validating your HTML and CSS? You almost certainly have a coding error in there somewhere and that will help you find it. http://validator.w3.org/
Actually, the problem here is that you're using W3C valid HTML, which IE has a tendency not to get along with. To get IE to embed flash content you need to use embed, which does exactly the same thing as object but is not part of the W3C standard.
The syntax for the embed tag is as follows:
<embed src="somefilename.swf" width="550" height="400"></embed>
This is often just placed inside of the object tag, so that both options are on the page (don't worry, it won't be rendered twice in browsers that understand the object tag you already have).
A common way to get around using non-standard HTML is to do the embed with Javascript, which writes non-standard HTML code to the browser but not until after the page is rendered. This allows the page to pass the W3C HTML validator, and still work cross-platform. The best javascript library for doing this is generally SWFObject, which lets you just include the flash content once and will write html out for whatever browser the user is viewing your content in.