受欢迎的博客标签

BarTender 集成模式之二:BarTender .net sdk

Published

Requirements

Install .NET Framework 4.8  on  Windows
Install Bartender2016 R1  with  .Net SDK  option checked 

Create .Net Framework project
Add Seagull.BarTender.Print in your c# project
using Seagull.BarTender.Print
code


1.Download .NET Framework 4.8 and Install - download url:https://go.microsoft.com/fwlink/?LinkId=2085155
2.Download .NET Framework 4.8 Developer Pack ( CHS Language Pack! and Install )- download url:https://go.microsoft.com/fwlink/?LinkId=2085167&clcid=0x804

说明:

1.BarTender .net SDK只支持.Net Framework框架,不支持.Net core 和.net 5.。所以在系统中需安装.Net Framework
1.1 dotnet  core doesnt work.you need full dot net 4.7.1 / 4.7.2 / 4.8  
1.2 BarTender 2021 R2, the BarTender .NET SDK doesn't support Microsoft .Net core 3.1 / .Net 5.0. 
     It is currently built-on and requires full Microsoft .net framework 4.7.2 or higher.
2.安装时需勾选.net SDK
3. .NET SDK是从BarTender 9.0版本才开始支持的一个.NET框架的SDK.
4. .NET SDK Required Edition: Automation, Enterprise Automation
5. office and bartender all is 32bit or all 64bit on the same time 
5.BarTender的几种集成模式:ActiveX COM集成,Commander的触发式集成,.NET SDK

 

Step 1:Install .NET Framework 4.8  on  Windows

1.Download .NET Framework 4.8 and Install - download url:https://go.microsoft.com/fwlink/?LinkId=2085155
2.Download .NET Framework 4.8 Developer Pack ( CHS Language Pack! and Install )- download url:https://go.microsoft.com/fwlink/?LinkId=2085167&clcid=0x804

 

Step 2:Install Bartender2016 R1  with  .Net SDK  option checked 

Requirements for Install Bartender on Windows
1. .NET SDK Required Bartender Version: Bartender 9.0 and over 
2. .NET SDK Required Edition: Automation, Enterprise Automation
3. .NET SDK Required Install Option:.Net SDK  option checked 

When you install Bartender, be sure to install Automation version (or Enterprise Automation).
During the install, select advanced and check the option to install .NET SDK examples.
Once installation is completed you'll find a folder installed on your system "Bartender .NET SDK".
Open that and look in "Print Engine API Samples" > "LabelPrint". You'll find projects for both C# and VB. The path on my machine is "C:\Program Files\Seagull\BarTender Suite\SDK\Print Engine API Samples\LabelPrint" but it may be different on yours depending on where you installed.

 

 

BarTender v2016 and higher

BarTender 2016 and higher offers both a 32 bit and 64 bit version. In addition, newer versions of BarTender are using a newer version of Microsoft .NET Framework. Therefore, please consider the following:

Make sure you are using the same bit version (32 or 64 bit) of BarTender that your custom application is targeted for and compiled with. Otherwise, you will need to recompile the custom application with the bit version that matches the bit version of BarTender.

Make sure your custom application is compiled for the Microsoft .NET Framework version used by BarTender.

If you upgrade BarTender on your development system, you may also need to remove and re-add the references to the SDK in your project.

When you start BT's Help (in BarTender, press the F1 key), do you not see the "Automating BarTender" topic and inside that the "Automation with ActiveX" subtopic? Otherwise, you should still be able to open the "Automation.chm" file you'll find under "C:\Program Files (x86)\Seagull\BarTender Suite\Help".

 

SDK的内容分四部分

The Librarian API allows you to access the functionality of Librarian, a revision control system installed with the BarTender Suite. 
The Print Engine API lets you manage BarTender's print engines and automate printing.
The Print Server API provides scalable, task-based management of large or complex print jobs.
The System Database API provides access to information stored in the BarTender System Database.

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

 

Table of contents

BarTender .net SDK and BarTender Version compatibility

Bartender Net Sdk Examples

BarTender Librarian

How to Install, Upgrade and Remove Drivers by Seagull™

INTEGRATING THE BARTENDER® PRINTING AND DESIGN FUNCTIONALITY WITH YOUR CUSTOM APPLICATION

You can use the BarTender integration functionality to import data from external systems and allow
other applications to use BarTender to print your BarTender documents.

 

If you have installed the BarTender .net SDK, you should be able to find further documentation and examples in the BarTender designer under the help menu->BarTender help->Automating BarTender->Automation with the BarTender .net SDK.

