1, the use of the scene
The user prints a small ticket automatically after doing something in the browser.
2, test methods
2.1 JavaScript implementation
Tried a lot of ways, eventually will appear a pop-up box, let the user select the printer. Not in line with our needs.
2.2 Lodop
The function is more powerful, but the charge. No consideration.
2.3 Pazu
The function is also very powerful, free license. It's awesome!
Details: http://www.4fang.net/article/tech/pazu_tprinter.html
Implementation process:
2.3.1 Print Details page
2.3.2 Business Page
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
2.3.3 JS introduced
/** * Created by Hery on 2016/7/25. */function Initprintactivex () {var div_ = document.createelement (' div '); div_.style= "Display:none"; var object_=
Document.createelement (' object ');
Object_.setattribute ("ClassID", "clsid:af33188f-6656-4549-99a6-e394f0ce4ea4");
Object_.setattribute ("codebase", "Http://www.4Fang.net/4ff/sc_setup.exe");
Object_.setattribute ("id", "Pazu");
Object_.setattribute ("name", "Pazu");
var param_=document.createelement (' param ');
Param_.setattribute ("name", "License");
Param_.setattribute ("Value", "2ae816ba3a24a9ba3f01162e7bf420f4");
Object_.appendchild (PARAM_);
Div_.appendchild (object_);
document.getElementsByTagName ("Body") [0].appendchild (DIV_);
//Pre-selected paper var strdefaultpaper = ' A4 '; 1. Load printer and paper list function init () {listprinters ();//listpapers (),//2. Page load Print now//demo ();//List all printer function Listprinter S () {var ps = Pazu.
Tprinter.getprinters ();
is a string/alert (PS) separated by a carriage return newline;
var pa = ps.split ("\ r \ n"); for (var i = 0; i < pa.length i++) {//alert (pa[i]); var Op = document.createelement ("option");
Op.text = Pa[i];
Op.value = Pa[i]; try {printers.add (Op);} catch (ex) {alert (ex.message)}} function print (num) {/* Skip IE PRINT selector hint/////default printer's name is set to: GP-58120
Series var ispromtuser = false;
/* Page Settings * * var spaper = "A4";
var sprinter = Printers.value;
var sprinter = "GP-58120 Series"; Pazu. Tprinter.margintop = 1; Property Top Margin Pazu. Tprinter.marginbottom = 14; Pazu the bottom margin of the attribute. Tprinter.marginleft = 7; Property left Margin Pazu. Tprinter.marginright = 8; property to the right margin Pazu. Tprinter.footer = ""; Property Footer Pazu. Tprinter.header = ""; Property Header Pazu. Tprinter.orientation = 1; Property int: Paper Direction 1 = portrait 2 = Transverse Pazu. Tprinter.papername = Spaper; Property paper size name Pazu. Tprinter.printername = sprinter; The property printer name is Pazu. Tprinter.isprintbackground = false; Whether the property prints the background True/false Pazu. Tprinter.iszoomouttofit = true; property is scaled to fit the size of the print True/false//pazu. Tprinter.printtemplate = SPT; property to print the URL of the template Pazu. tprinter.copies = num; Property prints the number of copies//pazu. Tprinter.range = Range.value; Property Page Range Pazu. Tprinter.iscopybycopy = fAlse; Property whether the entire print is finished before printing the next copy of True/false//pazu. Tprinter.getdefaultprinter//method Gets the object//pazu of the default printer. Tprinter.printtodefaultprinter//method to transport the string to be printed to the default printer (with GetDefaultPrinter)//pazu. Tprinter.getpaperforms//method returns a list of all paper formats to vbCrLf split//pazu. Tprinter.getprinters//method returns a list of printers to vbCrLf split//pazu. Tprinter.createpaper//method to create a custom paper by the specified width and height see the example//pazu. Tprinter.doprint//method performs the print//pazu. Tprinter.doprint_//method performs printing but does not set the page parameter//pazu. Tprinter.dopreview//Method Print Preview//pazu. Tprinter.dopagesetup//method to perform page parameter setting//pazu. Tprinter.showpagesetup//Method Pop-up Page Setup window//pazu. Tprinter.writehtmltoofficefile method to export HTML to Office Excel or Word format files//To specify the frame to be printed just use JavaScript to get the focus on that frame. Note: This method is not previewed and can only be printed immediately.
Otherwise the preview sees the entire page, not the specified frame window.frames[' myifrm '].focus (); Pazu. Tprinter.dopreview ()//print preview Pazu.
Tprinter.doprint (Ispromtuser); } String.prototype.trim = function () {return this.replace (/^\s*) | (
\s*$)/g, ""); function Isnum (n) {if (isNaN (n)) return false;
The above is a small set to introduce a browser based automatic small ticket machine printing implementation scheme (JS version), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!