Search code examples
javaasposeaspose-slides

Page Setup in Aspose PPT/Slides


I am using aspose-slides-17.3-jdk16.jar for java. I want to customize the page setup for slides in PPT.

enter image description here

Any help would be greatly appreciated.


Solution

  • I have observed your requirements for setting the slide size using Aspose.Slides. I like to mention that slide size is set on presentation level, so we have got a single slide size for entire presentation. Please try using following sample code for getting and setting different slide size properties using Aspose.Slides.

    Presentation pres=new Presentation("Test.pptx");
    //Getting Orientation
    //SlideOrienation 0: Landscape 1: Portrait
    int orientation=pres.getSlideSize().getOrientation();
    
    //Setting orientation
    pres.getSlideSize().setOrientation(SlideOrienation.Portrait);
    
    //Setting Slide size
    // Method SetSize is used for set slide size with scale content to ensure fit
    pres.getSlideSize().setSize(720, 540, SlideSizeScaleType.EnsureFit);
    
    // Method SetSize is used for set slide size with maximize size of content
    pres.getSlideSize().setSize(SlideSizeType.A4Paper, SlideSizeScaleType.Maximize);
    
    //Getting SlideSizeType: Read only property
    int SizeType= pres.getSlideSize().getType();
    
    //Getting slide Size: Read only property
    Dimension2D slideSize=pres.getSlideSize().getSize();
    

    Please also visit, SlideOrienation and SlideSizeType enumeration for your further kind reference. I also like to add further here that in Aspose.Slides we have 72 pixels per inch for slide size. So a normal slide with 10''x 7.5'' will have corresponding size in Aspose.Slides as 10*72 x 7.5*72= 720 x 540.

    If there still an issue, you are more than welcome.

    I am working as Support developer/ Evangelist at Aspose.