Universal Document Converter
Informazioni sul prodotto
Scarica
Acquista
Tutorial
Soluzioni per sviluppatori
Servizio di assistenza
Chi è fCoder SIA


      Cerca nel sito
   


      Conversioni più richieste
Da Adobe PDF a JPEG
Da documento Word a PDF
Da foglio di lavoro Excel a PDF
Da PowerPoint a JPEG
Da disegno Visio a PDF
Da disegno AutoCAD a TIFF
Da pagina Web a JPEG
Convertire di lavoro Excel in PDF
Convertire da DjVu in PDF
Pagine Web in PDF



Pagina principale>Developer Solutions>Examples>Visual C++>PowerPoint Presentations to JPEG

Converting PowerPoint Presentations to JPEG


//////////////////////////////////////////////////////////////////
// This example was designed for using in Microsoft Visual C++ from 
// Microsoft Visual Studio 2003 or above.
//
// 1. Microsoft PowerPoint 97 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 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)] -- &[Date(0)] -- &[Time(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();
}


© fCoder SIA Chi è fCoder SIA | Mappa del sito