首页 > 代码库 > Automatic Conversion from PowerPoint to JPEG
Automatic Conversion from PowerPoint to JPEG
Universal Document Converter works as a virtual printer and can save any document in the PDF, JPEG, TIFF, or PNG format. If you are a software developer, you can control the settings using COM-interface and using Microsoft PowerPoint as COM-server for converting your presentations to the JPEG format.
PowerPoint presentation conversion source code examples:
////////////////////////////////////////////////////////////////// // This example was designed to be used in Microsoft Visual C++ starting // from Microsoft Visual Studio 2003 or higher. // // 1. Microsoft PowerPoint 97 or higher should be installed and activated on your PC. // // 2. Universal Document Converter 5.2 or higher should be installed as well. // // 3. You should initialize the COM before calling any COM method. // Please insert ::CoInitialize(0); in your application initialization // and ::CoUninitialize(); before closing it. // // 4. Import Office libraries 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 MSO.DLL") // MS Office 2000 -> // "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE10\\MSO.DLL" // // MS Office 2003 -> // "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE11\\MSO.DLL" // // MS Office 2007 -> // "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" #import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" rename_namespace("MSO"), auto_rename #pragma message("Import VBE6EXT.OLB") #import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB" rename_namespace("VBE6EXT") #pragma message("Import MS Powerpoint API") // MS Office 2000 -> "C:\\Program Files\\Microsoft Office\\OFFICE\\MSPPT9.OLB" // MS Office 2003 -> "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSPPT.OLB" // MS Office 2007 -> "C:\\Program Files\\Microsoft Office\\OFFICE12\\MSPPT.OLB" #import "C:\\Program Files\\Microsoft Office\\OFFICE12\\MSPPT.OLB" rename_namespace("POWERPNT"), auto_rename // 5. Import Universal Document Converter software API: #import "progid:udc.apiwrapper" rename_namespace("UDC") ////////////////////////////////////////////////////////////////// void PrintPowerPointToJPEG( CString sFilePath ) { 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 itfProfile->PageSetup->Orientation = UDC::PO_LANDSCAPE; itfProfile->FileFormat->ActualFormat = UDC::FMT_JPEG; itfProfile->FileFormat->JPEG->ColorSpace = UDC::CS_TRUECOLOR; itfProfile->OutputLocation->Mode = UDC::LM_PREDEFINED; itfProfile->OutputLocation->FolderPath = L"C:\\Out"; itfProfile->OutputLocation->FileName = L"&[DocName(0)].&[ImageType]"; itfProfile->OutputLocation->OverwriteExistingFile = FALSE; itfProfile->PostProcessing->Mode = UDC::PP_OPEN_FOLDER;// Run Microsoft Excel as COM-server POWERPNT::_ApplicationPtr objPPTApp(L"PowerPoint.Application"); POWERPNT::_PresentationPtr itfPresentation; POWERPNT::PrintOptionsPtr itfPrintOptions;// Open document from file itfPresentation = objPPTApp->Presentations->Open( (LPCTSTR)sFilePath, MSO::msoTrue, MSO::msoTrue, MSO::msoFalse );// Print all slides from the presentation itfPrintOptions = itfPresentation->PrintOptions; itfPrintOptions->put_PrintInBackground( MSO::msoFalse ); itfPrintOptions->ActivePrinter = "Universal Document Converter"; itfPresentation->PrintOut( 0, itfPresentation->Slides->Count, _T(""), 1, MSO::msoFalse );// Close the presentation itfPresentation->Close();// Close Microsoft PowerPoint objPPTApp->Quit(); }
Automatic Conversion from PowerPoint to JPEG
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。