• 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打印微调

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

     

  • 相关阅读:
    【Java123】JDBC数据库连接池建立
    【招聘123】Some good open positions
    [Java123]Gradle
    4_3:流程控制:循环练习
    4_3:流程控制:while + do while + continue + break
    4_2:流程控制:[ for循环 ] + 断点调试
    4_1:流程控制:分支结构:[ if else ] + [ 三元表达式 ] + [ switch case ]
    3:运算符 + 运算符优先级 [ 逻辑短路 ]
    2_3:变量:[ 类型之间转换 ]
    2_2:变量:[ 五种简单数据类型 ]
  • 原文地址:https://www.cnblogs.com/weifeng123/p/14366672.html
Copyright © 2020-2023  润新知