分析BarTender的SDK帮助文档

传送门
python集成Bartender的雏形
python写上位机(集成Bartender)


许多朋友不知道SDK的使用手册怎么获取,答案如下:
安装Bartender试用版,到开始目录下可以看到
在这里插入图片描述

一、SDK使用

SDK的内容分四部分:

  • Librarian API:版本管理系统,可以控制文件回滚、签入签出、显示文件信息等。
  • Print Engine API:客户端打印系统。管理打印机列表、打开关闭标签模版、合并标签数据、启动打印、监控打印状态。
  • Print Server API:服务器端打印系统,自带队列管理机制。
  • System Database API:系统数据库管理系统。

暂时只需要客户端打印系统,研究简单的打印模式。

1.1、Creating a BarTender Print Engine

最开始时需要创建一个Engine对象,然后启动,打开文件,打印,停止,释放资源。

// Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();
      // Open a format.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");
      // Print the format.
      btFormat.Print();
      // Stop the BarTender print engine.
      btEngine.Stop();
   }
// Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();
      // Open a format.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");
      // Print the format.
      btFormat.Print();
      // Stop the BarTender print engine.
      btEngine.Stop();
   }

特性:

  • 可以控制主程序的启动与停止
  • 可以打开、访问、保存标签模板
  • 可以监控打印事件
  • 可以控制APP窗口

1.1.1、如何开始和停止一个Engine类:

  • 创建时启动
    构造时传入参数true,隐式启动:
new Engine(true)
  • 创建后某个时刻触发启动
    默认构造,再显式启动:
Engine btEngine = new Engine()
btEngine.Start()
  • 停止时不保存修改
btEngine.Stop()
  • 停止时保存修改
btEngine.Stop(SaveOptions.SaveChanges)
  • 退出时,释放资源:
btEngine .Dispose()
  • 默认地,Bartender进程运行在幕后,若想显示Bartender软件的交互窗口:
btEngine.Window.Visible = true

1.2、Working with Print Job Status Events

当Engine引擎被启动时,就会监控打印状态。Engine类的evevts,存放着事件处理函数的指针,可以触发多个回调函数。

// Hook up to job cancelled event.
      btEngine.JobCancelled += new EventHandler<PrintJobEventArgs>(btEngine_JobCancelled);
      btEngine.JobErrorOccurred += new EventHandler<PrintJobEventArgs>(btEngine_JobErrorOccurred);
      btEngine.JobMonitorErrorOccurred += new EventHandler<MonitorErrorEventArgs>(btEngine_JobMonitorErrorOccurred);
      btEngine.JobPaused += new EventHandler<PrintJobEventArgs>(btEngine_JobPaused);
      btEngine.JobQueued += new EventHandler<PrintJobEventArgs>(btEngine_JobQueued);
      btEngine.JobRestarted += new EventHandler<PrintJobEventArgs>(btEngine_JobRestarted);
      btEngine.JobResumed += new EventHandler<PrintJobEventArgs>(btEngine_JobResumed);
      btEngine.JobSent += new EventHandler<JobSentEventArgs>(btEngine_JobSent);
详细内容暂时跳过

1.3、Working with Label Formats

LabelFormatDocument类

标签模版类,该类的实例对象代表.btw文件,用户可以通过该类对标签模板进行修改和打印。另外,每一个Engine对象都包含了一系列打开的.btw文件,简称文件集(The Documents Collection)。

  • 可以打开、关闭、打印、保存、激活标签模板
  • 可以访问标签模版的名字、打印机信息、字串等属性
  • 可以修改标签模板中的字串
  • 可以设定打印数量
  • 可以选择打印机打印或打印在文件中
  • 可以监控打印状态
  • LabelFormat 是LabelFormatDocument的父类
    LabelFormat 作用体现在:创建LabelFormatDocument对象之前,可以先使用LabelFormat预设属性,然后使用LabelFormat作为参数调用拷贝构造来构建LabelFormatDocument对象。

打开一个.btw文件:

LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabel.btw");
关闭一个.btw文件,为节省资源,最好是用完即关闭:
btFormat.Close(SaveOptions.DoNotSaveChanges);

1.4、Printing Label Formats

通过调用LabelFormatDocument类的打印方法可以打印标签模板

1.4.1public Result Print()

