Import Presentation
Contents
[
Hide
]
Using Aspose.Slides for PHP via Java, you can import presentations from files in other formats. Aspose.Slides provides the SlideCollection class to allow you to import presentations from PDFs, HTML documents, etc.
Import PowerPoint from PDF
In this case, you get to convert a PDF to a PowerPoint presentation.
- Create an instance of the Presentation class.
- Call the addFromPdf() method and pass the PDF file.
- Use the save() method to save the file in the PowerPoint format.
This PHP code demonstrates the PDF to PowerPoint operation:
$pres = new Presentation();
try {
$pres->getSlides()->addFromPdf("InputPDF.pdf");
$pres->save("OutputPresentation.pptx", SaveFormat::Pptx);
} finally {
if (!java_is_null($pres)) {
$pres->dispose();
}
}
Tip
You may want to check out Aspose free PDF to PowerPoint web app because it is a live implementation of the process described here.Import PowerPoint from HTML
In this case, you get to convert a HTML document to a PowerPoint presentation.
- Create an instance of the Presentation class.
- Call the addFromHtml() method and pass the PDF file.
- Use the save() method to save the file in the PowerPoint format.
This PHP code demonstrates the HTML to PowerPoint operation:
$presentation = new Presentation();
try {
$htmlStream = new Java("java.io.FileInputStream", "page.html");
try {
$presentation->getSlides()->addFromHtml($htmlStream);
} finally {
if (!java_is_null($htmlStream)) {
$htmlStream->close();
}
}
$presentation->save("MyPresentation.pptx", SaveFormat::Pptx);
} catch (JavaException $e) {
} finally {
if (!java_is_null($presentation)) {
$presentation->dispose();
}
}
Note
You may also use Aspose.Slides to convert HTML to other popular file formats: