Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder Group


      Site search
   


      Video tutorial
Show tutorial



Main page>Developer Solutions>COM Examples

Get List of Available Page Formats Using Visual C++ 6.0


Universal Document Converter is virtual printer software that saves any document you print as an image file. Below is a source code example that can help you to accomplish your task with Universal Document Converter. Please let us know if you cannot find the solution you need.

// 1) Install Universal Document Converter 3.0 or above on your PC
//
// 2) Open your project in Microsoft Visual C++ 6.0
//
// 3) Press "Ctrl+W" in Visual C++ to open ClassWizard
//
// 4) In ClassWizard window press "Add Class->From a type library"
//    button and select "UDCWrapper.dll" file. By default this file
//    should be in folder:
//    "C:\Program Files\Universal Document Converter\SDK\bin"
//
// 5) Save files "udcwrapper.h" and "udcwrapper.cpp" and add into
//    your "stdafx.h" file this include: #include "udcwrapper.h"
//
// 6) You must initialize the COM before you call any COM method.
//    Please call "::CoInitialize(0);" before using COM and
//    ::CoUninitialize(); after using COM.
//
// Universal Document Converter COM interface is ready to use now!

#include "udcwrapper.h"
#include <atlconv.h>

void GetPageFormatsList()
{
  CString   sMessage, sNumber;
  IPrinter  *pUDC;

  pUDC = new IPrinter;
  pUDC->CreateDispatch("UDCWrapper.Printer");
  pUDC->SetPrinterName("Universal Document Converter");

  IProfile  prof = pUDC->GetProfile( pUDC->GetDefaultProfile() );
  VARIANT   strings = prof.GetPageFormatesList();

  if( ( strings.vt & VT_ARRAY ) && ( strings.vt & VT_BSTR ) )
  {
    USES_CONVERSION;

    SAFEARRAY   *pSA = strings.parray;
    BSTR        *bstrArray;

    SafeArrayAccessData( pSA, (void**)&bstrArray );

    for( DWORD i = 0; i < pSA->rgsabound->cElements; i++ )
    {
      sNumber.Format("%d. ", i + 1);
      sMessage = sMessage + sNumber + W2A( bstrArray[i] ) + "\n";
    }

    SafeArrayUnaccessData( pSA );
  }

  VariantClear( &strings );

  pUDC->ReleaseDispatch();
  delete pUDC;

  MessageBox(0, sMessage, "List of Available Page Formats", MB_OK);
}



Related topics
Popular pages
Popular solutions


© 2001-2012 fCoder Group, Inc. About fCoder Group | Privacy Policy | Site Map