Result是一个enum类型,Success=0,Timeout=1,Failure=2

LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabel.btw");
Result result = btFormat.Print();
// Display the print result.
Console.WriteLine("Print status = " + nResult);

1.4.2、public Result Print( string printJobName)

参数:printJobName,打印任务名,如果为空,则会使用标签模板名
返回值:Result是一个enum类型,Success=0,Timeout=1,Failure=2

1.4.3、Print(string printJobName, out Messages message)

Messages messages = null;
LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabel.btw");
Result result = btFormat.Print("PrintJob1", out messages); 

参数:printJobName,打印任务名,如果为空,则会使用标签模板名
参数:messages,传入时是空的消息集合,返回时被函数内部填充,每一次打印都会在Message对象的text属性中写入内容。Messages类是一个集合类型,集合中的元素是Message类。

返回值:Result是一个enum类型,Success=0,Timeout=1,Failure=2

1.4.4、Print(string printJobName, int waitForCompletionTimeout)

参数:printJobName,打印任务名,如果为空,则会使用标签模板名
参数:waitForCompletionTimeout,打印超时时间,ms单位

返回值:Result是一个enum类型,Success=0,Timeout=1,Failure=2

1.4.5、Print(string printJobName, int waitForCompletionTimeout, out Messages messages)

参数:printJobName,打印任务名,如果为空,则会使用标签模板名
参数:messages,传入时是空的消息集合,返回时被函数内部填充,每一次打印都会在Message对象的text属性中写入内容。Messages类是一个集合类型,集合中的元素是Message类。
参数:waitForCompletionTimeout,打印超时时间,ms单位

返回值:Result是一个enum类型,Success=0,Timeout=1,Failure=2

  • enum类
    enum类型,Success=0,Timeout=1,Failure=2
  • Message类
    存放消息,包括正常消息、警告、错误消息。成员有:
    Category:消息种类
    ID:消息ID
    Severity:严重性
    Source:源
    Text:描述消息内容
    Verification:错误或故障相关处理
  • Messages类
    消息集合,成员有:
    Count:计数器
    HasError:判断是否包含错误消息
    Item:调取某个消息
    Add:添加消息

1.4.6、一次打印多个不同标签时

假设一个Engine对象中打开了多个LabelFormatDocument对象,一次性全部打印:

int i = 0;
foreach (LabelFormatDocument format in btEngine.Documents) 
{ 
i++; 
format.Print("PrintJob" + i); 
}

1.4.7、打印一系列标签时

btFormat.PrintSetup.NumberOfSerializedLabels:规定了序列长度
btFormat.PrintSetup.IdenticalCopiesOfLabel:规定了重复次数
在这里插入图片描述

// Initialize and start a new engine 
using (Engine btEngine = new Engine()) 
{ 
btEngine.Start();
// Open a label format. 
LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\MyLabel.btw");
// Change the number of identical labels and serialized labels to print 
btFormat.PrintSetup.NumberOfSerializedLabels = 4; 
btFormat.PrintSetup.IdenticalCopiesOfLabel = 10;
 // Print the label 
Result result = btFormat.Print(); 
}

1.4.8、配置打印机

打开标签模版时配置打印机
或给标签模版的成员属性PrinterName 配置打印机

// Initialize and start a new engine 
using (Engine btEngine = new Engine()) 
{
btEngine.Start();
// Open a label format specifying the default printer 
LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\MyLabel1.btw");
// Print the label 
Result result = btFormat.Print("PrintJob1");
// Open a label format specifying a different printer 
btFormat = btEngine.Documents.Open(@"C:\MyLabel2.btw", "OurPrinter_HX3000");
// Print the label 
result = btFormat.Print(); 
/*
// Change the name of the printer 
btFormat.PrintSetup.PrinterName = @"OurPrinter_HX3000";
*/
}

1.5、Changing Text and Barcode Data on the Label Format

读取和修改标签模板的内容,没有新建的方法
每个标签模板包含一系列的字段,这些字段类似于python中的字典,具备键值对。

1.5.1、/* 读取 */

Engine btEngine = new Engine(); 
LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\MyLabel.btw");
string AddressSubstring = btFormat.SubStrings["Address"].Value; 

1.5.2、/* 修改 */

Engine btEngine = new Engine(); 
LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabel.btw");
btFormat.SubStrings["Address"].Value = "1313 Mockingbird Lane, Anywhere, USA"; 
btFormat.SubStrings["Name"].Value = "John Doe"; 
btFormat.SubStrings["Quantity"].Value = "10";

/*
btFormat.SubStrings[“Quantity”].Value = “10”;
"Quantity"就是键(key),"10"就是值(value),通过键能够调出值的内容
*/

1.6、Automating Database Printing

数据库打印,暂时跳过

1.7、Working with Print Job Status Events

Job Status Events依赖于Maestro Print Service监控程序。

LabelFormatDocument类与Engine类还有Printer类等等,许多类型都有相应的事件Event。下面具体研究 Engine 与 LabelFormatDocument 类的Event机制,其他类大同小异,暂时略过。

1.7.1、订阅Job Status Events

订阅,类似于信号绑定。将处理函数的指针推入列表的相应位置。

// Open a label format 
LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabelFormat.btw");
// Subscribe to the format event 
btFormat.JobQueued += new EventHandler<PrintJobEventArgs>(MyLabelFormatOnJobQueued);

/* 订阅了JobQueued事件,MyLabelFormatOnJobQueued为事件处理函数 */

1.7.2、处理Job Status Events

针对Engine类,有以下程序:

// Called by a worker thread when a job is queued 
public void btEngine_JobQueued(object sender, PrintJobEventArgs e) 
{ 
	// 类型转换,将基类对象转换成子类对象
	Engine btEngine = sender as Engine; 
	if (btEngine != null) 
	{ 
	Console.WriteLine(string.Format("Client {0} has printed or is printing {1} jobs", e.ClientName, btEngine.PrintJobCounter)); 
	} 
}

btEngine_JobQueued是回调函数名,与订阅时的函数相对应。

参数:sender,当一个打印事件被推入打印队列时,假若该打印事件对应的Engine对象或LabelFormatDocument对象曾经订阅过JobQueued类型的事件,那么这些对象就会作为sender参数。

参数:PrintJobEventArgs,打印事件的相关信息。

上例代表了一个Engine对象调用btEngine_JobQueued的场景。

针对LabelFormatDocument类,有以下程序:

public void ProgramModule() 
{ 
	// Initialize and start a BarTender Engine 
	using (Engine btEngine = new Engine(true)) 
	{ 
	// Open a label format 
	LabelFormatDocument btFormat = btEngine.Documents.Open(@"c:\MyLabelFormat.btw");
	// Subscribe to the format event 
	btFormat.JobQueued += new EventHandler<PrintJobEventArgs>(MyLabelFormatOnJobQueued);
	// Print the label 
	btFormat.Print();
	// Stop the BarTender Engine 
	btEngine.Stop(SaveOptions.DoNotSaveChanges); 
	} 
}
public void MyLabelFormatOnJobQueued(object sender, PrintJobEventArgs printJobEventInfo) 
{ 
	// 类型转换,将基类对象转换成子类对象
	LabelFormatDocument btFormat = sender as LabelFormatDocument;
	// Check to see if the object is not null 
	// If it is, the sender was NOT a Format 
	if (btFormat != null) 
	{ 
	// Do something with the label format 
	} 
}

1.7.3、Handler处理函数的第二个参数

上例中,Handler函数形式为:
public void MyLabelFormatOnJobQueued(object sender, PrintJobEventArgs printJobEventInfo)

第二个参数可以有3种类型,PrintJobEventArgsJobSentEventArgsMonitorErrorEventArgs

PrintJobEventArgs:代表普通打印任务的事件

  • PrintJobEventArgs 类
    ClientName:客户端名, PC机名
    ID:打印任务的ID
    Name:打印任务名
    PagesPrinted:已打印的页数
    PrinterInfo:触发事件的打印机信息
    Status:当前打印状态
    TotalPages:当前打印任务的总页数
    UserName:用户名

JobSentEventArgs:是PrintJobEventArgs的子类,只多了一个成员变量,JobPrintingVerified,表示已经打印完成或已被发送到物理打印机(而不是库中的缓存队列)。

  • JobSentEventArgs 类
    ClientName:客户端名, PC机名
    ID:打印任务的ID
    JobPrintingVerified:与父类(PrintJobEventArgs )的区别在此。打印确认。
    Name:打印任务名
    PagesPrinted:已打印的页数
    PrinterInfo:触发事件的打印机信息
    Status:当前打印状态
    TotalPages:当前打印任务的总页数
    UserName:用户名

