C++ Tutorial: Convert PowerPoint to OFD Format Efficiently

Page Content:
- Differences between PowerPoint and OFD Format
- How to Convert PowerPoint to OFD with Spire.Presentation for C++
- Batch Convert PowerPoint Files into OFD Format with C++
- Convert a Single Slide of PowerPoint to OFD with C++
- FAQs
PowerPoint presentations are widely used for business reports and technical documentation. In some industries, especially in government and enterprise systems, documents are often required to be distributed in OFD instead of standard Office formats. Because PowerPoint files can include complex layouts and interactive elements, they are not always suitable for standardized document distribution.
In this tutorial, you will learn how to convert PowerPoint to OFD in C++ using Spire.Presentation for C++. The guide walks through simple code examples for converting an entire .ppt/.pptx file, exporting a single slide, and performing batch PPT to OFD conversion for multiple files.
Differences between PowerPoint and OFD Format
Before implementing the conversion, it helps to first understand the key differences between PowerPoint and OFD formats. Each format is designed for a different purpose and usage scenario, which is why some organizations require documents to be converted before distribution. Knowing these differences can make it clearer why converting PowerPoint to OFD is often necessary in enterprise or government document workflows.
1. File Structure and Purpose
PowerPoint files (PPT/PPTX) are designed for interactive presentations and support animations, transitions, embedded media, and editable slide elements.
OFD, in contrast, is a fixed layout document format like PDF, designed to preserve the exact visual layout of a document across different systems. Because of this, OFD is commonly used for official document distribution and long-term digital archiving.
OFD, in contrast, is a fixed layout document format like PDF, designed to preserve the exact visual layout of a document across different systems. Because of this, OFD is commonly used for official document distribution and long-term digital archiving, similar to scenarios where organizations convert PowerPoint to PDF to ensure consistent document formatting.
2. Compatibility and Standardization
PowerPoint belongs to the Microsoft Office ecosystem and typically requires compatible presentation software to view or edit.
OFD is an open national standard created for electronic document exchange, allowing organizations to share and store documents with consistent formatting regardless of the software environment.
3. Security and Compliance
In many enterprise and government workflows, documents must follow standardized formats to meet regulatory requirements. OFD supports features such as digital signatures, fixed layout rendering, and secure document exchange, making it suitable for compliant document distribution.
How to Convert PowerPoint to OFD with Spire.Presentation for C++
Understanding the differences between PowerPoint and OFD is the first step in ensuring documents are properly formatted for distribution. OFD’s fixed layout and standardized features make it ideal for official and long-term archival use.
To handle the conversion in C++, Spire.Presentation for C++ provides a simple and reliable solution. It lets developers load, edit, and export PowerPoint files to OFD while preserving the original layout and content. It also supports other tasks such as editing slides, extracting images, and converting PowerPoint files to images and other formats.
Read on to learn how to use Spire.Presentation for C++ to convert PowerPoint to OFD format.
Install Spire.Presentation for C++:
Before using the sample code in Visual Studio, make sure to add the library to your C++ project. You can either download it from the official download link and add it to your project manually, or install it automatically via NuGet.
For a more detailed tutorial on how to integrate Spire.Presentation for C++, see: How to Integrate Spire.Presentation for C++ in a C++ Application.
PowerPoint to OFD Conversion Workflow:
- Specify the input and output file paths.
- Create a Presentation object.
- Load the PowerPoint file using Presentation.LoadFromFile(String).
- Save the presentation as an OFD file using Presentation.SaveToFile(String, FileFormat).
- Dispose of the Presentation object to release resources.
Sample Code:
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
// Specify the input and output file paths
std::wstring inputFile = L"powerpoint-sample.pptx";
std::wstring outputFile = L"output\\PowerPointToOFD.ofd";
// Create a Presentation object
intrusive_ptr<Presentation> presentation = new Presentation();
// Load a PowerPoint document from disk
presentation->LoadFromFile(inputFile.c_str());
// Save the document to OFD format
presentation->SaveToFile(outputFile.c_str(), FileFormat::OFD);
presentation->Dispose();
}
Conversion Result:

Note: If you want to remove the evaluation warning message of the converted OFD file or gain full access to all features of Spire.Presentation for C++, please contact us to request a 30-day trial license.
Batch Convert PowerPoint Files into OFD Format with C++
In real-world development scenarios, developers often need to process multiple PowerPoint files at once rather than converting them individually. For example, a document management system may need to convert a folder of PPT files into OFD format for standardized archiving or distribution.
Using Spire.Presentation for C++, you can easily iterate through a directory, load each PowerPoint file, and export it to OFD format automatically. This approach greatly improves efficiency when handling large numbers of presentations.
Batch PowerPoint to OFD Conversion Workflow
- Specify the input folder containing PowerPoint files and the output folder for the converted OFD files.
- Iterate through all files in the input directory.
- Load each PowerPoint file using the Presentation object.
- Generate a corresponding OFD output file path.
- Save the presentation as an OFD file.
- Dispose of the Presentation object to release resources.
Sample Code:
#include "Spire.Presentation.o.h"
#include <filesystem>
using namespace Spire::Presentation;
using namespace std;
namespace fs = std::filesystem;
int main()
{
// Specify folder paths
wstring inputFolder = L"InputPPT";
wstring outputFolder = L"batchoutputOFD";
for (auto& file : fs::directory_iterator(inputFolder))
{
if (file.path().extension() == L".pptx")
{
intrusive_ptr<Presentation> presentation = new Presentation();
// Load PowerPoint file
presentation->LoadFromFile(file.path().wstring().c_str());
// Generate output OFD file path
wstring outputFile = outputFolder + L"\\" + file.path().stem().wstring() + L".ofd";
// Convert to OFD
presentation->SaveToFile(outputFile.c_str(), FileFormat::OFD);
presentation->Dispose();
}
}
return 0;
}
Convert a Single Slide of PowerPoint to OFD with C++
In some scenarios, developers may only need to export selected slides instead of converting the entire presentation. For example, a reporting system may generate an OFD document from only a few important slides in a PowerPoint file.
Using Spire.Presentation, you can create a new presentation, copy the required slides from the original PowerPoint file, and then export them to OFD format.
Single Slide to OFD Conversion Workflow
- Load the source PowerPoint file.
- Create a new Presentation object.
- Copy the required slides from the original presentation to the new presentation.
- Save the new presentation as an OFD file.
- Dispose of the Presentation objects to release resources.
Note: In Spire.Presentation, slide indexing starts from 0, so index 4 refers to the fifth slide in the presentation.
Sample Code:
#include "Spire.Presentation.o.h"
using namespace Spire::Presentation;
using namespace std;
int main()
{
// Specify input and output paths
wstring inputFile = L"Input.pptx";
wstring outputFile = L"SingleSlide.ofd";
// Load the source presentation
intrusive_ptr<Presentation> presentation = new Presentation();
presentation->LoadFromFile(inputFile.c_str());
// Create a new presentation
intrusive_ptr<Presentation> newPresentation = new Presentation();
// Get the specific slide (for example: slide 5)
intrusive_ptr<ISlide> slide = presentation->GetSlides()->GetItem(4);
// Add the slide to the new presentation
newPresentation->GetSlides()->Append(slide);
// Save the slide as OFD
newPresentation->SaveToFile(outputFile.c_str(), FileFormat::OFD);
// Release resources
presentation->Dispose();
newPresentation->Dispose();
return 0;
}
RESULT:

FAQs
1. Can I export PowerPoint files directly to OFD format with Microsoft PowerPoint?
No. Microsoft PowerPoint does not provide built-in support for exporting presentations to OFD format. Developers usually rely on document processing libraries or third-party tools to perform this conversion programmatically.
2. Why convert PowerPoint to OFD instead of PDF?
While PDF is widely used, some government and industry platforms specifically require OFD because it is a national standard document format designed for secure and long-term document storage.
3. Does Spire.Presentation require Microsoft Office?
No. Spire.Presentation for C++ is a standalone library that does not require Microsoft PowerPoint to be installed.
4. Can I convert multiple PowerPoint files to OFD at once?
Yes. By looping through multiple files in a directory and applying the same conversion method, you can easily build a batch conversion tool in C++ with Spire.Presentation.
Wrap-Up
In this tutorial, we showed how to perform PowerPoint to OFD conversion in C++ using Spire.Presentation for C++. With just a few lines of code, developers can load PPT or PPTX files and export them to OFD while preserving the original layout.
We also covered scenarios such as converting an entire presentation, exporting a single slide, and performing batch PPT to OFD conversion, making it easier to integrate this feature into automated workflows or enterprise systems. Download Spire.Presentation for C++ to try these examples and start converting PowerPoint files to OFD in your C++ applications.
C++: Convert PowerPoint to XPS
PowerPoint is a popular format used to create presentations, training materials, business reports, etc. However, it has certain disadvantages, such as not being secure enough or having possible compatibility issues on different devices/software. While XPS, also known as XML Paper Specification, is a more secure and compatible file format suitable for high quality printing and fast transfer. As a result, there are many people who may choose to convert their PowerPoint files to XPS format. In this article, you will learn how to programmatically convert a PowerPoint Presentation to XPS using Spire.Presentation for C++.
Install Spire.Presentation for C++
There are two ways to integrate Spire.Presentation for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.
Integrate Spire.Presentation for C++ in a C++ Application
Convert PowerPoint to XPS in C++
It's fairly simple to convert a PowerPoint presentation to an XPS file using Spire.Presentation for C++. You just need to load a sample PowerPoint document and then save it as XPS format using Workbook->SaveToFile(LPCWSTR_S fileName, FileFormat::XPS) method. The following are the detailed steps.
- Create a Presentation instance.
- Load a PowerPoint document using Presentation->LoadFromFile() method.
- Save the document to an XPS file using Presentation->SaveToFile(LPCWSTR_S fileName, FileFormat::XPS) method.
- C++
#include "Spire.Presentation.o.h"
using namespace std;
using namespace Spire::Presentation;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"Data\\input.pptx";
std::wstring outputFile = L"ToXPS.xps";
//Create a Presentation instance
intrusive_ptr<Presentation> presentation = new Presentation();
//Load a sample PowerPoint document
presentation->LoadFromFile(inputFile.c_str());
//Save the document as an XPS file
presentation->SaveToFile(outputFile.c_str(), FileFormat::XPS);
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
C++: Add, Read or Delete Speaker Notes in PowerPoint
Speaker notes are hidden notes that can be added to slides to help recall some important or key information. Speaker notes are only visible to the presenter, so adding speaker notes in PowerPoint will not affect the overall visual effectiveness of the document. In this article, you will learn how to programmatically add, read or delete speaker notes in a PowerPoint presentation using Spire.Presentation for C++.
- Add Speaker Notes in PowerPoint in C++
- Read Speaker Notes in PowerPoint in C++
- Delete Speaker Notes in PowerPoint in C++
Install Spire.Presentation for C++
There are two ways to integrate Spire.Presentation for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.
Integrate Spire.Presentation for C++ in a C++ Application
Add Speaker Notes in PowerPoint in C++
There are a number of benefits to using speaker notes in a PowerPoint presentation, such as it can help you stay on point and also appear more confident during a presentation. The following are the steps to add speaker notes to a specified slide.
- Create a Presentation instance and load a PowerPoint document using Presentation->LoadFromFile() method.
- Get a specified slide using Presentation->GetSlides()->GetItem(slideIndex) method.
- Add a notes slide to the slide using ISlide->AddNotesSlide() method.
- Create a TextParagraph instance.
- Set text for the paragraph using TextParagraph->SetText() method, and then append the paragraph to the notes slide using NotesSlide->GetNotesTextFrame()->GetParagraphs()->Append() method.
- Save the result document using Presentation->SaveToFile() method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"Data\\Template.pptx";
std::wstring outputFile = L"SpeakerNotes.pptx";
//Create a Presentation instance
intrusive_ptr<Presentation> ppt = new Presentation();
//Load a sample PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Get the second slide
intrusive_ptr<ISlide> slide = ppt->GetSlides()->GetItem(1);
//Add a notes slide
intrusive_ptr<NotesSlide> notesSlide = slide->AddNotesSlide();
//Add paragraphs to the notes slide and set the content of the speaker notes
intrusive_ptrTextParagraph> paragraph = new TextParagraph();
paragraph->SetText(L"Tips for making effective presentations:");
notesSlide->GetNotesTextFrame()->GetParagraphs()->Append(paragraph);
paragraph = new TextParagraph();
paragraph->SetText(L"Use the slide master feature to create a consistent and simple design template.");
notesSlide->GetNotesTextFrame()->GetParagraphs()->Append(paragraph);
paragraph = new TextParagraph();
paragraph->SetText(L"Simplify and limit the number of words on each screen.");
notesSlide->GetNotesTextFrame()->GetParagraphs()->Append(paragraph);
paragraph = new TextParagraph();
paragraph->SetText(L"Use contrasting colors for text and background.");
notesSlide->GetNotesTextFrame()->GetParagraphs()->Append(paragraph);
//Set the bullet type and bullet style for specific paragraphs on the notes slide
for (int i = 1; i < notesSlide->GetNotesTextFrame()->GetParagraphs()->GetCount(); i++)
{
notesSlide->GetNotesTextFrame()->GetParagraphs()->GetItem(i)->SetBulletType(TextBulletType::Numbered);
notesSlide->GetNotesTextFrame()->GetParagraphs()->GetItem(i)->SetBulletStyle(NumberedBulletStyle::BulletArabicPeriod);
}
//Save the result file
ppt->SaveToFile(outputFile.c_str(), FileFormat::Pptx2013);
ppt->Dispose();
}

