วิธีสร้างสไลด์ PowerPoint ใน HTML โดยใช้ Java

บทช่วยสอนนี้มีข้อมูลเกี่ยวกับ วิธีสร้างสไลด์ PowerPoint ใน HTML โดยใช้ Java ขั้นตอนนี้ค่อนข้างง่าย โดยสร้าง presentation ใหม่หรือโหลดงานนำเสนอที่มีอยู่แล้วบันทึกเป็น HTML สิ่งนี้ทำให้คุณสามารถแสดงผล สไลด์ใน HTML ใน Java โดยใช้โค้ด 2-3 บรรทัด หากคุณต้องการแสดงงานนำเสนอที่มีอยู่เป็น HTML

ขั้นตอนในการสร้างงานนำเสนอ HTML โดยใช้ Java

  1. เพิ่ม Aspose.Slides for Java ในโครงการของคุณจากที่เก็บ Maven สำหรับสร้างงานนำเสนอ HTML
  2. สร้างวัตถุคลาส Presentation ที่ว่างเปล่า
  3. สร้างวัตถุคลาส Slide และเพิ่มรูปทรงเพชรเข้าไป
  4. ตั้งค่าข้อความในรูปทรงข้าวหลามตัด
  5. บันทึกงานนำเสนอผลลัพธ์เป็นไฟล์ HTML บนดิสก์

ขั้นตอนเหล่านี้ช่วยในการสร้าง HTML งานนำเสนอด้วย Java ซึ่งงานนำเสนอใหม่จะถูกสร้างขึ้นและบันทึกเป็น HTML ที่สามารถเปิดได้ในเบราว์เซอร์ใดก็ได้ โปรดทราบว่าไม่จำเป็นต้องสร้างงานนำเสนอตั้งแต่เริ่มต้น เนื่องจากคุณสามารถโหลดงานนำเสนอที่มีอยู่เพื่อสร้างงานนำเสนอ HTML ได้ คุณสามารถบันทึกสไลด์ที่เลือกลงในไฟล์ HTML เอาต์พุตได้หากจำเป็น

รหัสเพื่อสร้างสไลด์นำเสนอ HTML โดยใช้ Java

import com.aspose.slides.License;
import com.aspose.slides.IAutoShape;
import com.aspose.slides.IParagraph;
import com.aspose.slides.IPortion;
import com.aspose.slides.ISlide;
import com.aspose.slides.ITextFrame;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import com.aspose.slides.ShapeType;
public class SlidesMainFunction {
public static void main(String[] args) {//Create PowerPoint Slides in HTML using Java
// Instantiate license to create presentation in HTML
License slidesLicense = new License();
slidesLicense.setLicense("Aspose.Slides.lic");
//Create an empty presentation class object
Presentation targetPresentation = new Presentation();
try
{
// Get access to the first slide instance from the default slides collection
ISlide targetSlide = targetPresentation.getSlides().get_Item(0);
// Add a diamond shape to display some text in it
IAutoShape targetShape = targetSlide.getShapes().addAutoShape(ShapeType.Diamond, 150, 75, 150, 50);
// Add a text frame in the diamond
targetShape.addTextFrame(" ");
// Get access to the newly created text frame
ITextFrame targetTxtFrame = targetShape.getTextFrame();
// Get access to the first paragraph object in the text frame
IParagraph targetPara = targetTxtFrame.getParagraphs().get_Item(0);
// Get access to the first portion in the paragraph
IPortion targetPortion = targetPara.getPortions().get_Item(0);
// Add some test data to display in diamond shape
targetPortion.setText("Aspose sample text in the textbox");
// Save the HTML presentation on the disk
targetPresentation.save("TextBox_out.html", SaveFormat.Html);
}
finally
{
if (targetPresentation != null)
targetPresentation.dispose();
}
System.out.println("Done");
}
}

โค้ดนี้แสดงหนึ่งใน ตัวอย่างของการนำเสนอ HTML โดยใช้ Java โดยละเอียด เช่น การแสดงลำดับการดำเนินการที่สมบูรณ์ซึ่งส่งผลให้มีการนำเสนอ HTML ในตอนท้าย คุณสามารถสังเกตได้ว่าเราต้องสร้างวัตถุของคลาส Presentation, ISlide, IAutoShape, ITextFrame, IParagraph และ IPortion ตามลำดับเพื่อสร้างงานนำเสนอใหม่ คุณสามารถสร้างหลายสไลด์และเพิ่มเนื้อหาประเภทต่างๆ ที่คล้ายกับ MS PowerPoint

ในบทความนี้ เราได้เรียนรู้การสร้างงานนำเสนอ PowerPoint ใน HTML อย่างไรก็ตาม หากคุณต้องการรักษาความปลอดภัยของงานนำเสนอ โปรดดูบทความใน วิธีรักษาความปลอดภัยงานนำเสนอ PowerPoint โดยใช้ Java

 ไทย