นำเข้าการนำเสนอจาก PDF หรือ HTML ใน Java

บทนำ

ด้วย Aspose.Slides คุณสามารถนำเข้าการนำเสนอจากไฟล์ในรูปแบบอื่นได้ Aspose.Slides ให้คลาส SlideCollection ซึ่งช่วยให้คุณนำเข้าการนำเสนอจากเอกสาร PDF และ HTML

นำเข้า PowerPoint จาก PDF

ในกรณีนี้ คุณจะทำการแปลง PDF เป็นการนำเสนอ PowerPoint

pdf-to-powerpoint

  1. สร้างอินสแตนซ์ของคลาส Presentation
  2. เรียกเมธอด addFromPdf() และส่งไฟล์ PDF เข้าไป
  3. ใช้เมธอด save() เพื่อบันทึกไฟล์ในรูปแบบ PowerPoint
Presentation pres = new Presentation();
try {
    pres.getSlides().addFromPdf("InputPDF.pdf");
    pres.save("OutputPresentation.pptx", SaveFormat.Pptx);
} finally {
    if (pres != null) pres.dispose();
}

นำเข้า PowerPoint จาก HTML

ในกรณีนี้ คุณจะทำการแปลงเอกสาร HTML เป็นการนำเสนอ PowerPoint

  1. สร้างอินสแตนซ์ของคลาส Presentation
  2. เรียกเมธอด addFromHtml() และส่งไฟล์ PDF เข้าไป
  3. ใช้เมธอด save() เพื่อบันทึกไฟล์ในรูปแบบ 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