Read Speaker Notes in PowerPoint in C++
To get speaker notes from a notes slide, Spire.Presentation for C++ offers the NotesSlide->GetNotesTextFrame()->GetText() method. The following are the detailed steps.
- Create a Presentation instance and load a PowerPoint document using Presentation->LoadFromFile() method.
- Get a specified slide using Presentation->GetSlides()->GetItem(slideIndex) method.
- Get the notes slide from the slide using ISlide->GetNotesSlide() method.
- Get the speaker notes from the notes slide using NotesSlide->GetNotesTextFrame()->GetText() method, and then save them to a .txt file.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"SpeakerNotes.pptx";
std::wstring outputFile = L"GetSpeakerNotes.txt";
//Create a Presentation instance
intrusive_ptrPresentation> presentation = new Presentation();
//Load a sample PowerPoint document
presentation->LoadFromFile(inputFile.c_str());
//Get the second slide
intrusive_ptr<ISlide> slide = presentation->GetSlides()->GetItem(1);
//Get the notes slide from the second slide
intrusive_ptr<NotesSlide> notesSlide = slide->GetNotesSlide();
//Get the speaker notes and save to txt file
wofstream desFile(outputFile, ios::out);
desFile << notesSlide->GetNotesTextFrame()->GetText() << endl;
desFile.close();
presentation->Dispose();
}

