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

Free Support Forum - aspose.com

Formatting lost while cloning

Hi,

I am trying to clone slides from Ppt to other ppt using

fromPpt.cloneSlide(srcSld, slidePosition, toPpt, treeMap);

However the master slide in the toPpt lost the formatting.

Please assist.

Thanks.

Hello,

Most probably, you are missing the correct order of presentations, when cloneSlide is used. Or you might be using the already used TreeMap object.

Suppose, you want to clone sourceSlide from sourcePresntation to destinationPresentation, so it will look like this

sourcePresentation.cloneSlide(sourceSlide, 1, destinationPresentation, new TreeMap());

For more information, you should see this link.

http://www.aspose.com/documentation/file-format-components/aspose.slides-for-.net-and-java/cloning-a-slide.html

Hello Aspose team., thanks for the support.

Cloning worked fine for all the ppts and using the documentation you mentioned.

It just fails for the attached presentation , can you please assist if anything is wrong with the source.ppt or any formatting not supported by aspose.

Thanks again.

This is because of different slide sizes. You need to add this line of code to make slide sizes equal in both presentations

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

e.g

//Make the slide size of destination equals to source

destination.setSlideSize(source.getSlideSize());

A complete code example is given below.

Presentation source=new Presentation(new FileInputStream("d:\\downloads\\source.ppt"));

Presentation destination=new Presentation();

//Make the slide size of destination equals to source

destination.setSlideSize(source.getSlideSize());

int sourceLastSlidePosition=source.getSlides().getLastSlidePosition();

int destinationLastSlidePosition=source.getSlides().getLastSlidePosition();

for(int i=1; i<=sourceLastSlidePosition; i++ )

{

Slide sourceSlide=source.getSlideByPosition(i);

source.cloneSlide(sourceSlide, destinationLastSlidePosition+1, destination, new TreeMap());

destinationLastSlidePosition++;

}

destination.write(new FileOutputStream("c:\\out.ppt"));

Thanks a lot ! It solved our problem.

Not sure if I can add the below finding to the same thread:

1) I found that my header text and other attributes like headerVisible, footerVisible are not getting copied while cloning. Do I need to set these explicitly from source to destination slide.

2) My next thought would be : what all do we need to take care of while cloning slides that are not automatically cloned or copied.

Thanks team for your continued support!

1- Please provide source ppt to reproduce it.

2- You don’t need any extra step, cloneslide will take care of everything.

Attached is the ppt which has a footer but the cloned one did not get the footer text.

Hello,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I was wrong; you need to set header footer properties visible in order to display them. For example, in the above code, you will do the following change to make page number visible.

Slide dstSld=source.cloneSlide(sourceSlide, destinationLastSlidePosition+1, destination, new TreeMap());

dstSld.getHeaderFooter().setPageNumberVisible(true)

Thank you for the clarification.

From your experience - would you suggest anything else that need to be taken care off explicitly while cloning (like we have done for header properties) ?

I think, no other things are required.

Okay Thank you !!