Phantomjs - render text as images on Ubuntu Server - html

I use phantomjs and html to pdf node package. On local env (MacOS) everything is ok. When I use the same app on Ubuntu Server (16.04), phantomjs generates PDF with images instead of text (on image per page).
I was looking for info and found that it can be caused by external resources - yes, I used additional custom font in my styles. But after changing to local (file:/// and base in render options) problem still occurs. Don't sure why it's platform-depended issue.

Solution: install fonts locally on server (on /usr/share/fonts and /usr/local/share/fonts/). After that, Phantom can use them without any issues.

Related

Is transcrypt supposed to run from the local filesystem?

I've installed Transcrypt, compiled the Hello Solar System demo, and run it as instructed using the python web server.
However, I was also able to run the hello.html file directly from Chrome on Windows 10 ... once. Subsequently it refuses to run - the buttons appear but clicking them does not update the text.
------- EDIT ---------
Thanks - CORS is the problem - the browser must connect to a web server, not a file on the local filesystem.
You've probably run into a security policy of Chrome called CORS. Start a webserver from the directory where your html file is, using python -m http.server, and browse to localhost:8000. In your browser window, click on the html file and things should work.

Auto refresh wepage when source file changed

I have been learning web development for some time and I have noticed on tutorials on youtube that when someone change source file (html, css, js) the webpage opened in browser is automatically refreshing. I have read something about live-reload but it's too complicated for me and there is no step by step tutorial.
I have found some similar questions, but the case is that refreshing happens by side of local server not the code editor or browser as is mentioned in questions that I found.
I'm using Apache as my local server. Sublime Text for writing a code and Ubuntu operating system.
Here is the video that shows what I am exactly trying to say.
https://www.youtube.com/watch?v=q78u9lBXvj0
Npm and live-server doesn't work on my computer at all.
Sorry for my english, but I'm not a native speaker. I'm looking forward for your help.
Anyone knows anything?
Install sublime web server using package manager ( or in your case continue to use Apache )
Use http://livejs.com/

Chrome allow file access from files no longer working (was using to see WebGL/three.js files)?

I was using a Chrome shortcut with allow-file-access-from-files in the target to work on my three.js student project files. But sometime this morning this stopped working and it appeared Chrome had been updated. I redid the shortcut but no joy.
Part of the project I'm doing is building three.js animation that works in a common browser (for which I chose Chrome).
Is there any way to get Chrome to allow file access again?
Thanks.
The answer I came up with was to use Firefox instead of Chrome changing the security policy as detailed in https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally
Not a perfect answer but with a deadline looming it's the best workable answer for me right now as trying different variations of Chrome, trying Wamp and also Mongoose didn't work. If I had more time I would work out how to use Python or probably node.js as I've seen it mentioned a number of times as being the faster option.
What gman stated is true, using the Chrome flag (and changing Firefox's security policy) does create a big security risk. But only if you use that shortcut (and it's tabs etc.) for anything other than accessing your own local files. I've been scrupulous about not using it for the internet but don't use this method if you can't be strict with yourself.
Ideally I'd recommend beginning any project with node.js.
Gman's answer is good. If you're in windows environment, and use npm for package management the easiest is to install http-server globally:
npm install -g http-server
Then simply run http-server in any of your project directories:
Eg. d:\my_project> http-server
Starting up http-server, serving ./
Available on:
http:169.254.116.232:8080
http:192.168.88.1:8080
http:192.168.0.7:8080
http:127.0.0.1:8080
Hit CTRL-C to stop the server
Easy, and no security risk of accidentally leaving your browser open vulnerable.
DON'T USE THAT FLAG! You're opening yourself to having your online accounts being hacked and your local data stolen. Here are 2 proof of concept examples
Run a simple server.
It's super simple.
Here's one
Here's one.
Here's another.
And another.
They won't take more than a couple of minutes to download and require no configuration

How to allow download of files on a HTML server?

I have setup a HTML Server to run on Windows Server 2012. I have added few virtual directories and some files.
I am trying to download a file firmware.dob. But when I click on the file the browser reports "File not found"
404 - File or directory not found.
As an admin, how do i enable users/make the browser to download file rather that try to open it?
This should be done by PHP. If you have just HTML i don't think this can be solved. In PHP you could set a Header. Perhaps you can use your admin tools of your server to set some properties of the file you're talking about. maybe the server gives you the option to force download prompts.
If you can only use HTML you might consider using a flash plugin for this. But this would only work on desktops, not on mobile phones. You could look into this: Creating download prompt using purely javascript

Can I build a "JavaScript Mode" version of a Processing sketch using the command line?

I'm using the "b-g" Processing build system for Sublime Text 2 (link) which works perfectly fine.
It's using the following command to initiate the build via the processing-java executable (I'm on Windows btw):
"cmd": ["processing-java", "--sketch=$file_path", "--output=$file_path/build-tmp", "--run", "--force"]
This will open the Processing application in a Java Environment.
Since I am targeting mobile devices I'd like to use JavaScript Mode though (the Processing IDE will fire up a server listening to some strange port serving a web page that you can access using any browser when exporting a sketch that way).
As I would like to avoid having to use the Processing Editor (usage of "foreign" editors has apparently been disabled in v2) I was wondering if I could trigger that behavior via my build system / the CLI?
Unfortunately I cannot find any information on that at all on the web and $ processing-java --help doesn't mention export modes as well.
No, but you can concatenate your .pde files into one source file, and then run that through the "processing-helper" for processing.js. If you clone the Processing.js repo (links on https://github.com/processing-js/processing-js) then you can load the ./tools/processing-helper.html in a browser (ideally from localhost, not file), and then just paste in your code, hit "convert", and out comes the compiled JS source.
That said, there's not all that much benefit to precompiling, since Processing.js is a browser technology. It's not "an editor", a sketch running using Processing.js is just a webpage, and all mobile devices support web pages.