How to perform Internet Printing via .NET SDKs with BarTender
Overview
How to perform Internet Printing via .NET SDKs with BarTender.
Applicable to
BarTender 2016 and above.
Information
Web Label Print Sample
As part of the BarTender suite, we have included an example called Web Label Print. The Web Label Print Sample application is a working Windows ASP.net web application that demonstrates how to use the BarTender Print Server SDK to print across an Internet web connection. It will allow you to print to printers installed locally on the web server where BarTender is running and also to remote printers connected to remote client computers.
This example is a good starting point for developing your own web application that integrates with BarTender using our .NET SDK.
The application, which includes all source code, allows the user to:
- Print BarTender documents, on local printers (connected directly to the server or through a LAN or WAN) using standard Windows printing and on remote printers accessed via the Internet.
- Select which type of remote printing to use: BarTender Web Print Service, or a Java applet.
- Explore different mechanisms of communicating with the Web Print Service (IFrame or CORS).
- Display all printers installed on the web server and internet-accessed client computers.
Requirements
Running this sample requires the following software to be installed on the server:
- BarTender 2016 or later activated as the Enterprise (or Enterprise Automation) edition.
- Visual Studio 2010 or higher
- Microsoft .NET Framework 4.0
- Internet Information Services (IIS) 7.0 or later
- ASP.NET MVC 4.0
Web Print Service (via IFrame) System Requirements. Clients running the Web Print Service (communication over IFrame) have the following requirements:
- Any Windows Desktop operating system
- Microsoft .NET Framework 4.0
- Browsers: IE8+, Chrome, Firefox. This is the most compatible approach.
Web Print Service (via CORS) System Requirements. Clients running the Web Print Service (communication over CORS) have the following requirements:
- Any Windows Desktop operating system
- Microsoft .NET Framework 4.0
- Browsers: IE10+, Chrome, Firefox. This is a much simpler and standards-compliant way of communicating with cross-domain web services, but it is not compatible with older versions of IE.
Java Applet system requirements Clients running the Java applet have the following system requirements:
- Any desktop operating system (Windows, Mac, Linux). Mobile operating systems are unable to run the Java applet.
- Any web browser capable of running Java applets.
- This is the most broadly compatible approach to client printing, but it lacks many features and performance compared to the Web Printing Service.
Installation/Setup
Installing the BarTender .NET SDK
In order to access the BarTender .NET SDK and source files for our examples, you will need to install the BarTender .NET SDK component otherwise you will not see any of the BarTender .net SDK help documentation or examples.
During the installation of BarTender, make sure you select the BarTender .NET SDK component to install. If you do not see any of the BarTender .NET SDK help documentation or examples, you will need to modify the installation of BarTender to install the BarTender .NET SDK. To do this, go to the Windows Control Panel->Programs and Features->right click on BarTender->click change->the install wizard should come up to allow you modify the installation and install the BarTender .NET SDK.
Files to Use
The source files are located in the SDK folder of the main BarTender Suite installation directory.
The default path should be: C:\Program Files\Seagull\BarTender Suite\SDK\Print Server API Samples\WebLabelPrint or C:\Program Files(x86)\Seagull\BarTender Suite\SDK\Print Server API Samples\WebLabelPrint depending if you are using 32 bit or 64 bit BarTender.
This directory will contain items named WebLabelPrint_CS for C# and WebLabelPrint_VB for Visual Basic .NET source files.
Most of the code can be found on these three Solution Explorer folders:
As part of the example, it contains the full source code and solution files in C# and Visual Basic .NET that can be used and modified with Visual Studio.
Using the Example in Visual Studio
This example comes with the full source code and solution file that you can open in Visual Studio to modify.
In the directory where the example source files are located, you can see the solution file (.sln) that you can open in Visual Studio.
When you are running this example in Visual Studio, you want to ensure the following:
- If you are using 64 bit version of BarTender, make sure that you set Visual Studio to use the 64 bit version of IIS Express. You can usually set this by going to tools->options->projects and solutions->web projects->enable the option for “Use the 64 bit version of IIS Express for web sites and projects” (This may vary depending on the version of Visual Studio you use).
- You are compiling your application as version .NET 4 Framework and as the appropriate 32 bit or 64 bit version depending on the version BarTender you are using.
Setting up the Web Label Print Sample in Internet Information Services (IIS)
- Make sure you have Windows Internet Information Services (IIS) installed. You can install this via the Windows Control Panel->Programs and Features->clicking on the option “Turn Windows features on or off”. If running a Windows Server operating system, you will have to install it via the Server Manager.
- Copy the WebLabelPrint source folder (WebLabelPrint_CS or WebLabelPrint_VB) from where the Web Label Print example is located to the directory where your IIS web applications will be running from (The default directory is: C:\inetpub\wwwroot).
- Open Internet Information Services (IIS).
- Create an application pool
- On the left pane, right click on “Application Pools”
- Click add application pool
- Give it a name
- Make sure you select .NET framework version 4, managed pipeline mode is set to “Integrated”, “start application pool immediately” is checked, and click ok.
- Right click on the app pool you created and go to advanced settings.
- You want to make sure that “Enable 32-bit Application” setting is set for the correct bit version of BarTender you are using.
- Also the “Identity” is set to a user account with appropriate permissions. The user account usually is a local admin account that has access to run BarTender and related resources such as printers and file locations being accessed.
- On the left panel, expand sites and default web site. You should see a folder appear on the list corresponding to the WebLabelPrint folder copied from previous step.
- Right click on it and click “Convert to Application”
- Make sure the application pool is set the one you created. If not, click the select button and choose the correct application pool.
- The web application should now be setup in IIS. To launch the website, you can right click on the web application from the left pane->go to manage application->browse.
- Create an application pool
Printer Configuration and Printing Methods
There are two main methods for web based printing that we call Standard Printing and Internet Printing. Standard Printing refers to printing to printers installed locally on the web server and Internet Printing refers to printing to remote printers connected to remote client computers.
For Standard Printing, the configuration of the printers is simple. You will just need to install the printer drivers locally on the web server where BarTender is running. The web application simply accesses the locally installed printers on the web server to print.
However, for Internet Printing, there are some additional requirements and configuration
- Internet Printing relies on the use of either the BarTender Web Print Service or Java Applet plugin depending on the client system to allow communication between the web server and client computer. They are initially installed when a client first accesses the web site.
- The BarTender Web Print Service is just a Windows web service that is installed on the client. The ideal use is for clients running Windows Operating systems. For other types of client operating systems (such as Mac OSX and Linux), the Java Applet web browser plugin will be used.
- Internet Printing also requires that a printer driver be installed on the client computer and also a compatible printer driver be installed on the web server where BarTender is running.
The following is the general process of how Internet Printing works:
- From a web application on a server, a user selects the option to print.
- The web application prompts for the user to select and/or specify a remote printer.
- The web application acquires a print license from the client running the BarTender Web Print Service or Java Applet web browser plugin.
- Using the print license, the web application prints the document to a file.
- The contents of the print code file are sent from the server application to the client computer.
- Using client-side scripts or a custom application, the client sends the print code to the local Windows spooler for printing using the BarTender Web Print Service or Java Applet web browser plugin.
These client components can be found on the following Windows folder (if you've installed the .NET SDK component as part of BarTender's installation):
"C:\Program Files\Seagull\BarTender Suite\SDK\Print Server API Samples\WebLabelPrint\WebLabelPrint_VB\Content\ClientComponents"
So, either you can install a Java based applet (BarTenderPrintClient.jar) or a Windows Service (BarTenderWebPrintService.exe). When working on a Windows OS, the second approach is recommended.
Internal Only Information
- The use of the "BarTenderPrintClient.dll" has been deprecated in BarTender v2016. Use one of the other internet printing methods instead.
- In order to make use of these printing methods, the Enterprise Automation Edition of BarTender is required.
-
You can find more documentation about the BarTender .NET SDK in our BarTender help. It can be accessed in BarTender by going under help->BarTender help. You want look under Automating BarTender->Automation with the BarTender .NET SDK-> Print Engine API and Print Server API.
-
Be aware, the documentation for the BarTender Web Print Service and Java Applet has not been added into our Bartender help yet. However, the source code of this example should contain helpful inline comments.