Demonstration of the .NET version of the PDF processing control Aspose.PDF: Convert PDF files to PPT documents in C#

PDF is one of the widely used formats for exchanging documents reliably without worrying about layout issues. On the other hand, PowerPoint presentations (PPT/PPTX) make it easier to present data or information in the form of interactive slides. In some cases, the information contained in the PDF file needs to be presented in the form of a PowerPoint presentation. In this case, you can minimize your workload by automating the process of importing information from PDF to PowerPoint PPT/PPTX.

Aspose.PDF for .NET  is a PDF processing and parsing API for performing document management and manipulation tasks in cross-platform applications, which can be easily used to generate, modify, convert, render, protect and print PDF documents without Use Adobe Acrobat.

To handle this situation, this article will show how to use Aspose.PDF to convert PDF to PPT document in C#.NET. This article will demonstrate how to:

  • Convert PDF to PowerPoint PPT or PPTX in C#.
  • Convert PDF with slides to PowerPoint PPT or PPTX in C#.
  • Track the progress of PDF to PowerPoint conversion.

Recently, the .NET version of Aspose.PDF has been upgraded to v20.3, which supports tracking the progress of converting PDF to PowerPoint presentations, enhances the link extraction function, and fixes many bugs. Interested friends can click the button below to download the latest version.

Convert PDF to PPT or PPTX in C#

Below are the steps to convert a PDF file into a PowerPoint presentation using Aspose.PDF for .NET.

  • Create an object of the Document class.
  • Create an object of the PptxSaveOptions class.
  • Call the Document.Save() method to save the PDF as PPT or PPTX.

The following code sample shows how to convert PDF to PPT in C#.

// Load PDF document
Document pdfDocument = new Document("document.pdf");
PptxSaveOptions pptxOptions = new PptxSaveOptions();
// Save output file
pdfDocument.Save("PDF to PPT.ppt", pptxOptions);

PDF file

Convert PowerPoint PPT

Convert PDF to PPT in C# – Render slides as images

If you want to avoid optional text in your converted PowerPoint presentation, you can render each slide as an image. To do this, you can set the PptxSaveOptions.SlidesAsImages property to true, and the rest of the steps will remain the same. The code sample below shows how to convert PDF with slides as images to PPT in C#.

// Load PDF document
Document pdfDocument = new Document("document.pdf");
PptxSaveOptions pptxOptions = new PptxSaveOptions();
pptxOptions.SlidesAsImages = true;
// Save output file
pdfDocument.Save("PDF to PPT.ppt", pptxOptions);

Track PDF to PPT conversion progress

Track the progress of your PDF to PPT conversion process with Aspose.PDF for .NET. The following information about the conversion process can be retrieved:

  • Total conversion progress
  • Analysis of each page before conversion ends
  • Create results page before physical export
  • Export every page of results

The following code sample shows how to track PDF to PPT conversion in C#.

// Load PDF document
Document pdfDocument = new Document("document.pdf");
PptxSaveOptions pptxOptions = new PptxSaveOptions();
// Render slides as images
pptxOptions.SlidesAsImages = true;
// Track progress in console
pptxOptions.CustomProgressHandler = ShowProgressOnConsole;
// Save output file
pdfDocument.Save("PDF to PPT.ppt", pptxOptions);

//----------------------------------

public static void ShowProgressOnConsole(PptxSaveOptions.ProgressEventHandlerInfo eventInfo)
{ 
	switch (eventInfo.EventType)
	{
		case ProgressEventType.TotalProgress:
			Console.WriteLine(String.Format("{0}  - Conversion progress : {1}% .", DateTime.Now.TimeOfDay, eventInfo.Value.ToString()));
			break;
		case ProgressEventType.ResultPageCreated:
			Console.WriteLine(String.Format("{0}  - Result page's {1} of {2} layout created.", DateTime.Now.TimeOfDay, eventInfo.Value.ToString(), eventInfo.MaxValue.ToString()));
			break;
		case ProgressEventType.ResultPageSaved:
			Console.WriteLine(String.Format("{0}  - Result page {1} of {2} exported.", DateTime.Now.TimeOfDay, eventInfo.Value.ToString(), eventInfo.MaxValue.ToString()));
			break;
		case ProgressEventType.SourcePageAnalysed:
			Console.WriteLine(String.Format("{0}  - Source page {1} of {2} analyzed.", DateTime.Now.TimeOfDay, eventInfo.Value.ToString(), eventInfo.MaxValue.ToString()));
			break;

		default:
			break;
	} 
}

output result

Guess you like

Origin blog.csdn.net/m0_67129275/article/details/131695629