Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
本文解释了如何 使用 C# 将 PDF 转换为 PowerPoint。 它涵盖了以下主题。
格式: PPTX
格式: PowerPoint
以下代码片段也适用于 Aspose.PDF.Drawing 库。
Aspose.PDF for .NET 让您跟踪 PDF 到 PPTX 转换的进度。
我们有一个名为 Aspose.Slides 的 API,它提供创建和操作 PPT/PPTX 演示文稿的功能。 此 API 还提供将 PPT/PPTX 文件转换为 PDF 格式的功能。 最近,我们收到了许多客户的要求,以支持将 PDF 转换为 PPTX 格式的能力。 从 Aspose.PDF for .NET 版本 10.3.0 开始,我们引入了一项将 PDF 文档转换为 PPTX 格式的功能。 在此转换过程中,PDF 文件的各个页面被转换为 PPTX 文件中的单独幻灯片。
在 PDF 到 PPTX 转换过程中,文本被呈现为文本,您可以选择/更新它。 请注意,为了将 PDF 文件转换为 PPTX 格式,Aspose.PDF 提供了一个名为 PptxSaveOptions
的类。 PptxSaveOptions 类的对象作为第二个参数传递给 Document.Save(..) 方法
。 以下代码片段展示了将 PDF 文件转换为 PPTX 格式的过程。
为了将 PDF 转换为 PPTX,Aspose.PDF for .NET 建议使用以下代码步骤。
步骤:在 C# 中将 PDF 转换为 PowerPoint | 步骤:在 C# 中将 PDF 转换为 PPTX
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFToPPTX()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "input.pdf"))
{
// Instantiate PptxSaveOptions object
var saveOptions = new Aspose.Pdf.PptxSaveOptions();
// Save the file in PPTX format
document.Save(dataDir + "PDFToPPT_out.pptx", saveOptions);
}
}
如果您需要将可搜索的 PDF 转换为 PPTX 作为图像而不是可选择的文本,Aspose.PDF 提供了通过 Aspose.Pdf.PptxSaveOptions 类实现此功能。 为此,将 PptxSaveOptios 类的属性 SlidesAsImages 设置为 ’true’,如下所示的代码示例。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFToPPTWithSlidesAsImages()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "input.pdf"))
{
// Instantiate PptxSaveOptions object
var saveOptions = new Aspose.Pdf.PptxSaveOptions
{
SlidesAsImages = true
};
// Save the file in PPTX format with slides as images
document.Save(dataDir + "PDFToPPT_out.pptx", saveOptions);
}
}
Aspose.PDF for .NET 让您跟踪 PDF 到 PPTX 转换的进度。 Aspose.Pdf.PptxSaveOptions 类提供了 CustomProgressHandler 属性,可以指定为自定义方法以跟踪转换的进度,如以下代码示例所示。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertPDFToPPTWithCustomProgressHandler()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "input.pdf"))
{
// Instantiate PptxSaveOptions object
var saveOptions = new Aspose.Pdf.PptxSaveOptions();
// Specify custom progress handler
saveOptions.CustomProgressHandler = ShowProgressOnConsole;
// Save the file in PPTX format with progress tracking
document.Save(dataDir + "PDFToPPTWithProgressTracking_out.pptx", saveOptions);
}
}
// Define the method to handle progress events and display them on the console
private static void ShowProgressOnConsole(Aspose.Pdf.UnifiedSaveOptions.ProgressEventHandlerInfo eventInfo)
{
switch (eventInfo.EventType)
{
case Aspose.Pdf.ProgressEventType.TotalProgress:
// Display overall progress of the conversion
Console.WriteLine($"{DateTime.Now.TimeOfDay} - Conversion progress: {eventInfo.Value}%.");
break;
case Aspose.Pdf.ProgressEventType.ResultPageCreated:
// Display progress of the page layout creation
Console.WriteLine($"{DateTime.Now.TimeOfDay} - Result page {eventInfo.Value} of {eventInfo.MaxValue} layout created.");
break;
case Aspose.Pdf.ProgressEventType.ResultPageSaved:
// Display progress of the page being exported
Console.WriteLine($"{DateTime.Now.TimeOfDay} - Result page {eventInfo.Value} of {eventInfo.MaxValue} exported.");
break;
case Aspose.Pdf.ProgressEventType.SourcePageAnalysed:
// Display progress of the source page analysis
Console.WriteLine($"{DateTime.Now.TimeOfDay} - Source page {eventInfo.Value} of {eventInfo.MaxValue} analyzed.");
break;
default:
break;
}
}
本文还涵盖了以下主题。 代码与上述相同。
格式: PowerPoint
格式: PPTX
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.