Free Support Forum - aspose.com

Copy slide links after cloning slieds

Hello,


I have a project, part of functionality of which is to merge two or more power point presentations together according to some rules. Recently in one of source presentations which I received there were cross-slide link, interaction on one slide opened another. After this presentation was merged with another links stopped working. Simplified code which merges is below. Please advice what is the correct way to also copy a link or restore links functionality after copying.

Thank you.

static void Main(string[] args)
{
PresentationEx destinition = new PresentationEx(@"…\Destinition.pptx");
PresentationEx source = new PresentationEx(@"…\Source.pptx");
for (int i = 0; i < source.Slides.Count; i++)
{
destinition.Slides.AddClone(source.Slides[i]);
}
destinition.Save(@"…\Result.pptx", SaveFormat.Pptx);
}

Hi Vitaliy,


Thanks for inquiring Aspose.Slides.

I like to share that when you clone slides the internal hyperlinks inside them are removed. This is not an issue but a logical behavior. Suppose a presentation has some slide A that internal hyperlink pointing to some slide at position X. Now, when you will clone slide A in destination presentation the destination presentation may or may not have slide position X or even some other slide at index X. So, for this reason the internal hyperlinks are not copied in cloned presentation. In order to achieve this you need to implement your own mechanism for setting the internal hyper links accordingly.

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

Many Thanks,

totally understand and that is exactly what I figured myself. But my question was more about how exactly to figure what elements had links to what slides in original presentations, and how to re-add those back again to destination (assuming that I have a way to know new slide number in the output presentation). Please advise.


I obviously look for some universal way, which would work no matter how presentations are going to change in the future.

Hi Vitaliy,


I like to share that there is not automated or generic way to do this but one can devise his own approach to achieve this. I would suggest a solution that before cloning any slide in target presentation, you can traverse through every shape inside the presentation to be cloned and then save them in the form of list. The after cloning the slide in target presentation you can use the preserved links and may apply accordingly. Please share if I may help you further in this regard.

Many Thanks,