How to save as pdf only one page

Hi,
i didn't find in Presentation.save the int[] slides parameter available in Presentation.SaveToPdf.
How can i save to pdf only specified slides ?

Thanks in advance for your help.

Hi Bottura,


Thanks for inquiring Aspose.Slides.

I have observed the requirements shared by you and like to share that Aspose.Slides is able to export the entire presentation to PDF. There is no direct option available to generate the individual slide PDF using Aspose.Slides. However, I have written a function for your convenience that will help you in generating the individual desired slide PDF. All you need to is to pass the presentation object and desired slide position to method as argument and It will generate the PDF for you. Please try using the following sample code for your convenience and share with us if there is any incurring issue.

public static void GenerateSlidePdf(Presentation pres, int SlideIndex)
{
Presentation destPres = new Presentation();
Slide slide = pres.GetSlideByPosition(SlideIndex);

//Creating SortedList object that is used to store the temporary information
//about the masters of PPT file. No value should be added to it.
System.Collections.SortedList sList = new System.Collections.SortedList();

//Cloning the selected slide at the end of another presentation file
pres.CloneSlide(slide, destPres.Slides.LastSlidePosition + 1, pres, sList);

//Rremoving defult empty slide
destPres.Slides.Remove(destPres.GetSlideByPosition(1));

destPres.Save(“D:\Aspose Data\Slide_” + SlideIndex.ToString() + “.pdf”, SaveFormat.Pdf);

}

Many Thanks,

Thanks a lot for your reply, that's exactly what i needed.

One question :
I am using Aspose in C++/CLI and i get a compilation warning :

warning C4996: 'Aspose::Slides::Slides::Remove': was declared deprecated

But in the help file, the function is not marked as obsolete ?

Hi Bottura,

I have observed the issues shared by you. I request you to please try using Aspose.Slides for .NET 7.8.1 on your end first. If there is still an issue then please provide the sample project with us that is reproducing the issue. We will verify the warning shared. Secondly. I suggest you to please use SlideCollection instead of Slides as this will be soon deprecated. I guess you are getting exception owing to this reason. Please try using the suggested option and in case the issue still prevails, please share the sample project with us.

Many Thanks,

Hi,
I tried using Slides for .NET v7.8.1 and I still get the warning.
Attached is the test project.

I don’t understand what you mean about the second point : i don’t use Slides : I use the Slides property of Presentation class, which is SlideCollection type … ?! But as SlideCollection inherits from Slides, the Presentation.Slides.Remove calls the Remove method from Slides Class, which was declared deprecated. Then I don’t see what I can do …

Thanks in advance for your help.

Hi Bottura,


Thanks for sharing the sample project. I have used the sample project and have been able to observe the warning message shared. Interestingly for same method there is no warning appearing in case of C#. It seems to be some comments mistake that is needed to be fixed as Presentation.Slides.Remove() message is not deprecated. I have created an issue with ID SLIDESNET-34695 as enhancement to further investigate and resolve it. I suggest you to please continue using the API.

For your second point, I have observed the warning message shared by you earlier, which gave illusion that if you were using Slides class instead of SlideCollection. Now, when I have observed the code shared by you and have found that you are using Presentation->Slides->Remove(), so this is Ok. You are using the correct property and the warning message seems to be an issue.

Many Thanks,

Hi Bottura,


I like to share that our development team has investigated the issue on their end. Actually, you have been working with methods of class that was inherited from an obsolete class. In case of using our library in C++/CLI project it calls C4996 warning. At the moment, we can’t disable this warning on our side. In our future releases (starting from next year) we’ll avoid using of obsolete classes in the internal source code.

Many Thanks,

Hi,

your sample below no longer works with Aspose.Slides v14.x.

Can you tell me how to do to export to pdf only some pages from a presentation ?

Thanks in advance.





public static void GenerateSlidePdf(Presentation pres, int SlideIndex)



{

Presentation destPres = new Presentation();

Slide slide = pres.GetSlideByPosition(SlideIndex);

//Creating SortedList object that is used to store the temporary information

//about the masters of PPT file. No value should be added to it.

System.Collections.SortedList sList = new System.Collections.SortedList();

//Cloning the selected slide at the end of another presentation file

pres.CloneSlide(slide, destPres.Slides.LastSlidePosition + 1, pres, sList);

//Rremoving defult empty slide

destPres.Slides.Remove(destPres.GetSlideByPosition(1));

destPres.Save(“D:\Aspose Data\Slide_” + SlideIndex.ToString() + “.pdf”, SaveFormat.Pdf);

}

Hi Bottura,

I have observed the requirement shared by you. Please try using the following sample code on your end to serve the purpose.

public static void GenerateSlidePdf(Presentation pres, int SlideIndex)
{
Presentation destPres = new Presentation();
ISlide slide = pres.Slides[SlideIndex-1];
//Creating SortedList object that is used to store the temporary information
//about the masters of PPT file. No value should be added to it.
System.Collections.SortedList sList = new System.Collections.SortedList();
//Cloning the selected slide at the end of another presentation file
destPres.Slides.AddClone(slide);

//Rremoving defult empty slide
destPres.Slides.RemoveAt (0);
destPres.Save(“D:\Aspose Data\Slide_” + SlideIndex.ToString() + “.pdf”, SaveFormat.Pdf);
}

Please share, if I may help you further in this regard.

Many Thanks,

It works fine.
Thank you for your help.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan