BCL easyPDF SDK
easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

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 easyPDF SDK 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.

COM Objects

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.

VBScript Example:

Set oLoader = Server.CreateObject("easyPDF.Loader.8")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.8")
oPrinter.PrintJob.PrintOut InputFileName, OutputFileName

C# COM Interop Example:

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

Error Codes for COM: ldrResult Enumeration

LDR_R_UNKNOWN = 0x8004FFFF

Unknown error

LDR_R_INTERNAL = 0x80050000

Internal error

LDR_R_INVALID_PARAM = 0x80050001

Invalid parameter(s)

LDR_R_SETUP_INVALID = 0x80050002

This product is not setup correctly

LDR_R_LICENSE_INVALID = 0x80050003

Invalid license key

LDR_R_LICENSE_EXPIRED = 0x80050004

License key expired

LDR_R_OUT_OF_MEMORY = 0x80050005

Not enough memory to continue

LDR_R_FEATURE_NOT_ENABLED = 0x80050006

The Loader feature is not enabled with the supplied license key

LDR_R_SUCCESS = 0

Success

Native .NET API

Loader is completely automatic, and you are not required to write any special code to use it:

using(Printer printer = new Printer())
{
   printer.PrintJob.PrintOut(inputFileName, outputFileName);
}

The native .NET API automatically determines whether Loader is required under the current circumstances. Loader is always needed for Printer when the customer's application is running under a system service or a web server (the Window Station 0, aka "WinSta0"). Otherwise Loader is not used by default.

Some users might want to force Loader, even if it is not required. This is mainly done for testing purposes, or to gain permission to special directories.

Forcing Loader is very simple, but it needs to be done as first thing, immediately after the Printer object is created:

using(Printer printer = new Printer())
{
   printer.LoaderSettings.ForceUseLoader = true; // use Loader even on the desktop
   printer.PrintJob.PrintOut(@"c:\temp\input.doc", @"c:\temp\output.pdf");
}

If you do anything at all with the Printer object, changing LoaderSettings has no effect whatsoever anymore. That also means you can't change LoaderSettings in the middle. LoaderSettings should be treated as if it were part of the constructor.

By default, Printer automatically starts the Loader service if it is needed and not yet running. This is only possible if the current process has enough permission to start a service. If Loader is needed but cannot be started, an exception is thrown.

If you choose not to start the service automatically, you can disable it:

using(Printer printer = new Printer())
{
   printer.LoaderSettings.AutoStartLoader = false; // do not auto-start the service; it must be running already
   printer.PrintJob.PrintOut(@"c:\temp\input.doc", @"c:\temp\output.pdf");
}

However, if Loader is required or requested and it is not running, Printer will fail with an exception.

Native Java API

The native Java API cannot detect whether the Loader Service is necessary or not, therefore it assumes it is needed for Printer, and not needed for the other SDKs.

Desktop users, on the other hand, are not required to use Loader, and therefore they can turn it off with a single line of code, which must be done immediately after the Printer object is created:

Printer printer = new Printer();
printer.useLoader = false; // on the desktop, there is no need for Loader; on a server, this must be true
try
{
   PrintJob printJob = printer.getPrintJob();
   printJob.PrintOut("c:\\test\\input.docx", "c:\\test\\output.pdf");
}
catch(PrinterException e)
{
   System.out.println(e);
}
finally
{
   printer.dispose();
}

If you do anything at all with the Printer object, changing useLoader has no effect whatsoever anymore. That also means you can't change useLoader in the middle. useLoader should be treated as if it were part of the constructor.

Only Printer needs the Loader Service. However, some users might want to force Loader for other objects, such as PDFProcessor, even if it is not required. This is mainly done for testing purposes, or to gain permission to special directories. Forcing the use of the Loader Service can be done by settings useLoader = true.

For Printer, useLoader defaults to true. For all other SDKs, useLoader defaults to false.

In Java, easyPDF SDK cannot automatically start the Loader Service. Therefore it is imperative that you change the Loader Service settings from Manual to Automatic and make sure it is always running.

If Loader is required or requested but not running, easyPDF will fail with an exception.