Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Tue Jun 18, 2019 8:41 am

Hello.

Is there any possibility or will be implemented cloning of a TextRange and TextParagraph, f.e. to copy them from one shape to another?

I mean, proper cloning as it is in OpenXML
Code: Select all
textRange.CloneNode(true);


Thanks in advance for response.

AdamShakhabov
 
Posts: 40
Joined: Wed Sep 26, 2018 12:03 pm

Tue Jun 18, 2019 10:28 am

Hello,

Thank you for contacting.
Our Spire.Presentation has no direct way like textRange.CloneNode(true) to clone the TextRange and TextParagraph from one shape to another, but you can refer to the following sample code to achieve it. If there is any question, to help further look into it, please share us with your sample PPT file as well as your desired effect of output. You could send them via email ([email protected]).
Code: Select all
Presentation ppt = new Presentation();
ppt.LoadFromFile(@"test.pptx");
ISlide slide = ppt.Slides[0];

//get the textRange from the first shape
TextRange textRange = (slide.Shapes[0] as IAutoShape).TextFrame.TextRange;
TextRange newTextRange = new TextRange(textRange);
//clear the textrange of second shape
(slide.Shapes[1] as IAutoShape).TextFrame.Paragraphs[0].TextRanges.Clear();
//append new textRange to the second shape
(slide.Shapes[1] as IAutoShape).TextFrame.Paragraphs[0].TextRanges.Append(newTextRange);

//get the TextParagraph from the first shape
TextParagraph tp = (slide.Shapes[0] as IAutoShape).TextFrame.Paragraphs[1];
TextParagraph newtp = new TextParagraph(tp);
//append new TextParagraph to the second shape
(slide.Shapes[1] as IAutoShape).TextFrame.Paragraphs.Append(newtp);

//save
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Mon Jun 24, 2019 2:39 am

Hello,

Greetings from E-iceblue.
Did my solution work for you? Your feedback will be greatly appreciated. Thanks in advance.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Tue Jun 25, 2019 9:18 am

Hi.

Yes, it does. Thanks.

AdamShakhabov
 
Posts: 40
Joined: Wed Sep 26, 2018 12:03 pm

Tue Jun 25, 2019 10:15 am

Hello,

Glad to hear that! If you encounter any issue related to our products in the future, just feel free to contact us. Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation