zoukankan      html  css  js  c++  java
  • c#BarTender打印,打印微调

    方法一、引用“Interop.BarTender.dll”单个打印

    BarTender.Application btApp;
    BarTender.Format btFormat;
    
    
     btApp = new BarTender.Application();
    
    
     btFormat = btApp.Formats.Open(tbPath.Text, false, "");
                    btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
                    btFormat.PrintSetup.NumberSerializedLabels = 1;
                    
                     btFormat.SetNamedSubStringValue("cm", "AAA");
                        btFormat.SetNamedSubStringValue("DATE", DateTime.Now.ToString("yyyy-MM-dd"));
                        btFormat.SetNamedSubStringValue("PN", "AAA");
                        btFormat.SetNamedSubStringValue("R", "AA");
                        btFormat.SetNamedSubStringValue("V1", "BBB");
                        btFormat.SetNamedSubStringValue("xl", "CCC");
    
     btFormat.PrintOut(false, false);
                        btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
                        btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

    方法二、引用“Seagull.BarTender.Print.dll”批量打印数据

     using Seagull.BarTender.Print;
     using Seagull.BarTender.Print.Database;
    
    
    
        StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    stringBuilder.Append(table.Rows[i][0].ToString());
                    stringBuilder.Append("	").Append(table.Rows[i][1].ToString());
                    stringBuilder.AppendLine();
                }
                File.WriteAllText(tbDataPath.Text, stringBuilder.ToString());
                Engine engine = new Engine();
                engine.Start();
                LabelFormatDocument labelFormatDocument = engine.Documents.Open(tbPath.Text);
                ((TextFile)labelFormatDocument.DatabaseConnections["TextFileDB"]).FileName = tbDataPath.Text;

            labelFormatDocument.PrintSetup.IdenticalCopiesOfLabel = 1;//打印一份
            labelFormatDocument.PageSetup.MarginTop = (float)nudMarginTop.Value;//上边距
            labelFormatDocument.PageSetup.MarginLeft = (float)nudMarginLeft.Value;//左边距

            
           

    #region 打印预览设置
    //engine.Window.VisibleWindows = VisibleWindows.InteractiveDialogs;//开启打印预览
    //labelFormatDocument.PrintPreview.ShowPrintDialogOnPrint = true;
    //labelFormatDocument.PrintPreview.StatusBarVisible = true;
    //labelFormatDocument.PrintPreview.ToolbarVisible = true;
    //labelFormatDocument.PrintPreview.StatusBarVisible = true;
    //labelFormatDocument.PrintPreview.ShowDialog();
    #endregion

     

    labelFormatDocument.PrintSetup.PrinterName
    = "PrimoPDF";//设置打印机 Cursor.Current = Cursors.WaitCursor; int waitForCompletionTimeout = 10000; Messages messages; Result result = labelFormatDocument.Print(tbPath.Text, waitForCompletionTimeout, out messages);
    TXT文件内容

    SN01 XX00015 SN02 XX00016 SN03 XX00017 SN04 XX00018 SN05 XX00019

    BarTender打印微调

     打印布局在以下代码属性中微调

     

  • 相关阅读:
    如何给swing加上alt+x和ctrl+x快捷键
    java基础之登录程序
    RFID UHF(EPC)标签使用常识
    史密斯圆图
    C# DataTable Operations
    温度测量【RTD】
    温度测量【温度传感器类型】
    C# Debug
    c# ComboBox绑定枚举
    c# 隐藏Tab控件的标签
  • 原文地址:https://www.cnblogs.com/weifeng123/p/14366672.html
Copyright © 2011-2022 走看看