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 std;
using namespace Spire::Presentation;
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
Presentation* ppt = new Presentation();
//Load a sample PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Get the second slide
ISlide* slide = ppt->GetSlides()->GetItem(1);
//Add a notes slide
NotesSlide* notesSlide = slide->AddNotesSlide();
//Add paragraphs to the notes slide and set the content of the speaker notes
TextParagraph* 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);
delete ppt;
}

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 std;
using namespace Spire::Presentation;
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
Presentation* presentation = new Presentation();
//Load a sample PowerPoint document
presentation->LoadFromFile(inputFile.c_str());
//Get the second slide
ISlide* slide = presentation->GetSlides()->GetItem(1);
//Get the notes slide from the second slide
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();
delete presentation;
}

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 std;
using namespace Spire::Presentation;
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
Presentation* presentation = new Presentation();
//Load a sample PowerPoint document
presentation->LoadFromFile(inputFile.c_str());
//Get the second slide
ISlide* slide = presentation->GetSlides()->GetItem(1);
//Get the notes slide from the second slide
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);
delete presentation;
}

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
Presentation* ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
SlideCollection* slides = ppt->GetSlides();
//Iterate through the slides in the collection
for (int i = 0; i < slides->GetCount(); i++)
{
ISlide* slide = slides->GetItem(i);
//Save each slide to a PNG image
Stream* image = slide->SaveAsImage();
image->Save(( L"Images\\ToImage_img_" + to_wstring(i) + L".png").c_str());
}
ppt->Dispose();
delete ppt;
}

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
Presentation* ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
SlideCollection* slides = ppt->GetSlides();
//Iterate through the slides in the collection
for (int i = 0; i < slides->GetCount(); i++)
{
ISlide* slide = slides->GetItem(i);
//Save each slide to a PNG image with a size of 600 x 400 pixels
Stream* image = slide->SaveAsImage(600, 400);
image->Save(( L"ImagesWithSpecificSize\\ToImage_img_" + to_wstring(i) + L".png").c_str());
}
ppt->Dispose();
delete ppt;
}

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
Presentation* ppt = new Presentation();
//Load a PowerPoint presentation
ppt->LoadFromFile(L"Sample.pptx");
//Get the slide collection of the presentation
SlideCollection* 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++)
{
ISlide* slide = slides->GetItem(i);
//Save each slide to an SVG image
Stream* svg = slide->SaveToSVG();
svg->Save((L"SvgImages\\ToSVG-" + to_wstring(i) + L".svg").c_str());
}
ppt->Dispose();
delete ppt;
}

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 std;
using namespace Spire::Presentation;
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
Presentation* 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);
delete ppt;
}

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 std;
using namespace Spire::Presentation;
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
Presentation* ppt = new Presentation();
//Load a PowerPoint document from disk
ppt->LoadFromFile(inputFile.c_str());
//Get the second slide
ISlide* slide = ppt->GetSlides()->GetItem(1);
//Save the second slide to PDF
slide->SaveToFile(outputFile.c_str(), FileFormat::PDF);
delete ppt;
}

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 std;
using namespace Spire::Presentation;
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
Presentation* 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);
delete ppt;
}

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.