[C #] Call the Bartender service and print the bartender tag

Source: Internet
Author: User

[C #] Call the Bartender service and print the bartender tag

Most enterprises usually use tags in the production, warehousing, QC, and other operations.
Generally, enterprises are equipped with label software + dedicated label printers. In this example, we use barriers as an example.
If you want to print a bar code or display a specific function, you can use CR, FR, and so on. However, these reporting tools are not professional label software.
Good brother Daniel shared a source code written by delphi. Unfortunately, I won't go to delphi, and I don't have the IDE environment to look at the source code. I want C # To write a similar function:
General idea:Call the Bartender service and print the bartender tag
(1) download the Bartender SDK and directly reference it (I have not studied the SDK, so I am lazy ...)
(2) install the bartender software and create labels for testing. In this example, the certificate is used.
(3) code implementation
Program interface:

Create tags:

The Code is as follows (Code of one label type is omitted): public partial class FrmQC: Form {public FrmQC () {InitializeComponent ();} BarTender. application btApp; barapp. format btFormat; private void Form1_Load (object sender, EventArgs e) {btApp = new BarTender. application (); this. num2.Value = 1;} private void button#click (object sender, EventArgs e) {int a = Int32.Parse (this. num2.Value. toString (); // set the variable if (this.txt Item. text. length = 0) {MessageBox. show ("no item entered");} else {btFormat = btApp. formats. open (@ "C: \ BarTenderFiles \ certification", false, ""); btFormat. printSetup. identicalCopiesOfLabel = 1; // set the number of copies printed in the same sequence btFormat. printSetup. numberSerializedLabels = a; // set the number of sequences to be printed btFormat. setNamedSubStringValue ("product number", this.txt Item. text); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("Product Name", this.txt Name. text); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("type", this.txt Desc. text); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("batch number", this.txt Pici. text); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("date", System. dateTime. now. year + ". "+ System. dateTime. now. month + ". "+ System. dateTime. now. day); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("month", System. dateTime. now. month + "Month"); // pass the variable btFormat to the bartender template. setNamedSubStringValue ("month", System. dateTime. now. month. toString (); // pass the variable btFormat to the bartender template. printOut (true, true); // The second false setting specifies whether the print attribute btFormat exists during printing. close (barparts. btSaveOptions. btSaveChanges); // whether to save the tag when exiting} private void form=formclosed (object sender, FormClosedEventArgs e) {btApp. quit (Barlow. btSaveOptions. btSaveChanges); // exit the bartender process synchronously when the interface exits }}

The TSC label printer is not connected to the test environment, and the A4 paper output result of the general printer is as follows:

Note: The tag template variable must be set to the sharing name.
Otherwise, you may encounter the following problems:
[System. Runtime. InteropServices. COMException] = {"the Name of the named substring is not found in the list of named substrings ."} Solution

Related Article

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.