PDF.js not rendering document in Windows 7 and IE 11 - javascript

We have embed using an iframe PDF.js using the latest version downloaded from their site.
The problem we are having is that for some users the document is not being rendered on windows 7 with IE 11. Instead of the content of the document they get a blank page.
We narrow it to that configuration, but what is more confusing to us is that if we log with another user to the same machine (using remote desktop), the other user can see the document without any troubles.
I can post the pdf document since it contains sensitive data from our customers/clients. How ever the pdf contains some text and images.
We check the settings and found nothing different, except the fact of an intel graphics driver that may be old.
Do someone know if there is an specific setting on IE or something related to PDF.js that needs like webgl or similar to work?
sorry for being vague but i have no clue and i'm a little bit lost trying to figure out this issue.
thanks in advance

Using the latest version of the PDF Js library and updating the drivers for the intel 4000 graphic card solved the problem. It was only happening in machines with that configuration.

Related

CefGlue silent printing to PDF

I have latests CefGlue version (3.2272.2035)
I need to save current page as PDF. I'd like to interact with my CEF somehow (JS/C#) and make it create PDF for me.
I've tried to use javascript.window.print() for that purpose with no success, because, all i've got is such window.
I've found OnPrintJob method in CefPrintHandler but I don't know what is the right way to call it + comments say: "Implement this interface to handle printing on Linux"
and I need to handle printing to pdf on Windows environments (both x64/x86)
Any code example would be appreciated. Thanks in advance for any help.
You'd need to merge this patch and recompile cef from source; Besides, you might have to add some glue logic to CefGlue. I tested the patch myself (on C++ API) and it worked fine.
EDITED: the patch will be merged in trunk.
If you only need to print some pages (specially if these pages are under your control), you will do just fine. However if you need (as I did at the time) to print almost anything, you'll probably face the fact that some web pages don't render anything useful to the print view. Also, even those well-behaved diverge significantly from what you see on the screen - and that's not a CEF behavior, as even google chrome showed the same issues. In my application this was a no-go so I dropped printing and started capturing the screen (and implemented saving that to a pdf using a pdf library in C++), but perhaps your application isn't as demanding as mine was. Cheers!

Taking screenshot using javascript in chrome packaged app

I need to grab the current html inside a chrome packaged app. I am aware of Taking screenshot using javascript for chrome extensions but when I tried this, chrome states that the "tab" permission is not allowed for packaged apps.
Is there any way I can reliably grab the current page?
You cannot do what you are trying to do with a packaged Chrome application. Instead, you should probably look at making an extension, as that would be the way to go if you want to interact with the current page.
If you're unsure, here's a resource for figuring exactly what you should choose: https://developer.chrome.com/webstore/choosing
Not from a chrome extension, as those are browser-centric solutions (not webpage-centric).
Niklas Von Hurtzen has created a very useful js extension called html2canvas that essentially does what you're looking for, just not as a chrome extension. You can see it here.
Once "rendered," the plugin will create a canvas element by traversing the DOM tree of whatever you hand to the extension. From there it's pretty simple... yourRenderedCanvasElement.toDataUrl() will return a data: URL representation of that canvas element, which by default is a PNG, giving you a "screenshot."
Edit: Ha, I see now that you reference this exact thing in the message thread in the other answer...

How Do I Use Smokescreen/JavaScript to Convert Flash to an Image

I have a simple script from AccuWeather to display a weather button on my website:
I love the simple way this button displays. It's perfect for what I want.
However, the button generated is in Adobe Flash format (swf) and doesn't display on most mobile devices since iOS and Windows Phone have no support and Flash Player for Android is no longer available for download from the Google Play app store.
I thought I found a solution in an Open Source project called Smokescreen that has its development area at Github.
I don't need this to reproduce flash movies. All I need is a simple javascript-based conversion of the flash button to a flat image that can be displayed in any browser that can execute javascript, which includes mobile devices.
But the documentation and description of how to use Smokescreen at their GitHub site is minimal at best, and I'm not a javascript expert and cannot get it working.
The call I am making that obtains the Flash image from AccuWeather is:
<script src='http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2ex.asp
?partner=netweather&tStyle=whteYell&logo=0&zipcode=NAM|CA|MB|WINNIPEG|
&lang=eng&size=7&theme=blue&metric=1&target=_self'>
</script>
Can anyone tell me what the javascript would be to use Smokescreen to display the flash image produced by the above code as an image.
If Smokescreen can't do it, is there any other method that can do this live on a webpage?
Just tested smokescreen with the SWF of the page you posted, and it doesn't work, you will need to parse the SWF at server side if you still want to use that site.
I opened the dev console and tracked down the SWF from the iframe
copied the file into my computer, then
cloned the github repo and
edited the player.html (from the github repo), line 13 to point to the file I downloaded.
This is the SWF I downloaded: http://netwx.accuweather.com/netWx-V212.swf?zipcode=46958
Edit: this is the error message I got from the dev console:
TypeError: this.defineEditText is not a function [loader.js:136](https://github.com/cesmoak/smokescreen/blob/master/src/player/loader.js#L136)
My system asks for permission to allow the SWF to connect to netwx.accuweather.com.
A quick search on github reveals some nice pure javascript alternatives.
https://github.com/search?l=JavaScript&q=weather&ref=searchresults&type=Repositories
I think this one looks the most promising: http://simpleweatherjs.com/
This simpleweatherjs demo shows a nice icon as well: http://codepen.io/fleeting/pen/wHism
unfortunately there is no way your javascript can handle swf, espacially on mobile devices like whith ios or windows phone since the javascript is running on your device itself.
all you could try is to use swfobject which is described as a workaround for javascript
here is the documentation of swfobject
Have you considered using a headless browser like phantomjs? You could use something like Selenium instead for out-of-the-box plugin support, but there are headless options for Flash.
The beauty of such software is that it can automate any user task (that's why it's used for testing). Like logging onto a site and performing a search that would normally not be available externally because of antiforgery tokens. Or checking if a product's price has changed by seeing if its DOM element value's has changed. Or accessing your online banking to see if your balance is a prime number and rendering your credit card bill in fractal form.
I mean, if you want to go this far for a weather widget, you probably have power user needs :)
...also Accuweather seems to do a fairly similar mobile-friendly version. And if it's not 100% the same, you could always ask.
Edit: check their T&C, the mobile-friendly snippet might actually be the only option for legal reasons.

Webfont in Windows Phone 8 HTML5 App

I can't get any web fonts to work in my Windows Phone 8 HTML5 Application.
I do the following:
Create a new Windows Phone HTML5 App Project
Copy my WOFF font (though I've also tried eot and ttf) to the project root, and add it to the project as an existing item
Add in this CSS to the index.html file
If anyone could create a template Windows Phone 8 project with simple working local web fonts, I'd be super appreciative. This has got me really stuck.
Windows phone supports web fonts. However, if they are embedded on the XAP they will not work.
Engineering response:
This is a known issue, the only workaround we know is to host the fonts on a remote server (making sure to bypass the single origin policy issue) and perhaps use AppCache to keep the font files locally on the device.
Thanks,
Apparently this is a known issue, and as a workaround, you need to host the fonts in a remote server until this issue is resolved by Microsoft.
I have been able to use local truetype web fonts in Windows Phone 8 HTML apps with no problems. You must ensure that the embeddable flag within the the font is set to 0 using software such as TTFEdit.
Check out the full answer I gave to a similar stackoverflow question here.
I think this might be better than the accepted answer but I'm a n00b so I can't add a comment to that yet.
I have searched and found the following post. May be it is related.
Phonegap Windows Phone 7 Dynamic HTML loading and cross-domain calls using jQuery
"If Cordova is not initialized (i.e the device ready has not fired), the browser control treats it like a remote get and lands you in to the usual Cross-Origin issue and rejects" This is probably the case for CSS. May be you can try loading CSS dynamically after deviceready event and see what happen.
NB: Same answer I posted there Phonegap/Cordova web-fonts with Windows Phone 8
I have just noticed in this video. http://channel9.msdn.com/Blogs/Interoperability/Getting-started-with-Windows-Phone-8-and-Cordova At around 4:12, it mentions the build action has to be set to "content" in order for the file to be seen. Not sure if that helps anything, since we already have a report about a bug. :p But I hope it worth sharing anyway. :)
I solved this problem using Cufon http://cufon.shoqolate.com/.
Cufon renders images instead of text, so that is the reason why this works on Windows Phone.
Here is documentation and usage: https://github.com/sorccu/cufon/wiki.
I hope this helps.
It looks like if you encode the font in base64 and put it directly in the css file, than it works in WP8 app as well.
With web apps like Icomoon or Fontsquirrel you can easily generate the css containing the base64 string.

How to save a web page snapshot with all its elements (css, js, images, ...) into one file

How is it possible to programmatically save a web page snapshot with all its elements (css, js, images, ...) into one file?
I need to archive some web pages regularly. However, just saving their HTML code is useless - not only because of images missing but esp. because the absence of CSS on today's pages can turn a web page into unrecognizable mess.
I remember the .mht format that worked like this, but that required manual saving, and it was just a feature of IE. I believe there is an open-source solution that can achieve this programmatically, but despite hours of searching I cannot find it on the web.
HTTrack, -%M
Use wget in terminal
wget -p -k http://www.example.com/
It'll make a clone of site frontend html, css, js, svg etc. But not in one file as asked. Rather, it'll recreate the whole folder structure
E.g. if folder structure of www.example.com is as
/css/*
/js/*
/index.html
then it'll create the same structure locally.
Docs: https://www.gnu.org/software/wget/manual/wget.html
I think #reisio (+1) has you covered...
...But if only to plug a great free tool, I would point out the Firefox extension Save Complete, which does an admirable job of grabbing "complete" pages on an ad hoc basis. The output will be a single HTML file with an accompanying directory stuffed with all the resources - you can easily zip them up for archiving.
It's not without fault - I've had issues with corrupted .png files lately on OSX, but I use it frequently for building mockups off of live pages and it's a huge time-saver. (Also of note, it hasn't been updated for FF 4 yet, and is the sole reason I rolled back to 3.6)
If you are using Google Chrome just use the save page as menu entry (CTRL + s), and select complete website from the options at the bottom of the file dialog. This save the HTML and all required resources (in a separate folder).
Apple's Safari has a pretty good solution. It saves all HTML and CSS (sadly no JS) but in a format called webarchive. It's one file, but it requires Safari to save and open, and Safari requires a Mac. Even though Safari for Windows does exist, it's too old to work with webpages, and it doesn't even support saving as webarchive, or opening them. If you have a Mac, open any website in Safari and press ⌘S and then make sure that Web Archive appears in the drop down.
There is also a Chrome extension that can open these types of files, but not save them.
Apologies for replying to such an old thread, just wanted to spread this info!

Categories

Resources