Here's how I went about it: cd ~/code/chrome #Chrome pdf reader installWe also need to install a build-time dependency called go-bindata. It's written in Go, so we need that to build it. The only one that I know of is ChromePAK-V5. The first thing we need is a tool that can unpack resources.pak. What we need to do is unpack resources.pak on disk, edit the files that style the PDF viewer, and then repack the bundle. When Chrome is built, these "resources" are bundled together into a single file, resources.pak, which the browser unpacks into memory during startup. The Chrome source tree contains thousands of HTML, JS, and CSS files that control the behavior and appearance of many parts of the browser, including the PDF viewer. It's so much easier on my eyes compared to the default background, which, when inverted, is blindingly bright. I like to change the PDF viewer's background to white, so that when I activate the color-inverting Deluminate extension at night, I get a nice solid black background. Still, to me, the effort is well worth it. #Chrome pdf reader updateThanks, Google.Īs a matter of fact, there is a way, but we've got to get our hands dirty, and the process must be repeated every time we update Chrome. #Chrome pdf reader downloadIt should still be possible to download the Chromium source, edit the files described below, and then recompile, but that's much more painful than simply hacking resources.pak. Update: Recent versions of Chrome seem to have moved the PDF viewer resources out of resources.pak and into the browser binary itself. 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. Implementing it as a web app is beyond the scope of this question, but there are many helpful tutorials available. It is also Firefox's default PDF viewer and is quite capable. It is an open source JavaScript library that renders PDF files using HTML5 Canvas. 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. 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. This API is deliberately left undocumented it may change with additions or removals at any time. Certainly there is no access to PDFium's DOM. #Chrome pdf reader how to( This question gives an example of how to implement the API). 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. Accessing an expanded API through content script messages can potentially be done if you know the available JavaScript messages. They are, as indicated above, quite limited, allowing the user to go directly to a page, set zoom factor, show thumbnails etc. The APIs you're having trouble finding simply don't exist.īasic API functions are some of those specified by Adobe in their Parameters for Opening PDF Files and are accessed through the URL (eg. The functionality available in the PDF viewer is (intentionally) fairly limited. In this discussion Mike West (Google/Chromium dev) states, in answer to a question on DOM accessibility in Chrome's PDF viewer: Instead you need to access an implemented API. In other words the PDF viewer uses a separate DOM to the page which is not directly accessible. 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. Because the plugin displays and controls content outside the scope of the current page's DOM, it can only be modified by the plugin. There is no way to directly style the Chrome default PDF viewer (PDFium).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |