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


      Site search
   


      Popular conversions
PDF to JPG converter
Convert Word to PDF
Convert PDF to TIFF
Autocad to PDF converter
Convert Word to JPG
Powerpoint to PDF converter
Printing to PDF
Convert Excel to PDF
Convert DJVU to PDF
Convert Web Page to PDF

      Video tutorials
Show tutorial



Main page>Developer Solutions>Examples>Visual C++>Visio Diagrams to TIFF

Converting Visio Diagrams to TIFF for Visual C++


//////////////////////////////////////////////////////////////////
// This example was designed for using in Microsoft Visual C++ from 
// Microsoft Visual Studio 2003 or above.
//
// 1. Microsoft Visio 2002 or above should be installed and activated on your PC.
//
// 2. Universal Document Converter 5.2 or above should be installed, too.
//
// 3. You must initialize the COM before you call any COM method.
// Please insert "::CoInitialize(0);" in your application initialization
// and "::CoUninitialize();" before closing it.
//
// 4. Import Visio library for 32-bit version of Windows.
// For 64-bit version please change "C:\\Program Files\\" to
// "C:\\Program Files (x86)\\" in all pathes.

#pragma message("Import MS Visio API")
// MS Visio 2002 -> "C:\\Program Files\\Microsoft Office\\Visio10\\Vislib.dll"
// MS Visio 2003 -> "C:\\Program Files\\Microsoft Office\\Visio11\\VISLIB.DLL"
// MS Visio 2007 -> "C:\\Program Files\\Microsoft Office\\OFFICE12\\VISLIB.DLL"
#import "C:\\Program Files\\Microsoft Office\\OFFICE12\\VISLIB.DLL"\
    rename_namespace("VISIO"), auto_rename
// 5. Import Universal Document Converter software API:
#import "progid:udc.apiwrapper" rename_namespace("UDC")
//////////////////////////////////////////////////////////////////
void PrintVisioToTIFF( CString sFilePath )
{
// Define constants
  const int visOpenDontList = 0x08, visOpenRW = 0x20, visOpenHidden = 64, visOpenMacrosDisabled = 128;
  UDC::IUDCPtr pUDC(__uuidof(UDC::APIWrapper));
  UDC::IUDCPrinterPtr itfPrinter = pUDC->Printers["Universal Document Converter"];
  UDC::IProfilePtr itfProfile = itfPrinter->Profile;
// Use Universal Document Converter API to change settings of converterd document
// Load profile located in folder "%APPDATA%\UDC Profiles".
// Value of %APPDATA% variable should be received using Windows API's SHGetSpecialFolderPath function.
// Or you can move default profiles into a folder you prefer.   
  itfProfile->Load("Drawing to TIFF.xml");
 
  itfProfile->OutputLocation->Mode = UDC::LM_PREDEFINED;
  itfProfile->OutputLocation->FolderPath = L"C:\\Out";
  itfProfile->PostProcessing->Mode = UDC::PP_OPEN_FOLDER;
// Run Microsoft Visio as COM-server
  VISIO::IVApplicationPtr objVisioApp( L"Visio.Application" );
  VISIO::IVDocumentPtr itfDrawing;
  
  objVisioApp->Visible = false;
// Open drawing from file
  itfDrawing = objVisioApp->Documents->OpenEx( (LPCTSTR)sFilePath, visOpenRW | visOpenDontList | visOpenMacrosDisabled | visOpenHidden );
// Change Drawing preferences for scaling it to page
  itfDrawing->PrintCenteredH = true;
  itfDrawing->PrintCenteredV = true;
  itfDrawing->PrintFitOnPages = true;
// Print drawing
  itfDrawing->Printer = "Universal Document Converter";
  itfDrawing->Print();
// Close drawing
  itfDrawing->Saved = true;
  itfDrawing->Close();
// Close Microsoft Visio
  objVisioApp->Quit();
}


© fCoder SIA About fCoder SIA | Privacy Policy | Site Map