How to Specify Parameters to Google Chrome Adobe PDF Viewer

How to specify parameters to google chrome adobe pdf viewer?

After checking various chrome bug reports, I can confirm that Google Chrome ignores the default functionality of Adobe PDF viewer. At the time of this answer there is no way to pass parameters (like zoom) to the Chrome PDF viewer.

EDIT

Progress has been made on this by the Chromium team. The work was being done with reference to both the Acrobat SDK and RFC 3778. As of Dec 2017 Chromium added support for view, zoom, page, toolbar and nameddest and later made it into Chrome.

HTML : How to specify PDF open parameters for Chrome native PDF reader?

I am just quoting @Robotsushi answer he has written in his topic for closing the question :

After checking various chrome bug reports, I can confirm that google chrome ignores the defualt functionality of adobe pdf viewer and at the time of this answer there is no way to passing parameters like zoom to the pdf viewer in chrome.
I hope this saves someone else some time.

EDIT:
See the quoted answer for updated information. As of Dec 2017 Chromium added support for view, zoom, page, toolbar and nameddest and later made it into Chrome.

How to use PDF open parameter (e.g. fitH) in Chrome/ FireFox browser?

Searching a solution for a problem very similar to yours, I found an interesting thread on forum.asp.net. http://forums.asp.net/t/1877403.aspx?Issue+with+embedded+pdf+object+in+chrome+browsers

At the end of the page, there is a workaround by a user working smoothly in Chrome. That seems to solve the problem.

Here it is an example:

<iframe src="/Downloads/MyPdfDocument.pdf#view=fitH" width="700"  height="880"></iframe>

For users fighting with http://pdfobject.com/ -> "pdfobject.js" like me, you can change few lines of code on both minified and develop version of pdfobject.

Find:

c.innerHTML='<object    data="'+a+'" type="application/pdf" width="'+i+'" height="'+z+'"></object>';return c.getElementsByTagName("object")[0];

and change with this line of code:

c.innerHTML='<iframe src="'+a+'" width="'+i+'" height="'+z+'"></iframe>';return c.getElementsByTagName("iframe")[0];

Hope this helps.

Stream PDF to browser and utilise Adobe PDF parameters such as #search, #zoom, #page

Okay finally I worked this one out! The answer given in the other question is the actual answer, understanding it however was the tricky part!

Have this code in your page:

<%
response.Clear

Response.Buffer = False
'This is download
Response.ContentType = "application/pdf"
'Set file name
Response.AddHeader "Content-Disposition", "inline; filename=myfile.pdf"

set stream = Server.CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1 ' binary
stream.LoadFromFile("c:\test.pdf")

Response.BinaryWrite(stream.Read)

Response.End()
%>

And then you pass the parameters to the adobe reader through the url! So if the code above is in a page called: default.asp

then do this: http://www.yoururl.com/default.asp#search=fox&zoom=20&page=2

and it will work a treat! Not in google chrome mind you! I googled about getting this sort of thing working in chrome however google didn't code in parameters into their pdf viewer.

Is there a way to style Google Chrome default PDF viewer

There is no way to directly style the Chrome default PDF viewer (PDFium). Because the plugin displays and controls content outside the scope of the current page's DOM, it can only be modified by the plugin. As indicated here it is impossible to make modifications to this sort of plugin controlled content unless the plugin also adds a content script that allows the page to pass messages to the plugin; the plugin must additionally be programmed to respond to messages and appropriately update the content. In other words the PDF viewer uses a separate DOM to the page which is not directly accessible. Instead you need to access an implemented API.

In this discussion Mike West (Google/Chromium dev) states, in answer to a question on DOM accessibility in Chrome's PDF viewer:

The functionality available in the PDF viewer is (intentionally) fairly limited ... The APIs you're having trouble finding simply don't exist.

Basic API functions are some of those specified by Adobe in their Parameters for Opening PDF Files and are accessed through the URL (eg http://example.org/doc.pdf#page=3&pagemode=thumbs. They are, as indicated above, quite limited, allowing the user to go directly to a page, set zoom factor, show thumbnails etc. Accessing an expanded API through content script messages can potentially be done if you know the available JavaScript messages. A complete list of available JS message names can be determined from the relevant PDFium source here from which it can be seen that advanced styling of the viewer, such as changing colours, isn't possible. (This question gives an example of how to implement the API). Certainly there is no access to PDFium's DOM.

This API is deliberately left undocumented; it may change with additions or removals at any time. Thus, while it's possible that in the future there will be an API to let you style some aspects of the viewer, it's very unlikely that any would go so far as to change the background colour or modify a CSS shadow. And, as stated above, without an API you can't modify content controlled by a plugin when you don't have access to its DOM.


You may, instead, wish to try PDF.js. It is an open source JavaScript library that renders PDF files using HTML5 Canvas. It is also Firefox's default PDF viewer and is quite capable.

Implementing it as a web app is beyond the scope of this question, but there are many helpful tutorials available. And as you, the developer, will have access to all constituent files, you will certainly be able to style the PDF.js viewer as much as you wish.



Related Topics



Leave a reply



Submit