码迷,mamicode.com
首页 > 其他好文 > 详细

Automatic Conversion from PowerPoint to JPEG

时间:2014-11-30 20:14:29      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:des   style   io   ar   color   os   sp   for   on   

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

标签:des   style   io   ar   color   os   sp   for   on   

原文地址:http://my.oschina.net/leon0407/blog/350544

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!