PHP & JavaScript select and setup printers - javascript

Take a look on the screenshot above, it's an Windows based app. I was wondering if this possible to done in PHP & JavaScript?
What I want to achieve is, user in module 1, will automatically select printer #1 and print it directly without display the print dialog. For module 2 will use printer #2.
I know this may sounds impossible due to security issue. But just share to me any possible solution that you know. Thank in advanced.
UPDATE: Feb 18, 2016 17:40
The module that I mention will actually generate a PDF file, I not sure if this matter.

Finally I have figured out the solution.
I create a C# Windows Form application as a wrapper, by using CefSharp, then I load the web app inside
From the Windows app, I can get the installed printers, and inject the list via JavaScript to the browser. Then it can be saved.
For my case, I need to print out the downloaded pdf file directly, thus I use Foxit to print it out. (by running batch script in C# app)
I have blog it down, refer here

Related

Bluebeam or Adobe SaveAs via Submit button using JS

I am trying to see if anyone knows of a workaround to do a save-as using a submit button within a PDF. I have a working version using Trusted functions in Adobe, but for our needs would like to avoid having our end-users from placing .js files in the trusted location on their machines.
The reason I am trying to do a save-as is to simply rename the output file with the date and username and place the files in a centralized location for data collection.
We are aware of using Adobe to distribute and receive responses from end-users... but as mentioned above we are using both platforms, and also have some DirectX issues.
I have also created the same Form in Microsoft Forms and I personally feel like this may be our best option in rolling this out, but before we wrote anything off, I figured I would try and see if there are any other options using JS and PDF's.

Is there any way to edit a local file through a web page without running server software?

I've a web working on a web page that's basically just a big table of links. I use javascript to read from a text file, parse it, and create a table based on that.
I'd like to be able to have a button on the page to add new a row of links and add them to the text file (or another file type if it's better).
I know you can accomplish this with php, node.js, and others, but all the methods I've found require server software to be running. Is there any way around this? For example, is there a way to use javascript to call a python script, or any other way?
The page is just for personal use, so I'd like to avoid running server software just to use it if possible. I know you can set it to download a text file, and you can save it in the same location, but I'd also like to avoid that.
From the research I've done, it doesn't seem possible, but I just thought I'd ask before I give up. Thanks in advance.
You can only read from files locally in browser with javascript.
This would be a huge security vulnerability if scripts in browsers could write files to your machine.

Not Updating javascript file

I am working on ASP.NET MVC4 Project. When i am updating JavaScript file and run my project in browsers. New changes do not reflected on page Same thing happen when I am trying on IIS Server. For that every time I have to remove browser history then it reflects but this is not correct way after deployment
Is there any other way for that?
Please guide me Thanks in advance
Your problem would be:
Browser Caching JavaScript
Check whether the browser is caching the javascript. To do it, check the header of the javascript on the browser for the attribute Cache-Control in the browser. Case yes, configure Cache-Control to no-cache on the project. Disable cache only in your development environment.
Visual Studio or IIS not reloading the javascripts
Check whether the Visual Studio or IIS are reloading your entire project after the deploy.
Suggestions to solve your problem:
Solutions to solve this problem is version the javascript.
Using different names
One way to ensure that the user will receive a fresh version of javascript is versioning the filename.
Instead of use only the name, you can concatenate a version number to the javascript.
Example:
www.example.com/script.8238823.js
www.example.com/script.3434342.js
This urls represent different paths and the browser will update.
Using query string
Another way is use a query string such v= + version.
The version can be a MD5 hash, or the timestamps or the size in bytes of the file.
Example:
www.example.com/script.js?v=999990
www.example.com/script.js?v=129
This force the browser to cache the file, and reload when the version of v, change.
I don't use ASP.NET, but I think that exists solutions for this.
I saw similar answers here which I think would help you. Specifically, the suggestion of adding a query parameter to the end of the URL which references your JavaScript file, so you can "version" them.
Not sure if this is the same problem. For my ASP.NET MVC4 project I had an Azure database and web app. The reason the javascript file was not updating was because the connection to the database had lapsed. Refreshing in Server Explorer solved the issue / reestablishing the connection with a new login fixed the issue.
Also make sure the way you are publishing has the correct database admin login and connection.
Are you using the MVC Bundle? By using bundle and js inclusion as #Scripts.Render("file name used in the bundle config file") should not sustain cache.

Rendering HTML local file with out browser or networking (lightweight)

I have had a lot of trouble trying to find information or possible examples of this being done.
I would like to render html in a window and take the js from the html and output that to a python code.
The Html is local and there will never be an internet connection for it to run off. Everythin i try shearch for possible answers everyone always seems to relate back to using some small lightweigh browser which in my case isn't an option to use.
Fort some more detail, I am running Selenium-Webdriver
(python) and Iceweasel(Raspberry Pi B+) to get the value of a element from a html page. So using a different browser isnt possible as the lightweight ones are not compatible with selenium. Using Selenium and Iceweasel takes in excess of 2 miunets to fully load up which for what i need it for is far to long.
I had a look into Awesomium but i think it lacks compatability with the Raspberry Pi.
My other thought was to use OpenGL to render the html but found no easy explained examples.
Currently looking into LibRocket, Berkelium and QWebView but again i dont think they will have anythin i need with the compatability i need.
EDIT:
Basically i want a Canvas capeable of rendering HTML to a screen using X11. On the HTML there will be buttons. I want those buttons to preform actions inside a python script.
The way i see it, a browser is basically a toolbar, a canvas and a lot of networking. I want to strip away as much of that as possible and just remain with the canvas.
First go to the directory that you has the local webpage. Than run python -m SimpleHTTPServer 8000. This will "render the html" in a window. Then view source and paste the javascript into a python file. Alternatively if you would like to automate piping the javascript into an out file you can use beautiful soup to select the javascript and write it to any file you want. Then manipulate it in python however you want.

Load and parse URL via JS in the background

Currently I am trying to develop a little Firefox extension.
In detail: i want to display users from the site dota2lounge.com the current prize of their steam items on the steam community market. My idea was to do this via a Firefox extension which reads the item names from the HTML code on dota2lounge.com . Via JS i would like to search the steam community market for the item names and parse the current prize. This should happen without any further action from the user and without opening extra tabs/windows.
In java i would just load the site into a variable and work with it. How could i do this with JS (or Jquery)? Or maybe there is an even better way in the addon-sdk from firefox which could solve this issue.
Any thoughts and hints are welcome.
This should be pretty simple to do using the Add-on SDK. Here is a list of modules you should look at:
the request module will allow you to make requests to other sites: https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/request
while the request module is fine, what you may want to do instead to get info from the steam site is use the page-worker module to load the site and easily extract info from it using jQuery. This is much nicer than using regex. The code would look something like this gist:
https://gist.github.com/canuckistani/6c299c812bbe582d9efb

Categories