How To Open PDF Files Inside Chromium? - javascript

I'm using nodejs and chromium for my desktop app. The problem is that I can't open pdf files in chromium. So I googled and found that most of the answers are related to mozplugger plugin. I installed the plugin as mentioned in the below link:
http://www.tootips.com/2013/01/how-to-open-pdf-files-inside-chromium.html
Now I'm getting an error message : "Mozplugger: M4 parsing of config generated error" when I try to open pdf file in chromium. How can I resolve this error?
Please help me!

If you look at this Ask Ubunutu question you'll see you can actually use Chrome's PDF viewer with Chromium.
Chrome has a nice PDF plugin that lets you open in the page, but it's not open source so it's not included with Chromium. You could install Chrome and symlink the plugin, then whenever you update Chrome you would also get that updated in Chromium. Alternatively, you could copy the plugin over to Chromium, and uninstall Chrome, but you won't receive updates that way.

Have you tried using PDFjs as a totally javascript based alternative solution?
https://github.com/mozilla/pdf.js
It is relatively new but works on many different examples, maybe it is good enough for your application.

In Linux I think we need mozplugger plugin for viewing pdf files. I just removed and installed mozplugger again (Reference links: http://www.tootips.com/2013/01/how-to-open-pdf-files-inside-chromium.html, http://mozplugger.mozdev.org/ ) and now it seems to work.
In windows we need to install a system pdf reader like acrobat (http://www.adobe.com/in/products/reader.html), as chromium downloads and displays pdf with system PDF viewer (Reference link: http://code.google.com/p/chromium/wiki/ChromiumBrowserVsGoogleChrome).
An alternative solution is to open the pdf link in default browser with help of node.js using below script.
Install the node.js open module:
$ npm install open
use:
var open = require('open');
open('http://www.google.com', function (err) {
if (err) throw err;
console.log('The user closed the browser');
});
Reference link: How to use nodejs to open default browser and navigate to a specific URL

You can use this extension by Google: ExtensionDocs PDF/PowerPoint Viewer which also allows you to open docx, ppt, rar and many more file types.

Google recently announced that Google Chrome PDF Viewer goes to open source. It means that in near future Chromium browser and Chromium OS users can soon enjoy the Chrome PDF viewer, without any workarounds!
See PDFium project web page at https://code.google.com/p/pdfium/

Related

Using window.open with blob files not working with Cordova or Electron

I am building my Apps with JavaScript using Cordova and Electron for mobile and desktop apps. In my App, I have a offline feature, where you can download content which is saved using localforage. It works great to show my images, audios, videos and so on.
However, I also have files in the app for users to download (zip, pdf, ...), by using the window.open command, which works as long as I'm using the file's url from the server. But when I use the offline feature and use the blob-url from my localforage, the app doesn't react at all to my onClick event. It doesn't open and also showing no errors in the console.
In the browser though it works just fine, whether it's the blob-url or server-url.
I first used window.open(src, '_blank');, but also tried to remove the _blank attribute with no luck.
Any help would be very appreciated! Thanks!

Add-on "appears to be corrupt" when trying to install my add-on's .xpi file in Firefox

I am trying to install an extension in Firefox 45 (same happens with Firefox 49), but Firefox does not allow me to do that, indicating that
This add-on could not be installed because it appears to be corrupt.
The way I am trying to install it is simply by dragging the .xpi file our team developed, into the Firefox window. This extension is based on MozRepl, but with some improvements.
Previously, I tried to install it but I couldn't as it was not signed (extensions in Firefox versions from 43 onwards require signing). I followed every step in order to sign it, according to this post: Signing a XPI. I am almost certain I could sign it correctly, but now the error Firefox displays is different: "This add-on could not be installed because it appears to be corrupt."
It seems that I am not creating the .xpi file correctly, but I am not sure which is the correct structure it should have. I tried different folder structures, but with no success.
Also, I checked the Browser Console to see what error is logged in, but I didn't found it really helpful. Here it is:
Here is a link to the .xpi file in case you want to check its content. Note that I tried moving the files manifest.mf, zigbert.rsa and zigbert.sf outside the META-INF folder, but it didn't work either.
Has anyone stumbled across an error like this when trying to install an add-on? Any ideas of what maybe happening?
The .xpi file must use only "deflate" compression or uncompressed
The zip implementation within Firefox only supports uncompressed files or files compressed with the "Deflate" algorithm. You will need to create the .zip archive using the compression method "Deflate" instead of the "LZMA" which you are currently using. How to do so will depend on the tools you use to create your archive.
Personally, I use a batch file/shell script to create the .xpi file as I describe in detail in my answer to "Firefox extension .xpi file structure: description, contents, creation, and installation". The basics are that I use the zip command line tool which defaults to "deflate" or uncompressed. I use the -1 option to provide the fastest compression. Firefox/Mozilla use .xpi files both to package the files, but to also increase file access speed. The important quality is not a high compression ratio, but that the files can be accessed quickly. Unless Firefox is not an WebExtension and explicitly told to unpack the add-on by the install.rdf option <em:unpack>true</em:unpack> (WebExtensions don't have install.rdf files), the add-on will be installed as the .xpi file and all access to the add-on will be as the .xpi file.
Note: Given that your extension contains .dll files, you may need to have your add-on installed unpacked by using <em:unpack>true</em:unpack>.
Wrong signing method used. It must be signed by Mozilla, not yourself.
While it is not the error you are currently seeing, as soon as you fix the problem with your .xpi format, you will encounter an issue with your extension being signed by the wrong signature. You signed your extension with your own signature. It was not signed by Mozilla. This will not work. It must be signed by Mozilla, not yourself.You mentioned that you followed the directions in the MDN page Signing an XPI. However, as is clearly stated at the top of that page, the directions on that page are outdated and no longer work. You should have followed the link in the note to the page Signing and distributing your add-on. The note at the top of the page states:
Note: These instructions are outdated. For an extension to work in Firefox it must be signed by Mozilla, not by yourself. See Signing and distributing your add-on. [Emphasis added]
There are also a variety of questions here on Stack Overflow which address the signing issue.
Like stated in other answer it happens for unverified/unsigned extension.
But sometimes for testing you might want to use unverified/unsigned extension.
As a hack/workaround to install unverified/unsigned extensions following worked for me on Firefox version 45:
Launch Firefox and hit - about:config
Search for 'xpinstall.signatures.required'
Either double click on the row OR set the value to false and close
Now retry installing the extension and it should work.
I think there is something not clearly documented, I'd like to share my experience.
Developed my extension and zipped all the files
Selected On your own for How to Distribute this Version step and uploaded .zip to AMO
Then, on the next page, I see a signed .xpi file available for download. I downloaded it and tried to install via "about:addons -> Install Add-on from file"
I get corrupt add-on error in this case
After receiving e-mail from amo-editors#mozilla.org, I went to my add-on's page and clicked on .xpi file link there and it worked!
I had this issue when I compressed the folder containing my addon rather then just the files within.
Don't Compress the Parent Folder of your Manifest
For example, on Windows CTRL+Click on your manifest and any other files or subfolders; right click and select Send to > Compressed Folder and you should be good to go.
Note: from the browser console screenshot we can tell this isn't the issue in this case, but even so this is a common problem to the This add-on could not be installed because it appears to be corrupt error.
The message because it appears to be currupt can point to various problems. You can see a more detailed error message in the Browser Console at ctrl+shift+J.
As soon as you edit anything inside an xpi file and try to add it manually to the browser, an extension ID needs to be provided inside the manifest.json if it isn't already, with applications.gecko.id or browser_specific_settings.gecko.id. For example, altering any single character in https://addons.mozilla.org/en-US/firefox/addon/quick-js-switcher/ shows Invalid XPI: Error: Cannot find id for addon in Browser Console, so you add
"applications": {
"gecko": {
"id": "some#example.com",
"strict_min_version": "1.2.3"
}
}
to the manifest.json as well and it works: But only with about:config's xpinstall.signatures.required set to false on Firefox versions that actually respect this setting, which excludes the normal release one because apparently Mozilla hates its userbase. You need FF Nightly or the like, I'm using LibreWolf.
source
This is an answer to a tangential question when the "The add-on downloaded from this site could not be installed because it appears to be corrupt" error message starts appearing when trying to install any Thunderbird add-on. There are some other sites where this tangential question has been asked but the pages got archived:
https://www.reddit.com/r/firefox/comments/7942yu/the_addon_downloaded_from_this_site_could_not_be/ (for FF)
https://support.mozilla.org/en-US/questions/1319105
http://forums.mozillazine.org/viewtopic.php?f=39&t=2739869
Since this question here still allows replies, just wanted to add that this can occasionally start happening for all add-ons if the user's local Thunderbird profile files gets corrupt in some specific way.
In such case, I recommend restarting Thunderbird in "safe mode" with all add-ons disabled via "Help" -> "Restart with Add-ons Disabled...", and then restarting back to the "regular" mode via "Help" -> "Restart with Add-ons Enabled". After that installation of add-ons may work again.
Even though this is not the answer to this specific question, hope this tip is helpful for whoever hits this specific tangential but similar situation.
I had the same problem on firefox 52, just downgrade the addon to a lower version designed for firefox 52 or less will fix this problem.

How to test firefox plugin locally

I have a basic Google Chrome extension which needs to be ported to Firefox. I uploaded the .crx file to the Firefox marketplace and it got accepted but is under review rightnow. I downloaded the the generated xpi file and tried to install it locally but without any success. It tell that the plugin is invalid or corrupted.
Another method that I tried is I ported the extension using chrome-tailor and generated the xpi. I am able to install the extension in this but the content scripts are not injected and the extension doesn't work as expected.
I want to install it in Firefox and test it. I have also set xpinstall.signatures.required to false.
WebExtensions
To test WebExtension based add-ons, they are usually loaded as a "Temporary Installation in Firefox"
That MDN page describes how to temporarily install a WebExtensions (i.e. similar code to Chrome) in Firefox. The gist of it is:
Navigate to about:debugging
Click the button "Load Temporary Add-on"
Use the file selection dialog to select the manifest.json file, or packaged .xpi file for the extension.
Note on testing WebExtensions:
The WebExtensions API is still in development. For now, you are probably best off developing and testing your WebExtension add-on with Firefox Developer Edition, or Firefox Nightly. You should also make careful note of what version of Firefox is required for the functionality you desire to use. This information is contained in the "Browser compatibility" section of the MDN documentation pages.
Firefox Add-on SDK
To test Firefox Add-on SDK based ad-ons, use jpm run. You might want to take a look at this answer to "jpm run does NOT work with Firefox 48, or later"

How do I check in Firefox and Chrome if a plugin is installed

I'm using an embedded plugin in my web app to enable scanning (Dynamsoft's webscanning plugin). I'm serving an xpi to firefox users and a crx to chrome users. When viewing the page without the plugin installed, Firefox will try to download the plugin and the user will need to click "manual install" to install it. Chrome will make no attempt to donwload the plugin (this is by design, according to http://code.google.com/p/chromium/issues/detail?id=15745)
I would like to use javascript to detect wether the plugin is installed or not (preferrably before trying to load it through the embed tag). If no plugin is installed, I want to provide an explanation and a link to the correct plugin to the user. Both browsers install their respective plugins without any problem if the user clicks at a download link instead of just trying to load through the embed tag.
So, does anybody know a way detect wether a plugin is installed using javascript?
Have you had a look at window.navigator.plugins?
..and the equivalent reference for webkit plugins-
The Apple reference for the WebKit DOM appears to have disappeared. navigator.plugins does work for me in Safari & Chrome. See a jsfiddle here: http://jsfiddle.net/2EaKD/
Sounds to me like a potential security hole, if a website (something remotely) could access your plug-ins (something locally). So I guess this is not possible.
Your addon can monitor which pages are opened by the user. If it is your page, you can make your addon set a global variable in that page and your page's JavaScript should be able to detect this.

Editing pure JavaScript extensions directly in Chromium

I'm developing a JavaScript extension for Chromium and my current workflow is:
Edit file
Uninstall old file
Install new file
Test file
Is there a quicker way of doing this?
I'm using chromium-browser_5.0.375.125 in Ubuntu 10.04.
Load your extension into Chromium
Find your extension's ID:
Go to the extensions page chrome://extensions/
Click + Developer Mode
Scroll down to your extension and look at the ID: field
Open ~/.config/chromium/Default/Extensions/ID/VERSION/script.js in a text editor
Now simply edit, save, and test
For a pure JavaScript extension the version number should be 1.0.

Categories

Resources