PDF를 PowerPoint로 변환하기 (.NET)

개요

이 문서에서는 C#을 사용하여 PDF를 PowerPoint로 변환하는 방법을 설명합니다. 다음 주제를 다룹니다.

형식: PPTX

형식: PowerPoint

다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.

C# PDF를 PowerPoint 및 PPTX로 변환하기

Aspose.PDF for .NET는 PDF를 PPTX로 변환하는 진행 상황을 추적할 수 있게 해줍니다.

우리는 PPT/PPTX 프레젠테이션을 생성하고 조작할 수 있는 기능을 제공하는 Aspose.Slides라는 API를 가지고 있습니다. 이 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(..) method 메서드의 두 번째 인수로 전달됩니다. 다음 코드 스니펫은 PDF 파일을 PPTX 형식으로 변환하는 과정을 보여줍니다.

C# 및 Aspose.PDF .NET을 사용한 PDF를 PowerPoint로 간단히 변환하기

PDF를 PPTX로 변환하기 위해 Aspose.PDF for .NET는 다음 코드 단계를 사용할 것을 권장합니다.

단계: C#에서 PDF를 PowerPoint로 변환하기 | 단계: C#에서 PDF를 PPTX로 변환하기

  1. Document 클래스의 인스턴스를 생성합니다.
  2. PptxSaveOptions 클래스의 인스턴스를 생성합니다.
  3. Document 객체의 Save 메서드를 사용하여 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로 변환하기

검색 가능한 PDF를 선택 가능한 텍스트 대신 이미지로 PPTX로 변환해야 하는 경우, Aspose.PDF는 Aspose.Pdf.PptxSaveOptions 클래스를 통해 이러한 기능을 제공합니다. 이를 달성하기 위해 PptxSaveOptions 클래스의 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);
    }
}

PPTX 변환 진행 세부정보

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