| Using the easyPDF Objects |
All of BCL's COM Objects can be accessed from a variety of programming environments. This section shows the basics of COM Objects and how to access them. If you are already familiar with using COM Objects, skip to Sample Code to get started right away.
This example shows how to access a COM Object from Visual C# and Visual Basic .NET.

| using
BCL.easyPDF.Interop.EasyPDFPrinter; // ... Printer oPrinter = null; PrintJob oPrintJob = null; try { Type type = Type.GetTypeFromProgID("easyPDF.Printer.5"); oPrinter = (Printer)Activator.CreateInstance(type); oPrintJob = oPrinter.PrintJob; oPrintJob.PrintOut(inFileName, outFileName); } catch(System.Runtime.InteropServices.COMException err) { // ... } |
| Imports
BCL.easyPDF.Interop.EasyPDFPrinter ' ... Dim oPrinter As Printer = Nothing Dim oPrintJob As PrintJob = Nothing Try oPrinter = CreateObject("easyPDF.Printer.5") oPrintJob = oPrinter.PrintJob oPrintJob.PrintOut(inFileName, outFileName) Catch ex As System.Runtime.InteropServices.COMException ' ... End Try |
This example shows how to access a COM Object from Visual Basic.

| Sub
Convert(inFileName As String, outFileName As String) Dim oPrinter As EasyPDFPrinter.Printer Dim oPrintJob as EasyPDFPrinter.PrintJob On Error GoTo Convert_Error Set oPrinter = CreateObject("easyPDF.Printer.5") Set oPrinjob = oPrinter.PrintJob Call oPrintJob.PrintOut(inFileName, outFileName) Exit Sub Convert_Error: ' ... End Sub |
This example shows how to access a COM Object from Visual C++.
| #import "C:\Program Files\Common Files\BCL Technologies\easyPDF 5\bepprint.dll" |
| HRESULT
hr = CoInitialize(NULL); if(FAILED(hr)) { // failed. // ... } |
| EasyPDFPrinter::IPrinterPtr pPrinter =
NULL; EasyPDFPrinter::IPrintJobPtr pPrintJob = NULL; try { pPrinter.CreateInstance(_T("easyPDF.Printer.5")); pPrintJob = pPrinter->GetPrintJob(); pPrintJob->PrintOut(lpInFileName, lpOutFileName); } catch(_com_error &e) { // ... } |
| //
IMPORTANT: // Make sure to free all COM objects before calling // CoUninitialize(), or you'll get an exception. pPrinter = NULL; pPrintJob = NULL; CoUninitialize(); |
This example shows how to access a COM Object from Windows Scripting Host.
| <?xml version="1.0"
encoding="UTF-8" standalone="yes" ?> <package> <job id="demo"> <?job error="true" debug="true" ?> <object id="PrinterSDK" progid="easyPDF.Printer.5" reference="true" /> <script language="VBScript"> <![CDATA[ Set oPrinter = CreateObject("easyPDF.Printer.5") Set oPrinjob = oPrinter.PrintJob Call oPrintJob.PrintOut(inFileName, outFileName) ]]> </script> </job> </package> |