For Bartender 2021: c:\Program Files (x86)\Seagull\Bartender 2021\Help\BTSDK.chm
Seagull.BarTender.Print.dll - C:\Program Files (x86)\Seagull\BarTender Suite\SDK\Assemblies\Seagull.BarTender.Print.dll

Is possible to use .Net SDK without a Bartender Installation?

My idea is to make an application to use in some pc's of the company to print labels, but I don't want to install Bartender in these pc's.

The problem is, when I start the Engine, the program sends an error because the license is required ("You must activate Bartender with a valid product key code to use the BarTender Print Service API....") . I have a license server in the lan but I don't know how to connect him with C# .Net and without Bartender application.

My version is Automation 2021

 

project. For v9.3 or older you will need to do some additional tinkering.

The following steps show how to add the BarTender .NET SDK into a Visual Studio 2010 project.

1) When VS2010 starts select "New Project" on the start page.

2) Select ".Net Framework 4" and the project's template type and name.

3) In the Solution Explorer right mouse click on the project name and select Properties.

4) On the Application tab change the Target framework to be ".NET Framework 4". The solution will reload.

5) In the "Solution Explorer" right mouse click on the Reference folder and select "Add Reference…"

6) If using BarTender version 9.4 or later, select the ".NET" tab and select the Component Name "Seagull.BarTender.Print".

If using BarTender version 9.3 or earlier, select the "Browse" tab, navigate to the folder "<Program Files>\BarTender Suite\SDK\Assemblies", and select the file Seagull.BarTender.Print.dll

7) In the Solution Explorer edit the file app.config and change the contents to be:

<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
The notable change is that "useLegacyV2RuntimeActivationPolicy=true".

8) Add a button to your project's form and write BarTender SDK code as per documentation and samples.

9) Compile and run application.

The BarTender engine could not be started. Possible reasons are:

1) BarTender is not properly installed.
2) BarTender is not properly registered on the computer (e.g bartend.exe /register).
3) There are too many process instances of BarTender running. Stop a few bartend.exe instances and try again. 

To start, add a using reference to the "Seagull.BarTender.Print" component at the beginning of the code alongside other using statements, thus bringing the BarTender class into scope. 

using Seagull.BarTender.Print;

Enter in your BarTender specific automation code into the contents of the button's click event.  In the below example we create a BarTender engine instance, start it, define an application window making it visible, pause for five seconds, and then lastly, stopping the BarTender engine instance.

c# winform

private void button1_Click(object sender, EventArgs e)
{
               
       // Create and Start the BarTender print engine.
       Engine btEngine = new Engine();
       btEngine.Start();
 
       // Set the BarTender main window dimensions.
       btEngine.Window.Width = 800;
       btEngine.Window.Height = 600;
 
       // Set the window location.
       btEngine.Window.Top = 100;
       btEngine.Window.Left = 100;
 
       // Make BarTender visible to the user.
       btEngine.Window.Visible = true;
 
       // Wait five seconds so the user can see the window.
       System.Threading.Thread.Sleep(5000);
 
       // Stop the BarTender print engine.
       btEngine.Stop();
}

 

1.客户需求收集

1.1 搞清楚客户是需要在服务器打印还是客户端打印

 

2.实现

 

BarTender的几种集成模式。(come from:https://www.cnblogs.com/ldc218/p/5306675.html

ActiveX COM集成,
Commander的触发式集成,
还有9.0版本后支持的.NET SDK的支持

BarTender .NET SDK

.NET SDK里面分开了两个,一个是标准的,一个是Server版的。
标准的只是简单的开启BarTender进程去处理打印任务,所以当有多个任务同时打印的时候,就需要自己去管理任务队列问题;

Server版的就是里面有了任务队列机制,很方便的管理任务队列和BarTender的进程资源。
但是Server版需要安装BarTender的Enterprise版才支持.

It is currently built-on and requires full Microsoft .net framework 4.7.2 or higher.you need full dot net 4.7.1 / 4.7.2 / 4.8.
Currently at this time as of BarTender 2021 R2, the BarTender .NET SDK doesn't support Microsoft .Net core 3.1 / .Net 5.0. 

 

C:\Windows\assembly\GAC_MSIL\Interop.BarTender\11.0.1.1__109ff779a1b4cbc7\Interop.BarTender.dll

分析BarTender的SDK帮助文档及打印源代码

https://blog.csdn.net/mynameisJW/article/details/105491033

 

c#集成BarTender .net sdk 实现各种打印场景的方案

https://blog.51cto.com/yerik/611804

 

Download .NET Framework 4.8

https://dotnet.microsoft.com/download/dotnet-framework

download url:https://go.microsoft.com/fwlink/?LinkId=2085167&clcid=0x804