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

Using the easyPDF Objects

Last Updated: 4/16/14

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

COM Objects in Visual C# and Visual Basic .NET

This example shows how to access a COM Object from Visual C# and Visual Basic .NET.

  1. Create a new project. Click Project -> Add References, and select the easyPDF SDK COM Object(s):

    screenshot
  2. Create and use the object.

    Visual C# Code:

    using BCL.easyPDF7.Interop.easyPDFPrinter;

    // ...

    Printer oPrinter = null;
    PrintJob oPrintJob = null;

    try
    {
    Type type = Type.GetTypeFromProgID("easyPDF.Printer.7");
    oPrinter = (Printer)Activator.CreateInstance(type);

    oPrintJob = oPrinter.PrintJob;
    oPrintJob.PrintOut(inFileName, outFileName);
    }
    catch(System.Runtime.InteropServices.COMException err)
    {
    // ...
    }


  3. Visual Basic .NET Code:

    Imports BCL.easyPDF7.Interop.easyPDFPrinter

    ' ...

    Dim oPrinter As Printer = Nothing
    Dim oPrintJob As PrintJob = Nothing

    Try
    oPrinter = CreateObject("easyPDF.Printer.7")

    oPrintJob = oPrinter.PrintJob
    oPrintJob.PrintOut(inFileName, outFileName)
    Catch ex As System.Runtime.InteropServices.COMException
    ' ...
    End Try


COM Objects in Visual Basic

This example shows how to access a COM Object from Visual Basic.

  1. Create a new project. Click Project -> References, and select the easyPDF SDK COM Object(s):

    screenshot
  2. Create and use the object in VB Code:

    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.7")

    Set oPrinjob = oPrinter.PrintJob
    Call oPrintJob.PrintOut(inFileName, outFileName)

    Exit Sub

    Convert_Error:

    ' ...

    End Sub

COM Objects in Visual C++

This example shows how to access a COM Object from Visual C++.

  1. Create a new Visual C++ project.
  2. Import the BCL COM object:

    #import "C:\Program Files\Common Files\BCL Technologies\easyPDF 7\bepprint.dll"
  3. Initialize COM library for use by current apartment:

    HRESULT hr = CoInitialize(NULL);
    if(FAILED(hr))
    {
    // failed.
    // ...
    }

  4. Create and Use the object:

    easyPDFPrinter::IPrinterPtr pPrinter = NULL;
    easyPDFPrinter::IPrintJobPtr pPrintJob = NULL;

    try
    {
    pPrinter.CreateInstance(_T("easyPDF.Printer.7"));

    pPrintJob = pPrinter->GetPrintJob();
    pPrintJob->PrintOut(lpInFileName, lpOutFileName);
    }
    catch(_com_error &e)
    {
    // ...
    }

  5. Close COM library on the current apartment:

    // IMPORTANT:
    // Make sure to free all COM objects before calling
    // CoUninitialize(), or you'll get an exception.

    pPrinter = NULL;
    pPrintJob = NULL;

    CoUninitialize();

COM Objects in Windows Scripting Host

This example shows how to access a COM Object from Windows Scripting Host.

  1. Create a new Windows Scriptiong Host file (extension ".wsf").
  2. Create and use the object:

    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

    <package>
    <job id="demo">
    <?job error="true" debug="true" ?>

    <object id="PrinterSDK" progid="easyPDF.Printer.7" reference="true" />

    <script language="VBScript">
    <![CDATA[

    Set oPrinter = CreateObject("easyPDF.Printer.7")

    Set oPrinjob = oPrinter.PrintJob
    Call oPrintJob.PrintOut(inFileName, outFileName)

    ]]>
    </script>

    </job>
    </package>

 

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