We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting the slide size of generated presentation to that of source (PHP for Java)

Hi,

I’ve seen some of your examples below written in PHP, seems not to work anymore

$aux_pres ->getSlideSize()->setType( $pres ->getSlideSize()-> getType ());
$aux_pres ->getSlideSize()->setSize( $pres ->getSlideSize()->getSize());

You’ve given the example below to fix the problem. Can you please give pointers on how to convert this to PHP?

{

    String path="C:\\Aspose Data\\Presentation\\";

    IPresentation iPresentation=new Presentation(path+"Presentation Global Country Argentina.ppsx");

    IPresentation result=new Presentation();     // this.source = iPresentations;

    final Dimension2D size = iPresentation.getSlideSize().getSize();
    result.getSlideSize().setSize( (int)size.getWidth(),(int)size.getHeight(),SlideSizeScaleType.EnsureFit);
    for(ISlide slide : iPresentation.getSlides())
    {
        result.getSlides().addClone(slide);
    }

    result.getSlides().removeAt(0);
    result.save(path+"Saved.ppsx",SaveFormat.Ppsx);```

Many thanks.

@JediJide,

I have observed your requirements and like to share that we offer support for example in Java, C# or C++ based samples in our documentation. For its respective porting to PHP, one has to carry out porting on his end. However, we are looking into this and will get back to you with feedback ASAP.

@JediJide,

Please try using following sample code. You may please modify this in accordance to your environment details.

$presEx = new Java("com.aspose.slides.Presentation", "c:\\Aspose Data\\HelloWorld.pptx");
$result = new Java("com.aspose.slides.Presentation");
    echo $presEx;

$size = iPresentation->getSlideSize()->getSize();
echo "<p>Accessed slide size";
echo "</p>";

$result->getSlideSize()->setSize( $size->getWidth(),$size->getHeight(),1 /*SlideSizeScaleType*/);

foreach ($presEx->getSlides()  as $slide) {
       $result->getSlides()->addClone($slide);
            }
        

$result->getSlides()->removeAt(0);
        
$result->save("phppresentation.ppsx", 4 /*SaveFormat*/);
echo "<p>Saved presentation";
1 Like

Many thanks that works.

Had to correct this mistake
$size = iPresentation->getSlideSize()->getSize(); to $size = $presEx->getSlideSize()->getSize();

@JediJide,

It’s good to know things are working on your end.