TSC Barcode Printer C # routines (Tsclib.dll call)

Source: Internet
Author: User

TSC Barcode Printer C # routines (Tsclib.dll call)

----Program.cs

Using System;
Using System.Collections.Generic;
Using System.Windows.Forms;

Using System.Runtime.InteropServices;
public class Tsclib_dll
{
[DllImport ("TSCLIB.dll", EntryPoint = "about")]
public static extern int is about ();

[DllImport ("TSCLIB.dll", EntryPoint = "Openport")]
public static extern int Openport (string printername);

[DllImport ("TSCLIB.dll", EntryPoint = "barcode")]
public static extern int barcode (string x, string y, String type,
string height, string readable, string rotation,
String narrow, string wide, string code);

[DllImport ("TSCLIB.dll", EntryPoint = "Clearbuffer")]
public static extern int Clearbuffer ();

[DllImport ("TSCLIB.dll", EntryPoint = "Closeport")]
public static extern int Closeport ();

[DllImport ("TSCLIB.dll", EntryPoint = "downloadpcx")]
public static extern int downloadpcx (string filename, string image_name);

[DllImport ("TSCLIB.dll", EntryPoint = "FormFeed")]
public static extern int formfeed ();

[DllImport ("TSCLIB.dll", EntryPoint = "Nobackfeed")]
public static extern int nobackfeed ();

[DllImport ("TSCLIB.dll", EntryPoint = "Printerfont")]
public static extern int Printerfont (string x, string y, String fonttype,
string rotation, String Xmul, String Ymul,
string text);

[DllImport ("TSCLIB.dll", EntryPoint = "Printlabel")]
public static extern int Printlabel (string set, string copy);

[DllImport ("TSCLIB.dll", EntryPoint = "SendCommand")]
public static extern int SendCommand (string printercommand);

[DllImport ("TSCLIB.dll", EntryPoint = "Setup")]
public static extern int Setup (string width, string height,
String speed, string density,
String sensor, String vertical,
string offset);

 [dllimport ("TSCLIB.dll", EntryPoint = "Windowsfont")]
    public static extern int Windowsfont (int x, int y, int fontheight,
     int rotation,  int FontStyle,  int FontUnderline,
                     string Szfacename, string content);
  
}


Namespace Tsclib_dll_in_c_sharp
{
Static Class Program
{
<summary>
The main entry point of the application.
</summary>
[STAThread]
static void Main ()
{
Application.enablevisualstyles ();
Application.setcompatibletextrenderingdefault (FALSE);
Application.Run (New Form1 ());
}
}
}

----Form1.cs

Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Text;
Using System.Windows.Forms;

Namespace Tsclib_dll_in_c_sharp
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}

private void Button1_Click (object sender, EventArgs e)
{
Tsclib_dll.about (); Show the DLL version
Tsclib_dll.openport ("TSC ttp-344m Plus"); Open specified printer driver
Tsclib_dll.setup ("100", "63.5", "4", "8", "0", "0", "0"); Setup the media size and sensor type info
Tsclib_dll.clearbuffer (); Clear Image Buffer
Tsclib_dll.barcode ("n", "N", "Max", "+", "1", "0", "2", "2", "Barcode Test"); Drawing Barcode
Tsclib_dll.printerfont ("+", "+", "3", "0", "1", "1", "Print Font Test"); Drawing Printer Font
Tsclib_dll.windowsfont (0, 0, 0, "ARIAL", "Windows Arial Font Test"); Draw Windows font
TSCLIB_DLL.DOWNLOADPCX ("UL. PCX "," UL.                                        PCX "); Download PCX file into printer
Tsclib_dll.sendcommand ("Putpcx 100,400," UL.                               PCX ""); Drawing PCX graphic
Tsclib_dll.printlabel ("1", "1"); Print Labels
Tsclib_dll.closeport (); Close specified printer driver

}
}
}

------Another example

[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Windowsfont (int a, int b, int c,int d,int e, int f, string g, string h);
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Openport (string printername);
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Closeport ();
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void SendCommand (String command);
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Setup (string width,string height,string speed,string density,string sensor,string Vertical, string offset);
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Clearbuffer ();
[System.Runtime.InteropServices.DllImport ("Tsclib.dll")]
private static extern void Printlabel (string set,string Copy);


private void Button1_Click (object sender, System.EventArgs e)
{
Openport ("TSC TTP-343");
Setup ("100", "65", "3", "10", "0", "3", "0");
Clearbuffer ();
Windowsfont (50,30,70,0,0,0, "blackbody", "Call ISBN:");
Printlabel ("1", "1");
Closeport ();
}

TSC Barcode Printer C # routines (Tsclib.dll call)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.