MonitorErrorEventArgs:监控错误事件,区别上面2种。

  • MonitorErrorEventArgs 类
    ComputerName:出错的PC机名
    ErrorType:错误类型
    Message:错误信息文本

1.7.4、事件events

1.7.4.1、Engine Events

9个事件类型分别是:CommandLineCompleted Event、JobCancelled Event、JobErrorOccurred、JobMonitorErrorOccurred、JobPaused、JobQueued、JobRestarted、JobResumed、JobSent

  • CommandLineCompleted Event:命令完成,区别LabelFormatDocument Event

  • JobCancelled Event:任务关闭。

      在一个Engine中,通常监控了多个LabelFormatDocument,
      当其中一个LabelFormatDocument产生打印任务关闭事件时,对应的LabelFormatDocument下会产生JobCancelled,
      并且同时,Engine也会产生JobCancelled。以下的其他事件类型也同理。
    
  • JobErrorOccurred:任务错误

  • JobMonitorErrorOccurred:监控错误

  • JobPaused:暂停

  • JobQueued:入列

  • JobRestarted:重启

  • JobResumed:回溯

  • JobSent:发送

1.7.4.2、LabelFormatDocument Event

如果需要对不同的LabelFormatDocument配置不同的事件处理,则需要在LabelFormatDocument下配置不同的回调函数。

但是,若是对所有的LabelFormatDocument事件都可以统一处理,此处就没必要逐个LabelFormatDocument配置了。直接在Engine下配置回调函数即可。

8个事件类型分别是:JobCancelled 、JobErrorOccurred 、JobMonitorErrorOccurred 、JobPaused 、JobQueued 、JobRestarted 、JobResumed 、JobSent

注意:少了一个CommandLineCompleted Event
public void Demo()
{
   // Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Open a format to be printed.
      btEngine.Documents.Open(@"C:\Format1.btw");

      // Hook up to job cancelled event.
      btEngine.JobCancelled += new EventHandler<PrintJobEventArgs>(btEngine_JobCancelled);
      btEngine.JobErrorOccurred += new EventHandler<PrintJobEventArgs>(btEngine_JobErrorOccurred);
      btEngine.JobMonitorErrorOccurred += new EventHandler<MonitorErrorEventArgs>(btEngine_JobMonitorErrorOccurred);
      btEngine.JobPaused += new EventHandler<PrintJobEventArgs>(btEngine_JobPaused);
      btEngine.JobQueued += new EventHandler<PrintJobEventArgs>(btEngine_JobQueued);
      btEngine.JobRestarted += new EventHandler<PrintJobEventArgs>(btEngine_JobRestarted);
      btEngine.JobResumed += new EventHandler<PrintJobEventArgs>(btEngine_JobResumed);
      btEngine.JobSent += new EventHandler<JobSentEventArgs>(btEngine_JobSent);

      // Declare a commandline and execute it
      // (this commandline will print all open formats).
      String commandLine = "/P";
      btEngine.CommandLine(commandLine);

      // Since the commandline is processed asynchronously, we must
      // wait for printing to complete before stopping the engine.
      while (btEngine.IsProcessingCommandLines || btEngine.IsPrinting)
         System.Threading.Thread.Sleep(500);

      // Stop the BarTender print engine.
      btEngine.Stop(SaveOptions.PromptSave);
   }
}
  • JobCancelled :打印任务关闭时产生。
  • JobErrorOccurred :打印错误。
  • JobMonitorErrorOccurred :监控错误
  • JobPaused :打印暂停(挂起)
  • JobQueued :任务入列(库中的打印队列)
  • JobRestarted :任务重启
  • JobResumed :回溯??
  • JobSent :已被发送至打印机或打印完成,意味着从库中的打印队列转移到打印机

1.8、Printing Label Formats to a File

往文件里打印??再发送文件至打印机??

二、几个重要类的特性

2.1、Engine类

一个Engine对象代表一个打印引擎实体。

类成员:

  • 2个构造函数
