Convert PDF to Microsoft PowerPoint in C++

Overview

This article explains how to convert PDF to PowerPoint formats using C++. It covers the following topics.

Format: PPTX

Format: Microsoft PowerPoint PPTX format

Other topics covered by this article.

C++ PDF to PowerPoint Conversions

Aspose.PDF for C++ lets you track the progress of PDF to PPTX conversion.

During PDF to PPTX conversion, the text is rendered as Text where you can select/update it. Please note that in order to convert PDF files to PPTX format, Aspose.PDF provides a class named PptxSaveOptions. An object of the PptxSaveOptions class is passed as a second argument to the Document.Save(..) method method. The following code snippet shows the process for converting PDF files into PPTX format.

Simple conversion PDF to PPTX with Aspose.PDF for C++

In order to convert PDF to PPTX, Aspose.PDF for C++ advice to use the following code steps.

Steps: Convert PDF to PPTX in C++ | Steps: Convert PDF to PowerPoint PPTX format in C++

  1. Create an instance of Document class.
  2. Create an instance of PptxSaveOptions class.
  3. Use the Save method of the Document object to save the PDF as PPTX.
void ConvertPDFtoPPTX()
{
    std::clog << __func__ << ": Start" << std::endl;
    // String for path name
    String _dataDir("C:\\Samples\\Conversion\\");

    // String for file name
    String infilename("JSON Fundamenals.pdf");
    String outfilename("JSON Fundamenals.pptx");

    // Open document
    auto document = MakeObject<Document>(_dataDir + infilename);

    // Save the output in PPTX format
    document->Save(_dataDir + outfilename, SaveFormat::Pptx);
    std::clog << __func__ << ": Finish" << std::endl;
}

Convert PDF to PPTX with Slides as Images

In case if you need to convert a searchable PDF to PPTX as images instead of selectable text, Aspose.PDF provides such a feature via Aspose.Pdf.PptxSaveOptions class. To achieve this, set property SlidesAsImages of PptxSaveOptios class to ’true’ as shown in the following code sample.

void ConvertPDFtoPPTX_SlidesAsImages()
{
    std::clog << __func__ << ": Start" << std::endl;
    // String for path name
    String _dataDir("C:\\Samples\\Conversion\\");

    // String for file name
    String infilename("JSON Fundamenals.pdf");
    String outfilename("JSON Fundamenals.pptx");

    // Open document
    auto document = MakeObject<Document>(_dataDir + infilename);

    auto pptxOptions = MakeObject<PptxSaveOptions>();
    pptxOptions->set_SlidesAsImages(true);

    // Save the output in PPTX format
    document->Save(_dataDir + outfilename, pptxOptions);
    std::clog << __func__ << ": Finish" << std::endl;
}

Progress Detail of PPTX Conversion

Aspose.PDF for C++ lets you track the progress of PDF to PPTX conversion. The Aspose.Pdf.PptxSaveOptions class provides CustomProgressHandler property that can be specified to a custom method for tracking the progress of conversion as shown in the following code sample.

void ConvertPDFtoPPTX_ProgressDetailConversion()
{
    std::clog << __func__ << ": Start" << std::endl;
    // String for path name
    String _dataDir("C:\\Samples\\Conversion\\");

    // String for file name
    String infilename("JSON Fundamenals.pdf");
    String outfilename("JSON Fundamenals.pptx");

    // Open document
    auto document = MakeObject<Document>(_dataDir + infilename);

    auto pptxOptions = MakeObject<PptxSaveOptions>();
    //pptxOptions->set_SlidesAsImages(true);
    //Specify Custom Progress Handler
    pptxOptions->set_CustomProgressHandler(ShowProgressOnConsole);

    // Save the output in PPTX format
    document->Save(_dataDir + outfilename, pptxOptions);
    std::clog << __func__ << ": Finish" << std::endl;
}

Following is the custom method for displaying progress conversion.

void ShowProgressOnConsole(SharedPtr<UnifiedSaveOptions::ProgressEventHandlerInfo> eventInfo)
{
    switch (eventInfo->EventType)
    {
    case ProgressEventType::TotalProgress:
    std::clog << DateTime::get_Now().get_TimeOfDay() << " - Conversion progress : " << eventInfo->Value << std::endl;
    break;
    case ProgressEventType::ResultPageCreated:
    std::clog << DateTime::get_Now().get_TimeOfDay() << " - Result page's " << eventInfo->Value << " of " << eventInfo->MaxValue << " layout created." << std::endl;
    break;
    case ProgressEventType::ResultPageSaved:
    std::clog << DateTime::get_Now().get_TimeOfDay() << " - Result page's " << eventInfo->Value << " of " << eventInfo->MaxValue << " exported." << std::endl;
    break;
    case ProgressEventType::SourcePageAnalysed:
    std::clog << DateTime::get_Now().get_TimeOfDay() << " - Source page " << eventInfo->Value << " of " << eventInfo->MaxValue << " analyzed." << std::endl;
    break;
    default:
    break;
    }
}

See Also

This article also covers these topics. The codes are same as above.

Format: PowerPoint

Format: Microsoft PowerPoint PPTX format

Format: PPTX