English | 日本
PDF Java
Shopping CartContact Us
Knowledgebase
BCL easy PDF SDK

easy PDF C# API on the Server-Side: When to use the Loader and when to use impersonation on C# .NET API and C# COM Objects? All you need to know!

Background:

Servers and system services do not behave the same way as desktop applications. Services are running under special limited user accounts, and do not have access to the desktop. For example, they cannot open a dialog box, or launch Microsoft Word.

In order to work around these limitations, easy PDF C# API offers two alternative solutions. One is called the Loader Service, and the other one is called Impersonation.

Also it is important to bear in mind that you have the choice of using either the Loader object or on both the Native C# API or C# COM based objects.

Using the Loader Service:

The Loader Service is available from all APIs, including COM, .NET and Java. However, the usage is completely different depending on the programming environment.

Note that the Loader Service is not working properly unless it is configured first. Please read easy PDF API Loader Setup for more information .Loader is not working properly unless a desktop user is assigned to the service, and it is constantly running!

The Loader Service also requires the purchase of a special server license. Without this license server side printing is impossible.

Using the Loader Service:

The alternative solution is to simply impersonate a desktop user when necessary. This brand new technique was introduced in easy PDF SDK 8, and is available for .NET and Java programmers only. Users of the classic COM API have no choice but to use the Loader Service. The basic idea of Impersonation is to launch an external process under a specific user account. Instead of having a central Loader Service that is always running, each SDK object is isolated into a separate worker process. Each worker process quits as soon as they are not used anymore.

A huge advantage of Impersonation over the Loader Service is that multiple different users can be impersonated. For example, you may have a separate user for each web request. Or one dedicated user for each printer paper size. This is the only way to change paper size in a thread safe way. The difficulty of this solution is that the user-name and password must be supplied as parameters by the user of the PDF SDK. It is the developer's burden to hide this information in a secure location. Those who are uneasy about storing clear text passwords in the source code are required to encrypt it. Fortunately,.NET has a built-in solution.

PDF C# Example for COM object and Native .NET API:

If you are using the COM objects, the Loader Service is accessible via the Loader object. This is also true for the .NET COM Interop, as well as the Java COM Bridge:

Loader loader = new Loader();
Printer printer = (Printer)loader.LoadObject("easyPDF.Printer.8");
printer.PrintJob.PrintOut(inputFileName, outputFileName);

For the Native .NET API no special code is required to use the loader as it automatically determines when to use the loader.

PDF C# .NET API Impersonation Example:

The Printer object has a public member variable called

LoaderSettings. This is where the

UserName and Password is specified.

using(Printer printer = new Printer())
{
printer.LoaderSettings.UserName = "easyPDF8User";
printer.LoaderSettings.Password = "Password";
printer.PrintJob.PrintOut(inputFileName, outputFileName);

PDF SDK Knowledgebase
 
BCL
© 1993 - , BCL Technologies.
All other trademarks are the property of their respective owners.