I am developing a web-based POS. Unfortunately, POS must print through a thermal receipt printer (TM-T88IV, Epson). The web application is based on Django. Is there any idea on how the system could automatically print a receipt whenever a user clicks a control in the web application?
I was thinking of creating other services in python for that purpose, but that would defeat the purpose of having a web application, where all you need is a browser, without any extra installation.
The printer is connected to the client by the way, and the printing should be "silently" triggered, which means that there is no need for human intervention. Once the transaction is finalized, the printing should starts.
Any suggestion is welcomed!
I see two ways to accomplish it:
First method - Configure your browser
Notes
Good solution if you have one printer for every client (because you can use the default printer only). Keep in mind that you can remove your print server (useful for very resource limited devices) making a script that the browser should automatically execute for open your file. You can use something like this:
#!/bin/bash
printer="/dev/usb/lp0"
encoding_needed=true #false
if $encoding_needed; then
iconv -c -t 437 $1 > $printer
else
cat $1 > $printer
fi
Firefox
Manual setup:
Open about:config
Create a new boolean value called print.always_print_silent and set it to True
Create a new boolean value called print.show_print_progress and set it to False
Use an extension, like: https://addons.mozilla.org/en-us/firefox/addon/attendprint/
Keep in mind that there are other extensions for making kiosks, for example:
https://addons.mozilla.org/en-us/firefox/addon/r-kiosk/
https://addons.mozilla.org/en-us/firefox/addon/mkiosk/
Chrome
You can start it with those options: --kiosk --kiosk-printing
Internet Explorer
For kiosk mode see: http://support.microsoft.com/kb/154780
Second method - Server handles every printer
Notes
Good solution if:
You have more clients than printers (few money or faulty printers)
More printers than clients (different printers or paper colors for different needs)
Clients that can't print directly (PDA/smartphones)
You want to know the printer status
How to do
Connect printers (to the clients and/or to the server)
Share printers connected to clients over the network
Manage every printer from your Django server
Two options here: print an html page or provide a PDF file.
Note: it was not clear initially that prints should be automatic, which means the answer is not directly useful to OP.
HTML + "Print Me"
Show the receipt as an html page, then create a media="print" CSS stylesheet which the browser will use when printing the receipt. There's a lot to say about CSS print style sheets, but what's important is that you should remove all navigation elements and images that are going to be expensive to print.
When you do this, the user will simply have to print the page himself. You can also add a "Print Me" button which is going to show your user a printer dialog. This is done via JavaScript:
Print this page
(This is a bit obstrusive for your clients who don't have JS, check this tutorial about JS printing for a better way.)
PDF
Generate a PDF in Django, and show it to the user. He will be free to print it or save it on his computer later. Most web sites do this since it's far easier to control the layout of a PDF file, and it will be easier to make it look like a real receipt.
XSL-FO can help you do this (it translates an XML to a PDF with a "stylesheet").
A more Pythonic way seems to be explained in the Django docs
The above pages lists alternatives such as xhtml2pdf (Pisa) which seems to be used a lot on StackOverflow
If using raw/esc/p try jzebra on google code.
Related
I working on website for ticketing system where admins need to print tickets via Boca printer. Problem is that Boca use FGL (Friendly Ghost Language) which is a standard in ticket printing.
Is there some kind "secret" where I can be connected, some javascript, or PHP code with some BASH script what I can use to trigger prnting from web page?
Generaly I have a template in HTML format where I put user informations and barcode dynamicly and that need to be printed.
Thanks.
If your Boca is connected via a serial port you would have to resort to some underlaying mechanism to communicate to this serial port from a webpage; node-serial (or a java applet if you're into obsolete technologies) would be a solution.
The programming manual is available here for printing a simple text and cut the ticket you would pass the following command:
Hello World<p>
(replace <p> by <q> if you don't want it to cut the ticket)
If your Boca is connected via USB you can print on it via the supplied driver. A solution would be to generate a PDF with the correct ticket's dimensions and then print it out (the user would see the OS print dialog).
I have developed a token dispensing system (web based POS) with key component being a kiosk screen with angularjs on the client side and Java/Springs on the server side. The kiosk setup would be a normal (Win OS) Google Chrome browser window running on full screen mode, fitted with a thermal printer to print token slip.
The kiosk will dispense a token slip when the user clicks on a button (say 'Get Token') on the screen. The slip will contain a token number, a barcode and other miscellaneous info (like timestamp and kiosk id). The barcode has to be generated from the data I get from server side API call.
What I am looking for is a solution to silently (without print preview) print a token slip on the thermal printer connected to the client (kiosk) when the user clicks on a button on the kiosk screen.
Creating an iframe on-the-fly or binding values to a pre-defined html template is not helping since the data to be printed is not just plain text. It also has the barcode.
Any help would be much appreciated!!!
I haven't try completed solution as your demand, but you can try 2 separate steps below:
From server side API, you should generate an PDF for exactly
expectation print version as you want (mPDF is my best
recommendation) .
Disable print preview mode in google chrome with start up parameter "disable-print-preview"
(make your own shortcut at the desktop to run Chrome without print
preview mode. Then using javascript to do the print like you did
with iframe or new window.
PS: a good tip for a shortcut from techlogon: http://techlogon.com/2012/03/29/how-to-disable-print-preview-in-chrome/
I’ve been assigned a task, one which I’ve never done before, to generate a resume using data from our online job application web site, which a user client can display as a web page and then save to their local system in one of two formats, MS Word or PDF. The resume web page is a fixed layout which contains the clients contact information, education, work history and other relevant stuff. I already have a JavaScript plug-in for generating a PDF file on the client side, I’m now looking for a solution to create the MS word document on the client side and save either one to the client file system. The resume page is a single page with a fixed layout, customized only by data stored in the system for the user.
To see other details on the web applications follow this link: Express Professionals
Here are some of the more important requirements I have to take into consideration:
We are a Microsoft shop and use 3rd party solutions which adhere to those standards.
Windows Server 2012 R2 and IIS 8.5 - Forms Authentication - SQL Server 2012 backend
MVC4 internet application with Razor web pages
Bootstrap 3.0, JQuery 1.11, JQuery UI 1.8.24, OData 5.2
The application must be responsive from desktop to hand held devices
Target client browsers are IE 9.0 and up, Chrome 42.0 and up, Safari for MAC 8.0.6 and up - No commercial or 3rd party paid libraries or paid plug-ins. If I can’t find a free solution; I need to invent my own
No popup windows or other web pages to collect user input on where to store the finished document on the client machine
A single button click, one for PDF and one for MS Word, will take the Html resume page displayed, convert it, then save it, to the client’s machine in the chosen format, then launch the client app and load the document
The user can then decided where they want to save the file
If the resume page can’t be converted to the native client application file format, it can be saved to the file system in the next best compatible file format which the client application can read
Saving the converted file is OK, but it is preferred to launch the client application and load the converted file on the client machine as part of a complete process
SharePoint services or SharePoint Server are not available for use in solving this problem.
As I stated, I have found a JavaScript plug-in for creating the PDF, but for the MS Word document, I have only found bits and pieces which are unrelated, nothing in part or as a whole, which can be cobbled together into a working solution using our development stack.
Any references or links that match the requirements or suggestions which get me closer to an end solution are welcomed.
Thanks in advance….
After evaluating several open source solutions, the final choice was OpenXML for MS Word conversions. An MS Word template was created with the basic framework and then the OpenXML utility was used to create the class that builds the word doc. That class was customized to allow a data source to be added to the constructors and data added to tables in the document. DevExpress was used for the PDF conversions, since I don't know this tool the last part was handed off to another developer.
I have a web app (sencha/phonegap) that includes a feature allowing users to click on buttons that link to Wikipedia articles. This obviously works fine if the device has internet access, but I get numerous requests to make the app work when the app is offline too. To accomplish this, I'd like to give the user the option to download the linked articles/webpages for offline access. When the device does not have internet access, the app would instead display the saved version (which might be stale/out-of-date, but is better than nothing). What are possible ways to accomplish this task?
My first thought was to somehow use the html manifest to cache the pages in the phone's browser, which sounds possible on the Android browser, but iOS apparently has a 5MB browser cache limit - too small.
My next thought was to save the needed html & associated files and bundle them up inside the app. But this seems a rather cumbersome approach, the app becomes much larger than it needs to be, and the webpages are stale back to the date the app was installed.
Using javascript, is it possible to download webpages, which I could then save (on the sd card, for example) for access later?
Or is there a more elegant approach?
If anyone could point me in the right direction it would be much appreciated.
In pure Javascript you can make an Ajax request to download a page. Then you can use the FileWriter to write the responseText to a file on the file system. However, that won't help you when it comes to images. You'll need to use the FileTransfer.download() command to get the binary image files.
If I were you I'd:
Use AJAX to download the html.
Parse the html looking for images.
Use FileTransfer.download to get the images.
I'm building a web application that is primarily ASP.NET MVC / Javascript. The application needs to be able to print certain content to a label printer and other content to a standard printer. I'd prefer for the user to be able to select a default printer for each one rather than having to always explicitly select a printer.
Is there a way to save and reload some sort of default printer settings for multiple printers in such an application. I am also open to using Silverlight for the p;rinting features if there is no way to do it via javascript.
Not via JavaScript, no; JS uses the browser's built-in print mechanism, which in turn defers to the OS's default print mechanism.
I know its been 6 years since this question was posted but since it wasn't answered here is what I believe is the best way to solve this issue.
You still cannot manipulate printers from a web browser, but there is a great choice out there called QZ Tray
You have to install a program that will communicate between javascript from your application and your configured printers, allowing you to send RAW printing commands and also HTML to any printer.
You can also print to multiple printers at once and save all printer configuration and parameters inside your web app, so you have full control over your printers.
Browsers do not allow javascript (or any script) to access information about the available set of printers or offer any means to select even a "prefered" printer.
Simliarly Silverlight does not support access to infomation about the set of printers available and does not allow printing API to select a specific printer to.