How can I send a paper cut command using my web app? - html

I have a web app that prints out several receipts. I need to cut every consecutive receipt that follows. Is there a way somehow to embed the paper cut command in my HTML template?
Like a <br>
Thanks.
UPDATE : ESC/POS Commands to cut paper
SUGGESTED SOLUTIONS :
Convert a byte array (printer commands) to string and send it with the window.open(urlString).
After some research i found the jZebra applet. This will work for me! I can now
send printer commands from browser to physical thermal printer on network address.
http://code.google.com/p/jzebra/

After some research i found the jZebra applet. This will work for me! I can now send printer commands from browser to physical thermal printer on network address. http://code.google.com/p/jzebra/

Related

Printing HTML on specific printer with Golang

I am developing a desktop app and I want to print HTML on a physical printer of my choosing on Windows and Linux.
It shouldn't ask the user to choose a printer as I want it to be automated without user input.
Is it possible with pure go and without executing external binaries?
If not which binaries do I need for windows and which for linux?
I found a way that works by using chrome command line flags. Namely --kiosk-printing and --headless and --user-data-dir so a new instance is spawned.
The Javascript necessary is:
window.print();
setTimeout(function() {
var ww = window.open(window.location, '_self');
ww.close();
}, 1250);
The timeout is necessary because chrome's print() doesn't block so we need to wait until it was actually printed.
This way I can print silently without asking the user and this works with Windows and Linux.
However I can't find a way to choose the printer that's used.

How to download a text typed into the codepath using linux tools?

I have a link to the online text editor coderpath: https://coderpad.io/MY_ID:
Users with access to the link can type the text there and the text one user types will become visible to all users on the network (similar to Google Docs).
I would like to periodically download the latest text that is typed there using the linux shell, but a simple command
wget "https://coderpad.io/MY_ID" -O text.txt
downloads some HTML file that does not contain the text I typed.
Since my browser displays the text on my screen, I assume that the browser has downloaded it from the web and thus there should be a way to download it again and save it into my own text file. How?
The reason your wget "https://coderpad.io/MY_ID" -O text.txt command does not download the code you typed into the coderpad is because the command is actually downloading a different content depicted in the image below:
Delete the cookies of your current session or type https://coderpad.io/MY_ID into a new browser and you will also see this image rather than the expected code.
Once you enter the requested name into the page and click Go, a few steps later the browser stores new cookies for this webpage. The main cookie related to this question is:
Cookie name | Cokie value example | Explanation
pad_7JJWMNDA_username | Grace Hopper | Name entered into the bar
For the next requests to refresh the page, the browser will send an HTTP request to the website with this cookie embedded. By examining the cookie value, the server will decide to return the expected code rather than the "Enter your name" request.
In theory, adding appropriate cookie values as extra arguments to the wget command should make the server return the expected code. I did not succeed to download the code this way, because of the multiple hidden requests and responses exchanged between the browser and the server. Those hidden requests complicate the whole download procedure.
However, a workaround that works for me is the following:
Download auto HAR extension from https://github.com/Aloisius/autohar. HAR is basically the log of your browser tab activity with content included.
Change max_entries: 100 to max_entries: 1 in all files. This tells to download the HAR after each page refresh (rather than after 100 page refreshes).
Install this modified extension into the Chrome browser.
Open the new tab and open developer tools for that tab by clicking CTRL + SHIFT + I.
Now whenever you refresh the page in this particular tab, HAR file will be downloaded to your ~/Downloads folder.
That HAR file will contain the custom code of interest. You can then use grep
to extract only the code of interest and filter out the rest of the log.

NetSuite SuiteScript 2.0 Integration with external hook

I need to setup EPL2 label printing from Netsuite. Unfortunately the company this is for is very small and they don't have much money to spend, hence they cannot buy a $1000 label printing solution.
The current system uses a linux server that then sends a file to one of the CUPS print server queues using the linux cat command. From there it goes to a Intel NetportExpress 10/100 Print Server and then to the Argox V1000+ label printer. This is via a corporate network ip address.
Instead I started looking at some cheap options:
Popup a browser window with content type text/plain and use a suitelet to populate that browser window with the EPL2 label printer codes. Then open a print dialog window so that the user can print to the label printer driver. This requires installation of the label printer driver for all users. Sadly I could not get this to print a label.
Integration from Netsuite via a Restlet to an external python application (on Linux) that can then perform the linux cat command needed to print the label. The Restlet works nice, but unfortunately there does not seem to be a way to have some sort of hook that fires when a new label custom record arrives. Therefore I have to keep on polling the Restlet from Python every 2 seconds to see if a new label is waiting to be printed. I started running this about an hour ago and so far I have made about 2500 requests without errors. My concurrency limit is 5 and I'm using 2 so that seems ok. The script does very little so I don't think there will be size limit issues. The problem is just that I wonder whether NetSuite will eventually terminate my script for doing so many requests. Not sure whether there is such a governance issue, but can't imagine that they won't eventually stop that sort of thing.
Use the http module to send data in an ajax type manner. This should be able to pickup when new data arrives instead of having to poll (not sure). The problem with this is that I assume I will need a static IP address which is sadly an expensive option.
Use Netsuite SOAP web services which might have a hook instead of polling (not sure). I think this would not be free (like Restlets) either.
So my question is whether there is a better option that I'm missing or what would you recommend. Also would I hit some sort of governance limit if I poll every 2 seconds with option 2?
Update: The polling mysteriously stopped working after 7395 requests and about 3 hours. It did not return an error that I'm aware of. The rejected requests on Integration Governance shows 0.
I used to do the emailing thing quite a bit and it works pretty well. Volume may be an issue.
Another thing to do is just get a static IP address with something like ngrok.
ngrok runs on linux/mac/windows so you'd be able to write an app that listens on a particular port. Netsuite would send an https post to that app at (for instance) https://printing.mycompany.ngrok.io and the app would handle local printing.
I believe ngrok runs about $US60/year.
the app can verify identity with some sort of timestamp and hash so that if someone does get the https address they couldn't easily use all your paper or cause a DoS situation.
We got bamboozled by a printer vender (Zebra) before we found out that we could HTTP post to most printers using PRINTER_IP:9100 and just sending the RAW ZPL/EPL as the body.
Look into: IPP enabled printers. most are these days. saves you 1000's in longrun if you have a large warehouse operation like we do
Instead of polling I would have NetSuite initiate the connection in an afterSubmit User Event script.
I've automated label printing by having NetSuite email attachments to a dedicated mail box which is monitored by a Linux server. My setup is documented here:
https://gist.github.com/michoelchaikin/80af08856144d340b335d69aa383dbe7

html scan image from scanner on a web page and save the image to local folder or back to page

Printer type hp officejet pro 6830
Is there a way to scan from html/java script image from a scanner ?
If it cant be done can anyone recommend a lib for java that give access to the printer/scanner.
The over all idea is to add a button to web page and scan image back to the page or to a local folder
I already tried using Scanner.js: HTML/JavaScript Web Twain WIA
but it didnt work for me not sure why?
thanks
This can kinda be done.
Before starting I must specify that I'm trying this on my HP PhotoSmart network printer, but it should apply to yours as well.
If from your browser you surf to your printer IP address (I suppose you're using it as a network printer, ie. http://192.168.1.79), you should find a couple of options and the ability to scan documents from the web browser itself (you might have to enable this function first from the settings).
It works and you could spend hours reverse-engineering that things. Luckly, it seems someone has already done that: hp-webscan and it's only ~60 lines so it's easy to convert to another environment/language.
Otherwise HP printers should expose a CUPS (IPP) / SANE interface and you could use that.
SANE (Scanner Access Now Easy) is a set of API to communicate with scanners across a network. I gave you the link to the Wikipedia page describing the technology. Here's an example of binding for Node: node-sane.
Python Flask service, which can be called from javascript to start scanner, and get the scanned image as pdf. This python code will allow you to use image scanner from a web page. An example for a web page "client_page.html".
You can edit the code so it will return an image :
https://github.com/KHBillel/ImageScanner4Web

How to get change in HTML DOM in LabVIEW?

I am doing IOT related project in Labview using Arudino as hardware.
I was able switch off/on an led on Arudino by Pressing OFF/ON on website by using datasocket vi. Now what i want is to control the intensity of led from Website.
I have a range slider in my website and its real time value can be viewed in textarea,div,input type.
Is there any way i can get that real time value that is being changed in HTML DOM in Labview.
I know that datasocket vi returns the html source code but not the HTML DOM.
I dont want to use the Web Publishing Services as they dont work in my Laptop.
This is the link im referring for datasocket.
Datasocket Labview
You can do something like creating a web socket, but I expect the easiest thing is to use a web service. You can create one in LV and add a setLEDIntensity method to it and call it from your JS code. You can find a simple example here and in other documents in that community.
Use WebSocket API for LabVIEW to send and receive data from the web. This is the best option for you.
https://decibel.ni.com/content/docs/DOC-40572