Delete Speaker Notes in PowerPoint in C++
With Spire.Presentation for C++, you are also allowed to remove all speaker notes at once or just remove a specified speaker note from the notes slide. The following are the detailed steps.
- Create a Presentation instance and load a PowerPoint document using Presentation->LoadFromFile() method.
- Get a specified slide using Presentation->GetSlides()->GetItem(slideIndex) method.
- Get the notes slide from the slide using ISlide->GetNotesSlide() method.
- Remove all speaker notes from the notes slide using NotesSlide->GetNotesTextFrame()->GetParagraphs()->Clear() method or remove a specific speaker note from the notes slide using NotesSlide->GetNotesTextFrame()->GetParagraphs()->RemoveAt(paragraphIndex) method.
- Save the result document using Presentation->SaveToFile() method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"SpeakerNotes.pptx";
std::wstring outputFile = L"RemoveSpeakerNotes.pptx";
//Create a Presentation instance
intrusive_ptr<Presentation> presentation = new Presentation();
//Load a sample PowerPoint document
presentation->LoadFromFile(inputFile.c_str());
//Get the second slide
intrusive_ptr<ISlide> slide = presentation->GetSlides()->GetItem(1);
//Get the notes slide from the second slide
intrusive_ptr<NotesSlide> notesSlide = slide->GetNotesSlide();
//Remove all the speaker notes from notes slide
notesSlide->GetNotesTextFrame()->GetParagraphs()->Clear();
//Remove a specific speak note from notes slide
//notesSlide->GetNotesTextFrame()->GetParagraphs()->RemoveAt(1);
//Save the result file
presentation->SaveToFile(outputFile.c_str(), FileFormat::Pptx2013);
presentation->Dispose();
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
C++: Convert PowerPoint Presentations to Images (JPG, PNG, SVG)
Converting PowerPoint presentations to images brings you multiple benefits. For example, it makes it easy for you to share the content with others who may not have access to PowerPoint software; it preserves the formatting of the original presentation, ensuring that the content appears exactly as intended; and it protects the content in the presentation from being edited or modified by others. In this article, you will learn how to convert a PowerPoint Presentation to different image formats in C++ using Spire.Presentation for C++.
- Convert PowerPoint Presentation to JPG or PNG Images
- Convert PowerPoint Presentation to JPG or PNG Images with Specific Size
- Convert PowerPoint Presentation to SVG Images
Install Spire.Presentation for C++
There are two ways to integrate Spire.Presentation for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.
Integrate Spire.Presentation for C++ in a C++ Application
Convert PowerPoint Presentation to JPG or PNG Images in C++
Spire.Presentation for C++ offers the ISlide->SaveAsImage() method which enables you to convert the slides in a PowerPoint presentation to JPG or PNG images. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Access the slide collection of the presentation using Presentation->GetSlides() method.
- Iterate through the slides in the collection.
- Save each slide to an image stream using ISlide->SaveAsImage() method.
- Save the image stream to a JPG or PNG file using Stream->Save() method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Initialize an instance of the Presentation class
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
intrusive_ptrSlideCollection> slides = ppt->GetSlides();
//Iterate through the slides in the collection
for (int i = 0; i < slides->GetCount(); i++)
{
intrusive_ptrISlide> slide = slides->GetItem(i);
//Save each slide to a PNG image
intrusive_ptrStream> image = slide->SaveAsImage();
image->Save((L"Images\\ToImage_img_" + to_wstring(i) + L".png").c_str());
}
ppt->Dispose();
}

Convert PowerPoint Presentation to JPG or PNG Images with Specific Size in C++
You can convert the slides in a PowerPoint presentation to JPG or PNG images with a specific size using ISlide->SaveAsImage(int width, int height) method. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Access the slide collection of the presentation using Presentation->GetSlides() method.
- Iterate through the slides in the collection.
- Save each slide to an image stream using ISlide->SaveAsImage(int width, int height) method.
- Save the image stream to a JPG or PNG file using Stream->Save() method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Initialize an instance of the Presentation class
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
intrusive_ptrSlideCollection> slides = ppt->GetSlides();
//Iterate through the slides in the collection
for (int i = 0; i < slides->GetCount(); i++)
{
intrusive_ptrISlide> slide = slides->GetItem(i);
//Save each slide to a PNG image with a size of 600 x 400 pixels
intrusive_ptrStream> image = slide->SaveAsImage(600, 400);
image->Save((L"ImagesWithSpecificSize\\ToImage_img_" + to_wstring(i) + L".png").c_str());
}
ppt->Dispose();
}

Convert PowerPoint Presentation to SVG Images in C++
To convert the slides in a PowerPoint presentation to SVG images, you can use the ISlide->SaveToSVG() method. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Access the slide collection of the presentation using Presentation->GetSlides() method.
- Iterate through the slides in the collection.
- Save each slide to an SVG stream using ISlide->SaveToSVG() method.
- Save the SVG stream to an SVG file using Stream->Save() method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Initialize an instance of the Presentation class
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
intrusive_ptrSlideCollection> slides = ppt->GetSlides();
//Set whether to retain notes while converting PowerPoint to SVG
ppt->SetIsNoteRetained(true);
//Iterate through the slides in the collection
for (int i = 0; i < slides->GetCount(); i++)
{
intrusive_ptrISlide> slide = slides->GetItem(i);
//Save each slide to an SVG image
intrusive_ptrStream> svg = slide->SaveToSVG();
svg->Save((L"SvgImages\\ToSVG-" + to_wstring(i) + L".svg").c_str());
}
ppt->Dispose();
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
C++: Convert PowerPoint Presentation to PDF
When you need to share or present your PowerPoint presentations on different computers/devices, you may occasionally find that some content cannot be displayed properly. To avoid such incompatibility issues, a common method is to convert your PowerPoint document to PDF to ensure document integrity. In this article, you will learn how to convert a PowerPoint Presentation to PDF in C++ using Spire.Presentation for C++.
- Convert an Entire PowerPoint Presentation to PDF in C++
- Convert a Specific PowerPoint Slide to PDF in C++
- Convert a PowerPoint to PDF with Specific Page Size in C++
Install Spire.Presentation for C++
There are two ways to integrate Spire.Presentation for C++ into your application. One way is to install it through NuGet, and the other way is to download the package from our website and copy the libraries into your program. Installation via NuGet is simpler and more recommended. You can find more details by visiting the following link.
Integrate Spire.Presentation for C++ in a C++ Application
Convert an Entire PowerPoint Presentation to PDF in C++
The Presentation->SaveToFile(LPCWSTR_S fileName, FileFormat::PDF) method allows you to convert each slide in PowerPoint to a PDF page. The following are the steps to convert a whole PowerPoint presentation to PDF.
- Create a Presentation object.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Save it to PDF using Presentation->SaveToFile(LPCWSTR_S fileName, FileFormat::PDF) method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"Data\\sample.pptx";
std::wstring outputFile = L"Output\\PowerPointToPDF.pdf";
//Create a Presentation object
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Save the document to PDF
ppt->SaveToFile(outputFile.c_str(), FileFormat::PDF);
ppt->Dispose();
}

Convert a Specific PowerPoint Slide to PDF in C++
If you only want to convert a particular slide to PDF, you can use the ISlide->SaveToFile(LPCWSTR_S fileName, FileFormat::PDF) method provided by Spire.Presentation for C++. The following are the detailed steps.
- Create a Presentation object.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Get a specified slide by index using Presentation->GetSlides()->GetItem(slideIndex) method.
- Save the slide to PDF using ISlide->SaveToFile(LPCWSTR_S fileName, FileFormat::PDF) method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"Data\\sample.pptx";
std::wstring outputFile = L"Output\\SlideToPDF.pdf";
//Create a Presentation object
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Get the second slide
intrusive_ptr slide = ppt->GetSlides()->GetItem(1);
//Save the second slide to PDF
slide->SaveToFile(outputFile.c_str(), FileFormat::PDF);
ppt->Dispose();
}

Convert a PowerPoint to PDF with Specific Page Size in C++
Spire.Presentation for C++ also allows you to set a desired slide size and orientation for a PowerPoint document before converting it to PDF. The following are the steps to convert a PowerPoint to PDF with Specific Page Size (A4 slide size = 10.83x7.05 inch).
- Create a Presentation object.
- Load a PowerPoint presentation using Presentation->LoadFromFile() method.
- Set the slide size of the PowerPoint document using Presentation->GetSlideSize()->SetType() method.
- Set the slide orientation of the PowerPoint document using Presentation->GetSlideSize()->SetOrientation() method.
- Save the document to PDF using Presentation->SaveToFile(LPCWSTR_S fileName, FileFormat::PDF) method.
- C++
#include "Spire.Presentation.o.h";
using namespace Spire::Presentation;
using namespace std;
int main()
{
//Specify the input and output file paths
std::wstring inputFile = L"Data\\sample.pptx";
std::wstring outputFile = L"Output\\ToPdfWithSpecificPageSize.pdf";
//Create a Presentation object
intrusive_ptrPresentation> ppt = new Presentation();
//Load a PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Set the slide size to A4
ppt->GetSlideSize()->SetType(SlideSizeType::A4);
//Set the slide orientation to Landscape
ppt->GetSlideSize()->SetOrientation(SlideOrienation::Landscape);
//Save the document to PDF
ppt->SaveToFile(outputFile.c_str(), FileFormat::PDF);
ppt->Dispose();
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.