We are currently using 17.7 for aspose-slides for java and planning to migrate to 24.5 version. however I see that getSlideSize().setType getSlideSize().setSize on Presentation seems to be not supported. What is the alternative ? what are the default values that get set if they are not supported ? Appreciate any pointers on this. Thanks
In Aspose.Slides for Java, the methods getSlideSize().setType
and getSlideSize().setSize
are indeed not directly supported in the way you might expect. Instead, you can use the setSize
method of the ISlideSize
interface to set the size of the slides.
Here’s how you can set the slide size and type:
-
Setting the Slide Size: You can use the
setSize(float width, float height, int scaleType)
method to define the size of the slide in points. This will reset the slide type toSlideSizeType.Custom
. -
Setting the Slide Type: To set the type of slide size, you can use the
setSize(int type, int scaleType)
method. This allows you to specify a predefined slide size type while scaling the content accordingly.
Here is a code example demonstrating how to set the slide size:
import com.aspose.slides.*;
public class SetSlideSizeExample {
public static void main(String[] args) {
// Create a presentation
Presentation presentation = new Presentation();
// Get the slide size
ISlideSize slideSize = presentation.getSlideSize();
// Set the slide size to a custom size
slideSize.setSize(800, 600, SlideSizeScaleType.EnsureFit);
// Alternatively, set a predefined slide size type
slideSize.setSize(SlideSizeType.A4Paper, SlideSizeScaleType.EnsureFit);
// Save the presentation
presentation.save("output.pptx", SaveFormat.Pptx);
}
}
Default Values
If the methods you mentioned are not supported, the default slide size is typically set to the standard size used in PowerPoint presentations, which is 10 inches by 7.5 inches (or 720 points by 540 points). If you do not explicitly set the size, the presentation will use this default.
For more detailed information, you can refer to the official Aspose.Slides documentation on SlideSize and Presentation.
If you have any further questions or need additional assistance, feel free to ask!