Java에서 PDF 또는 HTML로 프레젠테이션 가져오기

소개

Aspose.Slides를 사용하면 다른 형식의 파일에서 프레젠테이션을 가져올 수 있습니다. Aspose.Slides는 PDF 및 HTML 문서에서 프레젠테이션을 가져올 수 있는 SlideCollection 클래스를 제공합니다.

PDF에서 PowerPoint 가져오기

이 경우 PDF를 PowerPoint 프레젠테이션으로 변환할 수 있습니다.

pdf-to-powerpoint

  1. Presentation 클래스의 인스턴스를 생성합니다.
  2. addFromPdf() 메서드를 호출하고 PDF 파일을 전달합니다.
  3. save() 메서드를 사용하여 파일을 PowerPoint 형식으로 저장합니다.

다음 Java 코드는 PDF를 PowerPoint로 변환하는 작업을 보여줍니다:

Presentation pres = new Presentation();
try {
    pres.getSlides().addFromPdf("InputPDF.pdf");
    pres.save("OutputPresentation.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

HTML에서 PowerPoint 가져오기

이 경우 HTML 문서를 PowerPoint 프레젠테이션으로 변환할 수 있습니다.

  1. Presentation 클래스의 인스턴스를 생성합니다.
  2. addFromHtml() 메서드를 호출하고 HTML 파일을 전달합니다.
  3. save() 메서드를 사용하여 파일을 PowerPoint 형식으로 저장합니다.

다음 Java 코드는 HTML을 PowerPoint로 변환하는 작업을 보여줍니다:

Presentation presentation = new Presentation();
try {
    FileInputStream htmlStream = new FileInputStream("page.html");
    try {
        presentation.getSlides().addFromHtml(htmlStream);
    } finally {
        if (htmlStream != null) htmlStream.close();
    }

    presentation.save("MyPresentation.pptx", SaveFormat.Pptx);
} catch(IOException e) {
} finally {
    if (presentation != null) presentation.dispose();
}

FAQ

PDF를 가져올 때 표가 보존되며, 표 감지를 개선할 수 있나요?

표는 가져오기 중에 감지될 수 있으며, PdfImportOptions에는 표 인식을 활성화하는 setDetectTables 메서드가 포함되어 있습니다. 효과는 PDF 구조에 따라 달라집니다.