namemean
Engine()创建一个引擎实例
Engine(Boolean)创建一个引擎实例,并指定是否在创建时就默认调用start
  • 属性:
namemean
ActiveDocument最近一个使用的标签模板
BuildNumber当前Engine对象的创建编号
Documents打开的标签模板列表
Edition当前BarTender Application的版本
FullVersionBarTender application的完整版本
IsAlive是否程序正在运行
IsPrinting是否正在打印
IsProcessingCommandLines是否正在处理命令行指令
IsResponsive在规定时间内是否响应
ResponsiveTimeout响应超时定时器
LicenseServer获取准许证服务程序对象
PrintJobCounter打印任务计数值
SAPIDocDefinitionFile获取或设置SAP IDoc配置文件名
SupportNumber获取BarTender应用程序的支持号码
Version获取BarTender应用程序的版本
Window获取对Window对象的引用,该对象控制BarTender应用程序的Window的外观
  • 方法:
namemean
CommandLine()提交命令行以供BarTender打印引擎处理
Dispose()关闭Engine,并释放资源
Dispose(Boolean)关闭引擎并释放对象所拥有的资源,指定是否可以处置托管资源
Finalize析构函数
IsProductKeyCode(String)生产密钥是否匹配软件
Restart停止,并重启
Start()启动进程
Stop()暂停进程
  • 事件:
NameMean
CommandLineCompleted命令行完成时触发
JobCancelled打印关闭时触发
JobErrorOccurred打印作业出错时触发
JobMonitorErrorOccurred当引擎在监视打印作业时遇到错误时发生
JobPaused打印作业暂停时触发
JobQueued打印作业入队时触发
JobRestarted打印作业重新开始时触发
JobResumed打印作业暂停后,恢复打印时触发
JobSent在将打印作业发送到打印机端口时触发,打印机收到数据后才开始打印,但是上位机已经无法知晓外部打印机的工作状态了
public void Demo()
{
   // Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Open a format to be printed.
      btEngine.Documents.Open(@"C:\Format1.btw");

      // Hook up to job cancelled event.
      // 回调函数都需要程序员额外定义在函数体外部。这里使用‘+=’说明一个事件可能触发多个回调函数
      btEngine.JobCancelled += new EventHandler<PrintJobEventArgs>(btEngine_JobCancelled);
      btEngine.JobErrorOccurred += new EventHandler<PrintJobEventArgs>(btEngine_JobErrorOccurred);
      btEngine.JobMonitorErrorOccurred += new EventHandler<MonitorErrorEventArgs>(btEngine_JobMonitorErrorOccurred);
      btEngine.JobPaused += new EventHandler<PrintJobEventArgs>(btEngine_JobPaused);
      btEngine.JobQueued += new EventHandler<PrintJobEventArgs>(btEngine_JobQueued);
      btEngine.JobRestarted += new EventHandler<PrintJobEventArgs>(btEngine_JobRestarted);
      btEngine.JobResumed += new EventHandler<PrintJobEventArgs>(btEngine_JobResumed);
      btEngine.JobSent += new EventHandler<JobSentEventArgs>(btEngine_JobSent);

      // Declare a commandline and execute it
      // (this commandline will print all open formats).
      String commandLine = "/P";
      btEngine.CommandLine(commandLine);

      // Since the commandline is processed asynchronously, we must
      // wait for printing to complete before stopping the engine.
      while (btEngine.IsProcessingCommandLines || btEngine.IsPrinting)
         System.Threading.Thread.Sleep(500);

      // Stop the BarTender print engine.
      btEngine.Stop(SaveOptions.PromptSave);
   }
}

2.2、LabelFormatDocument类

LabelFormatDocument的类实例代表一个.btw文件。

// Open a format document.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");
  • 注意:LabelFormatDocument继承自LabelFormat,区别在于后者并不能代表一个.btw文件,只能作为某个.btw文件的预配置格式。

类成员

  • 构造函数

  • 成员变量

