Setting the first slide number in a presentation

In the powerpoint activeX powerpoint model you can set the number of the first slide in a presentation. So if ou have

Microsoft.Office.Interop.PowerPoint.Presentation ppPres;

... code to set ppPres

ppPres.PageSetup.FirstSlideNumber = slideNumber;

if sets the slidenumber for the first slide.

Is there a way to do the same thing in the Aspose.Slides api?

Thanks

Hi Robert,


Thank you for inquiring Aspose.Slides.

I have observed your comments and like to share with you that Aspose.Slides does not support setting the first slide number however you can change the order of slides by using

Slide.SlideNumber Property as ppPres.Slides[0].SlideNumber = someInteger;

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards.

Hi Robert,

Thanks for inquiring Aspose.Slides.

I have observed the comments shared by you and like to share that the slides are available in order of appearance on PowerPoint inside Presentation.Slides collection. You can reorder the slides as per your convenience and set any slide to first slide index. It will be moved to first index inside Presentation.Slides collection. I hope this will clarify the concept. please share, if I may help you further in this regard.

Many Thanks,

Thanks for your quick responses.

Maybe there is another way to solve my problem.

Here is what I am trying to do. I need to produce a pdf of a single slide in a power point. It should look just like the slide would in the full deck.

The way I was trying to do this was to remove all of the slides except for the one slide I the user wants a pdf of, and save the ppt with all the other slides removed as a pdf file. This gives me the correct pdf file, except that the slide number is incorrect.

This is porting existing functionality from an implementation using the powerpoint api. The same approach worked there and I could work around the slide number problem by adjusting the PageSetup.FirstSlideNumber.

Is there another way that I am missing using Aspose to get a pdf that just contains a single slide?

Hi Robert,

I have observed your requirement and it seems that you wish to generate the one slide PDF for your presentation. There are two options to meet your requirement. First is to generate the PDF of desired slide directly instead of deleting the other slide and finally saving that as PDF to get the desired page PDF. Please visit this documentation link to serve the purpose in this regard. The other option is to use the slide cloning feature to clone the desired slide to a new presentation object and saving the presentation as PDF as under.

//Instantiate Presentation class to load the source presentation file

using(Presentation srcPres = new Presentation(“helloworld.pptx”))

{

//Instantiate Presentation class for destination presentation (where slide is to be cloned)

using(Presentation destPres = new Presentation())

{

//Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation

ISlideCollection slds = destPres.Slides;

//Clone the desired slide from the source presentation to the specified position in destination presentation

slds.AddClone(srcPres.Slides[1]);//Desired slide index

//remove default slide

destPres.Slides.RemoveAt(0);

//Write the destination presentation to disk

destPres.Save(“helloworld_dest2.pdf”,SaveFormat.Pdf);

}

}

I hope this will be helpful. Please share, if I may help you further in this regard.

Many Thanks,

Wouldn’t the slide number still be 1?

Hi Robert,


I have not been able to understand your question. Can you please elaborate. Please also share, if my suggestions have not been able to prove fruitful on your end. If no then please share the working sample interop project along with source and desired generated PDF file that you want. I will investigate that further on my end to help you out.

Many Thanks,

I have attached a project for a console app that takes a ppt file and a slide number and creates a pdf from a slide 3 ways:

1) it creates it using the ppt api
2) it creates it using aspose.slides deleting the other slides and then saving it as pdf.
3) it creates it using aspose.slides cloning the slide into a new presentation and saving it.

If you run this console app against title.pptx you get pdfs I included in the zip. This is a really simple presentation with 3 slides the significant feature of which is includes a slide number variable. I run it saying I want slide number 2.

Note that the version produced by ppt, the slide number in the pdf file is still 2, just as it would be if you converted the entire presentation to pdf.

In the version produced using aspose and deleting the other slides, the slidenumber is present but it is slide number 1, not 2. I need to make it be 2 just like it is in the original ppt.

In the version produced by cloning the slide, the slide number is gone, so I may have done something wrong in that. It is mostly a copy and paste of the code you posted.

So my question is, is there a way in aspose to export just the second slide to pdf and have the slide number remain 2.

Let me know if this is not clear.

Hi Robert,

I have observed the MS Interop code shared by you and have observed that you wish to generate the PDF of individual slide by retaining the slide number. Please try using the following sample code on your end to achieve the desired results. I hope this will be helpful. Please share, if I may help you further in this regard.

public static void generatePDF()
{
String path=@“D:\Aspose Data\”;
Presentation pres = new Presentation(path + “Title.pptx”);

//Setting array of slides positions
int[] slides = new int[] { 1 };

//Save the presentation to PDF
pres.Save(path + “Slides\Slide1.pdf”, slides, SaveFormat.Pdf);

slides = new int[] { 2 };
pres.Save(path + “Slides\Slide2.pdf”, slides, SaveFormat.Pdf);

slides = new int[] { 3 };
pres.Save(path + “Slides\Slide3.pdf”, slides, SaveFormat.Pdf);

}

Many Thanks,

Perfect, that is just what I needed.

Thank you

Hi Robert,


Thank you for sharing feedback.

We are glad to hear that things have started working on your end. Please share if I may help you further in this regard.

Many Thanks,