Create New Presentation in Aspose.Slides vs pptx4j
Contents
[
Hide
]
Aspose.Slides - Create New Presentation
The Presentation class holds a presentation’s content. Whether creating a presentation from scratch or modifying an existing one, when finished, you want to save the presentation. With Aspose.Slides for Java, it can be saved as a file or stream
Java
// Instantiate Presentation class that represents the PPTX
Presentation pres = new Presentation();
//Write the PPTX file to disk
pres.save(dataDir + "Aspose-New-Presentation.pptx", SaveFormat.Pptx);
pptx4j - Create New Presentation
New presentation creation procedure is shown below using pptx4j.
Java
// Create skeletal package, including a MainPresentationPart and a SlideLayoutPart
PresentationMLPackage presentationMLPackage = PresentationMLPackage.createPackage();
// Need references to these parts to create a slide
// Please note that these parts *already exist* - they are
// created by createPackage() above. See that method
// for instruction on how to create and add a part.
MainPresentationPart pp = (MainPresentationPart)presentationMLPackage.getParts().getParts().get(
new PartName("/ppt/presentation.xml"));
SlideLayoutPart layoutPart = (SlideLayoutPart)presentationMLPackage.getParts().getParts().get(
new PartName("/ppt/slideLayouts/slideLayout1.xml"));
// OK, now we can create a slide
SlidePart slidePart = presentationMLPackage.createSlidePart(pp, layoutPart,
new PartName("/ppt/slides/slide1.xml"));
presentationMLPackage.save(new java.io.File(dataDir + "Pptx4j-New Presentation.pptx"));
Download Running Code
Download Sample Code
For more details, visit Saving a Presentation.