NameMean
Attached返回此对象是否附加到BarTender自动化对象。(继承自BtAutomationObject。)
BaseName获取标签格式文件名的基础部分。 只读。(继承自LabelFormat。)
Comment获取或设置标签格式的注释。(继承自LabelFormat。)
DatabaseConnections获取为标签格式定义的DatabaseConnections列表。 只读。(继承自LabelFormat。)
Detached返回此对象是否与BarTender自动化对象分离。(继承自BtAutomationObject。)
Directory获取标签格式文件所在的目录。只读。(继承自LabelFormat。)
Encryption获取或设置标签格式的加密密钥。(继承自LabelFormat。)
FileName获取标签格式文件的完整路径。 只读。(继承自LabelFormat。)
IsModified获取或设置文档是否已修改。(继承自LabelFormat。)
LatestSaveNumber获取格式的最新修订号。 返回:LabelFormat.NullLabelFormat(如果Bt Format接口为null)。 如果尚未保存格式,或者版本日志功能已关闭,则为0。 否则,返回当前的修订号。(继承自LabelFormat。)
PageSetup获取标签格式的PageSetup对象。 只读。(继承自LabelFormat。)
PasswordProtections获取标签格式的PasswordProtections对象。 PasswordProtections包含用于指定哪些操作受密码保护的值(继承自LabelFormat。)
PrinterCodeTemplate获取或设置一个PrinterCodeTemplate对象,该对象用于配置和导出打印机代码模板。(继承自LabelFormat。)
PrintJobCounter获取此LabelFormatDocument所拥有的当前正在打印或在打印机队列中的打印作业数。
PrintPreview获取标签格式的PrintPreview对象。 PrintPreview对象使用户能够显示和控制打印预览窗口。(继承自LabelFormat。)
PrintSetup获取标签格式的PrintSetup对象。 PrintSetup对象保存有关打印机设置的数据,例如份数和打印机名称。(继承自LabelFormat。)
Prompts获取标签格式的打印时间列表。 只读。(继承自LabelFormat。)
Status表示LabelFormat的当前状态,有关该状态之前是否在BarTender中打开过,以及是否已缓存该格式的数据。(继承自LabelFormat。)
SubStrings获取标签格式上的所有数据列表(数据名,以字符串形式)。 只读。(继承自LabelFormat。)
Title获取标签格式的标题。 只读。(继承自LabelFormat。)
ViewRecordNavigator获取ViewRecordNavigator对象,该对象用于支持模板设计中数据库记录的浏览。(继承自LabelFormat。)
  • 方法
NameMean
Activate将此格式设置为此BarTender引擎实例的活动格式。Activate方法会将LabelFormatDocument分配给BarTender打印引擎的ActiveDocument属性。 如果BarTender打印引擎是可见的,则格式窗口将获得焦点。
Close
ExportImageToClipboard将标签格式的位图表示复制到剪贴板
ExportImageToFile将格式导出到图像文件
ExportPrintPreviewRangeToFile导出页面范围的打印预览
ExportPrintPreviewToFile将打印预览导出到图像文件
Print()Result nResult = btFormat.Print();
Print(String)
Print(String, Messages)
Print(String, Int32)
Print(String, Int32, Messages)Result nResult = btFormat.Print(“Test Print”, 6000, out btMessages);// 打印时指定作业名称和等待超时,并获取所有返回的消息
Save保存格式
SaveAsbtFormat.SaveAs(@“C:\Format2.btw”, true);// 用新名称保存格式,覆盖任何现有文件
SpecifyDocumentPassword指定用于密码保护操作的文档密码
  • 事件
public void Demo()
{
   // Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Open a format document.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");

      // Hook up to job events.
      btFormat.JobCancelled += new EventHandler<PrintJobEventArgs>(btFormat_JobCancelled);
      btFormat.JobErrorOccurred += new EventHandler<PrintJobEventArgs>(btFormat_JobErrorOccurred);
      btFormat.JobMonitorErrorOccurred += new EventHandler<MonitorErrorEventArgs>(btFormat_JobMonitorErrorOccurred);
      btFormat.JobPaused += new EventHandler<PrintJobEventArgs>(btFormat_JobPaused);
      btFormat.JobQueued += new EventHandler<PrintJobEventArgs>(btFormat_JobQueued);
      btFormat.JobRestarted += new EventHandler<PrintJobEventArgs>(btFormat_JobRestarted);
      btFormat.JobResumed += new EventHandler<PrintJobEventArgs>(btFormat_JobResumed);
      btFormat.JobSent += new EventHandler<JobSentEventArgs>(btFormat_JobSent);

      // Print the format.
      btFormat.Print();

      // Close the current format without saving.
      btFormat.Close(SaveOptions.DoNotSaveChanges);

      // Stop the BarTender print engine.
      btEngine.Stop();
   }

2.3、PrintSetup类

属于LabelFormatDocument类的一个成员,一般在打印前设置PrintSetup,用例如下

public void Demo()
{
   // Initialize a new BarTender print engine.
   using (Engine btEngine = new Engine())
   {
      // Start the BarTender print engine.
      btEngine.Start();

      // Open a format document.
      LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\Format1.btw");

      // Set the number of identical copies.
      btFormat.PrintSetup.IdenticalCopiesOfLabel = 2;

      // Set the number of serialized copies.
      btFormat.PrintSetup.NumberOfSerializedLabels = 10;

      // Change the comment on the format.
      btFormat.Comment = "This format now contains serialized object values";

      // Print the format.
      btFormat.Print();

      // Stop the BarTender print engine saving all changes.
      btEngine.Stop(SaveOptions.SaveChanges);
   }
}

类成员

  • 属性
namemean
Attached是否绑定了自动化对象
AutoPrintAgain自动连续打印
Cache缓存
Detached是否无任何自动化对象与之绑定
EnablePrompting在打印时提示数据交互时间
IdenticalCopiesOfLabel副本数量
IsIdenticalCopiesUnlimited副本数量不受限制标志位
IsNumberSerializedLabelsUnlimited序列号不受限制标志位
JobName打印任务名
LabelObjectPrintMethod打印方式,标签内不同段的打印方式
LogPrintJob记录打印任务,类似日志
NumberOfSerializedLabels连续打印的序列长度
Performance打印机性能
PrinterName打印机名
PrintToFile是否打印到文件中
PrintToFileLicense许可,搭配CreatePrintToFileLicense使用
PrintToFileName文件名
RecordRange从数据库调取记录范围以供引擎打印
ReloadTextDatabaseFields重载文本库
SelectRecordsAtPrint是否用户会在打印时选择打印字段
StartingPosition位置
SupportsIdenticalCopies是否支持多副本
SupportsSerializedLabels是否支持序列
UseDatabase是否使用数据库

2.4、Substring类

Substrings类属于LabelFormatDocument类的一个成员,而Substring则是Substrings中的item

类成员

  • 属性
namemean
Attached是否绑定了自动化对象
Detached是否解绑
Name数据源名称
Rollover序列化达到指定值时是否将进行翻转
RolloverLimit发生翻转的点
RolloverResetValue获取或设置序列化达到翻转限制时重新开始的值
SerializeBy获取或设置发生序列化时数据源递增或递减的间隔
SerializeEvery序列号递增或递减前,需要重复当前序列的次数
Type数据源的类型
Value数据源的值

在这里插入图片描述

  • 5
    点赞
  • 61
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
Bartender是一种流行的酒吧管理软件,用于制作和管理酒吧的饮料菜单。BartenderSDK文档是为开发人员提供的一份技术文档,旨在帮助他们利用Bartender的软件开发工具包(SDK)进行自定义开发和集成。 SDK文档通常包含以下内容: 1. 简介和安装指南:介绍Bartender SDK的功能和用途,并提供安装和配置指南,使开发人员能够快速开始使用SDK。 2. 开发指南:详细说明如何使用SDK进行开发,包括SDK中的各种功能和API的使用方法。这些指南通常包含示例代码和操作示例,以帮助开发人员了解如何使用SDK中的各种功能进行自定义开发。 3. API参考:提供对SDK提供的各种API的详细说明,包括API的参数、返回值和用法。开发人员可以根据API参考来了解如何正确地使用SDK中的各种功能和方法。 4. 整合指南:介绍如何将Bartender集成到其他系统或应用中,以实现更高级的功能。这些指南通常提供了集成的步骤和实例,帮助开发人员了解如何将Bartender与其他系统无缝地连接起来。 通过阅读BartenderSDK文档,开发人员可以了解如何使用SDK中提供的功能和工具来进行定制开发和集成,从而满足特定需求。这份文档的细致和清晰度,对于开发人员来说是非常重要的,因为它能够为他们提供所需的信息和指导,以便他们能够更高效地利用BartenderSDK进行开发工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值