How to set presentation slide size and type (C#)

Hello,

​Presentation.SlideSize.Type and Presentation.SlideSize.Size are now read only properties.
We encountered the issue when we updated to Aspose.Slides.dll 18.3.0.0
​We did not have this problem on the previous version we were using 17.3.0.0

We need to be able to set the size and type of a presentation.
Is there a new way to do this on newer versions fi slides?

@adrian.anton,

I have observed your comments. I have shared sample code with you. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.

Presentation pres = new Presentation(path+“testaspose1.pptx”);

   ISlide slide = pres.getSlides().get_Item(0);

   
   try {
pres.getSlideSize().setSize(540, 720, SlideSizeScaleType.EnsureFit); // Method SetSize is used for set slide size with scale content to ensure fit
pres.getSlideSize().setSize(SlideSizeType.A4Paper, SlideSizeScaleType.Maximize); // Method SetSize is used for set slide size with maximize size of content

} finally {
pres.dispose();
}
pres.save(path+“resulttestaspose.pptx”,SaveFormat.Pptx);

Can u tell me 540 and 720 unit?It is px?

@ximoon,

I like to share that there are 72 pixels / inch unit used in API. so for 720 x 540 is actually 10’’ x 7.5’’ slide size. I hope the shared information will be helpful.

if i set 960 * 540 on web, I should set value on my code?

@ximoon,

Yes, you need to set this on code.

@ximoon,

I suggest you to please check following link.

I do this, but invalid

@ximoon,

Can you please explain little bit so that we may help you out.

When I set pres.getSlideSize().setSize(640.0f,360.0f,SlideSizeScaleType.EnsureFit);
but I get slide of ppt size is not 640.0f * 360.0f.
like this image2019-11-14_125122.jpg (81.3 KB)

@ximoon,

Please change values according to your own needs and check following sample code.

Presentation pres = …
pres.getSlideSize().setSize(960, 540, SlideSizeScaleType.DoNotScale);

I do this,but it have no effect

@ximoon,

Please provide the working sample code, source file, generated file and desired output. We will investigate the issue further on our end to help you out.

{
Presentation pres = new Presentation();
pres.getSlideSize().setSize(960.0f, 540.0f, SlideSizeScaleType.DoNotScale);
pres.save(“testSlideSize.pptx”, SaveFormat.Pptx);
}
testSlideSize.zip (20.2 KB)
I think this slide of file is not I set. Is value I set is wrong? I want 960 * 540 canvas. But I get 1220 * 740.

@ximoon,

I have checked your result and its seems you are using old version of Aspose.Slides. Can you please try to use Aspose.Slides latest version 19.10 on your end and share feedback with us if there is still an issue.

I try version 19.10, but it still an issue.

@ximoon,

I have used your following sample code using Aspose.Slides for Java 19.10 and have not been able to reproduce the issue.

testSlideSize.zip (19.0 KB)

I just needed it. Thanks a lot for sharing.