Convert PDF Files to PowerPoint
The code below shows you how to convert a PDF file to a PowerPoint Presentation.
This sample requires a Professional license.
C#
using System;
using System.IO;
using SolidFramework.Converters.Plumbing;
using SolidFramework.Converters;
namespace PDFtoPowerPoint
{
class Program
{
[STAThread]
static void Main(string[] args)
{
// Call your Solid Documents License
SolidFramework.License.Import(@"C:\MyFolder\license.xml");
// Set the location of your the file you want to convert
String pdfPath = @"C:\YourFolder\yourpdf.pdf";
// Set the file extension you are creating
String pptxPath = Path.ChangeExtension(pdfPath, ".pptx");
//*PDF to PowerPoint*//
using (PdfToPowerPointConverter converter = new PdfToPowerPointConverter())
{
// Add files to convert.
converter.AddSourceFile(pdfPath);
// Set the preferred conversion properties
// Force detection of hierarchical lists
converter.DetectLists = true;
// Choose how images are reconstructed
converter.GraphicsAsImages = true;
// Convert the File
converter.ConvertTo(pptxPath, true);
//Show the status of the PDF file in the Console Window
SolidFramework.Converters.Plumbing.ConversionStatus status = converter.ConvertTo(pptxPath, true);
if (status != ConversionStatus.Success)
{
Console.WriteLine(status);
Console.ReadKey();
}
}
}
}
}
C++
#include "stdafx.h"
#include "SolidFramework.h"
#include <iostream>
using namespace std;
void DoProgress(SolidFramework::ProgressEventArgsPtr args)
{
// Not implemented
}
void DoWarning(SolidFramework::WarningEventArgsPtr args)
{
// Not implemented
}
class PDFtoPowerPointConverter : public SolidFramework::Converters::PdfToPowerPointConverterBase
{
public:
void FireProgress(SolidFramework::ProgressEventArgsPtr args) override { DoProgress(args); };
void FireWarning(SolidFramework::WarningEventArgsPtr args) override { DoWarning(args); };
};
int _tmain(int argc, _TCHAR* argv[])
{
// Enter your License code goes here
SolidFramework::License::Import(L"C:\\MyFolder\\license.xml");
// Create a PDF to Word Converter called converter
PDFtoPowerPointConverter *converter = new PDFtoPowerPointConverter();
SolidFramework::Converters::CustomData *pData = NULL;
pData = new SolidFramework::Converters::CustomData();
pData->Converter = converter;
pData->Data = nullptr;
converter->setCustomData(pData);
// Add the PDF file to convert.
converter->AddSourceFile(L"C:\\YourFolder\\yourpdf.pdf");
converter->setOutputDirectory(L"C:\\MyFolder");
// Set some convertion options - Detect auto rotate
converter->setAutoRotate(true);
// Set how images are reconstructed
converter->setGraphicsAsImages(true);
//Start the Conversion
cout << "Starting conversion." << endl; converter->Convert();
SolidFramework::Converters::Plumbing::ConversionStatus status = converter->getResults()->getItem(0)->getStatus();
if (status != SolidFramework::Converters::Plumbing::ConversionStatus::Success)
{
cout << "Conversion failed." << endl;
}
else
{
cout << "Conversion succeeded." << endl; } converter->Dispose();
cout << "Press <Enter> to exit." << endl;
cin.get();
return 0;
}
VB.Net
Imports System.IO
Module PDFtoPowerPoint
Sub Main()
' Call your Solid Documents License
SolidFramework.License.Import("C:\MyFolder\license.xml")
' Define a variable for your source file
Dim sPdfPath As String
' Define a String for the output file
Dim ppPath As String
' Define your Solid Framework Converter
Dim myConverter As SolidFramework.Converters.PdfToPowerPointConverter
' Set the converter
myConverter = New SolidFramework.Converters.PdfToPowerPointConverter
' Set your file path
sPdfPath = "C:\YourFolder\filepdf.pdf"
' Set your output file and location
ppPath = Path.ChangeExtension(sPdfPath, ".pptx")
' Set the preferred conversion properties
' Add files to convert.
myConverter.AddSourceFile(sPdfPath)
' Force detection of hierarchical lists
myConverter.DetectLists = True
' Choose how images are reconstructed
myConverter.GraphicsAsImages = True
' Convert the File.
myConverter.ConvertTo(ppPath, True)
' Clean up
myConverter.Dispose()
End Sub
End Module
