Universal Document Converter
製品の概要
ダウンロード
ご購入
チュートリアル
開発者の方へ
サポートサービス
fCoder SIAについて


      サイト検索
   


      Video tutorial
Show tutorial



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

Converting Visio Diagrams to TIFF


//////////////////////////////////////////////////////////////////////////////////////////////////// // 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. Add references to "Microsoft Visio XX.0 Object Library" and "Universal Document Converter Type Library" using // the Project | Add Reference menu > COM tab. // XX is the Microsoft Office version installed on your computer. //////////////////////////////////////////////////////////////////////////////////////////////////// using System; using System.IO; using UDC; using Visio = Microsoft.Office.Interop.Visio; namespace VisioToTIFF { class Program { static void PrintVisioToTIFF(string VisioFilePath) { //Create a UDC object and get its interfaces IUDC objUDC = new APIWrapper(); IUDCPrinter Printer = objUDC.get_Printers("Universal Document Converter"); IProfile Profile = Printer.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 Environment.GetFolderPath method. //Or you can move default profiles into a folder you prefer. string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string ProfilePath = Path.Combine(AppDataPath, @"UDC Profiles\Drawing to TIFF.xml"); Profile.Load(ProfilePath); Profile.OutputLocation.Mode = LocationModeID.LM_PREDEFINED; Profile.OutputLocation.FolderPath = @"c:\UDC Output Files"; Profile.PostProcessing.Mode = PostProcessingModeID.PP_OPEN_FOLDER; //Run Microsoft Visio as COM-server Visio.Application VisioApp = new Visio.ApplicationClass(); VisioApp.Visible = true; //Open document from file short Flags = (short)(Visio.VisOpenSaveArgs.visOpenRW | Visio.VisOpenSaveArgs.visOpenDontList | Visio.VisOpenSaveArgs.visOpenMacrosDisabled | Visio.VisOpenSaveArgs.visOpenHidden); Visio.Document Document = VisioApp.Documents.OpenEx(VisioFilePath, Flags); //Change document preferences for scaling it to page Document.PrintCenteredH = true; Document.PrintCenteredV = true; Document.PrintFitOnPages = true; //Print document Document.Printer = "Universal Document Converter"; Document.Print(); //Close document Document.Saved = true; Document.Close(); //Close Visio VisioApp.Quit(); } static void Main(string[] args) { string TestFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.vsd"); PrintVisioToTIFF(TestFilePath); } } }


© fCoder SIA fCoder SIAについて | サイトマップ