Front-end calls the printer to print bar codes, two-dimensional code (some of the pits)

1, first need to install the computer control TSCActiveX; TSCActiveX.dll, TSCLIB.dll tray into the system (32 and 64); regsvr32 used to register;

2, install the printer driver; (many online)

3, ActiveX controls only support IE browser; and to set your browser to enable Activex (default is off), otherwise it will be reported AutoMation error;

4, the code that implements the function of the two-dimensional code printing, bar code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript">function TestFun() {var TSCObj = new ActiveXObject("TSCActiveX.TSCLIB");
            TSCObj.ActiveXopenport("TSC TTP-244 Pro");
            TSCObj.ActiveXsetup("70", "40", "4", "15","0", "2.5", "0"); //printer settings//

        
            
            
            TSCObj.ActiveXsetup ( "tab width", "height label", "printing speed", "printing concentration (0-15)", "category string type sensor, 0 indicates vertical spacing sensor (gap sensor), 1 shows a sensor using a black mark (black mark senso) "," Gap / black mark vertical spacing (mm) "," Gap / black mark the offset distance (mm) "); 
            TSCObj.ActiveXsendcommand (" DIRECTION 1 ") ; // set the label orientation, dIRECTION 1 top left corner (x, y) = {0,0 }; dIRECTION 0 lower right corner (X, Y) = {0,0}; 
            TSCObj.ActiveXsendcommand ( "the sET TEAR the ON" ); 
            TSCObj.ActiveXclearbuffer (); 
            // TSCObj.ActiveXsendcommand ( "PUTPCX 0,0, \" 123.PCX \ ""); 
            / * 
            . 1, using the machine built-in encoder ActiveXprinterfont commonly used to play English. 
            2, ActiveXwindowsfont can output Chinese characters, but must be present in the system font. 
            TSCObj.ActiveXprinterfont ( "a",
            b: string, starting text in the Y direction, in dot notation. 
            d: integer type, rotation angle, rotates counterclockwise. 0- rotation of 0 °, 90- rotation of 90 °, rotation of 180 ° 180-, 270- rotation of 270 °.
            c: the name of the built-in fonts, a total of 12 kinds of (1: 8 * 12 dots 2 : 12 * 20 dots 3: 16 * 24 dots 4: 24 * 32 dots 5: 32 * 48 dots TST24.BF2: 24 * Traditional Chinese 24 TST16.BF2: Traditional Chinese 16 * 16 TTT24.BF2: Traditional Chinese 24 * 24 (telecommunications code) TSS24.BF2: Simplified Chinese 24 * 24 TSS16.BF2: Simplified Chinese 16 * 16 K: Korean 24 * 24 L: Korean 16 * 16) 
            D: string, rotation angle 
            e: string, X direction magnification 1-8 
            F: string, Y direction magnification 1-8 
            G: string, print 
            ActiveXwindowsfont (a, b, c, d, e, f, g, h) 
            Description: Windows TTF fonts used to print text. 
            Parameters: 
            A: integer type, the X-direction starting character, point Fig. 
            b: integer type, the Y-direction starting point of the text, in dot notation. 
            c: integer type, font height, in points indicate. 
            e: integer type, the font outline. 0: Tags; 1: italic; 2: bold; 3: bold italic. 
            f: integer type, underline, 0: no underline; 1: underlined. 
            g: string type, font name. Such as: Arial, Times new Roman.
            h: string type, print text. 
            * / 
            // TSCObj.ActiveXwindowsfont (500, 200 is, 48, 90, 0, 0, "Arial", "\ u7f16 \ u7801"); 
            TSCObj.ActiveXwindowsfont (50,50,40,0,2,0, "Arial "" product name: Apple " );
             // TSCObj.ActiveXwindowsfont (50,120,40,0,2,0," Arial "," product Code: 12,345,678,907,456 "); 
            TSCObj.ActiveXbarcode (" 100 "," 195 ", "128", "95", "2", "0", "3", "2", 12,345,678,907,456); // barcode 
            // starting point var cmd = 'QRCODE barcode X direction, the Y-direction starting point of the bar code, correct wrong level, two-dimensional code height, A (A and M), the rotation angle, M2 (divided into type 1 and type 2), S1 (s1-s8 , default s7), \ "1231 hello 2,421,341,325,454,353 \" '; 
            var= cmd 'QRCODE 80,80, H,. 7, A, 0, M2, Sl, \ "' +" 123456789 "+ '\"' ; 
            TSCObj.ActiveXsendcommand (cmd); // 
            TSCObj.ActiveXprintlabel ( ". 1", "1"); // (number of copies, number of printed sheets per) 
            TSCObj.ActiveXclearbuffer (); // Clear 
            TSCObj.ActiveXcloseport (); // close the print port 
        }
     </ Script> 
</ head> 

<body> 
    <button onclick = 'TestFun () '> test </ Button> 
</ body> 

</ HTML>

 

Guess you like

Origin www.cnblogs.com/Apsey/p/11865523.html