Add paragraphs from textframe to another textframe

Hello

I use the following code:
private static void CopyTextFrame(TextFrameEx destinationTextFrame, TextFrameEx sourceTextFrame)
{
destinationTextFrame.Paragraphs.Clear();
foreach (ParagraphEx par in sourceTextFrame.Paragraphs)
{
destinationTextFrame.Paragraphs.Add(new ParagraphEx(par));
}

}
when i save presentation i have following exception:

Hi,


I have observed the part of sample code shared by you and like to share that you may not use following ParagraphEx constructor to inherit the source paragraph properties.

ParagraphEx(ParagraphEx par)

Instead, you need to follow the approach explained in this documentation article to copy properties from one paragraph to another and then adding that paragraph in destination text frame paragraph collection as under.

//CopyParagraph is given in above shared link
destinationTextFrame.Paragraphs.Add(CopyParagraph(par));

You can use the article as reference and can copy all properties of ParagraphEx in CopyParagraph() method. Please use the shared sample and if there is still an issue then please share a working sample project that I may use on my end to reproduce the issue and help you further. Please also try Aspose.Slides for .NET 7.6.0 on your end for investigation.

Many Thanks,

I tried to use this function but :


i got that paragraph from chart.SecondCategoryAxis.TextProperties.Paragraphs[0]

First exception arise if i do destinationTextFrame.Paragraphs.Clear(); before paragraphs adding, where destinationTextFrame is chart.ChartTitle.Text or chart.CategoryAxis.TextProperties

Hi,


I have observed the image shared by you and also your statement that you are trying to access the paragraph of chart secondary axis. I like to share that you cannot delete the chart category axis paragraphs as it holds the formatting for automatic chart secondary axis values. You can set the properties for chart category axis to get their effect on chart. To have a more idea about formatting different chart entities please visit this documentation link for sample code. Please try using Aspose.Slides for .NET 7.6.0 on your end and if there is still an issue then please share the sample application with us that is reproducing the issue on your end along with the desired output presentation with chart category axis that you wish to generate using Aspose.Slides. I will investigate it on my end to help you as quickly as possible.

Many Thanks,

Ok. That work to set value to txtVal.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.LatinFont for example. But if i want get value from another chart i have something like “NaN”. What can i do?

Hi,

In case of Nan returning from any property, I request you to please share the source chart presentation and sample code to reproduce the issue. I will investigate the issue further on my end to help you out.

Many Thanks,

var presentation = new PresentationEx("D:\\sample.pptx");
var chart = (ChartEx) presentation.Slides[0].Shapes[0];
Console.WriteLine(chart.CategoryAxis.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight);


Hi,

Thanks for sharing the presentation. I have observed the presentation file and reproduced the issue specified. Actually, Nan is returned for predefined auto calculated value of font height. I have created an issue with ID SLIDESNET-34505 to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

Hi,

Our development team has investigated the requirement on their end. Actually, the NAN that you are getting is not an issue but a normal behavior and everything works as expected. Let me explain it. Getting individual individual properties like the following,

Console.WriteLine(chart.CategoryAxis.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight);

queries the setting made at this particular point without taking the inheritance into account. Returning NaN means that nothing is defined at this point, and it is an entirely normal behavior. But if you need to know the effective parameters including inherited ones you need to use CreateParagraphFormatData() for ParagraphEx and CreatePortionFormatData() for PortionEx instances. So changing the code and using the following will serve the purpose for you:


var presentation = new PresentationEx(“D:\Aspose Data\sample.pptx”);
var chart = (ChartEx)presentation.Slides[0].Shapes[0];
var format = chart.CategoryAxis.TextProperties.Paragraphs[0].CreateParagraphFormatData();
Console.WriteLine(format.DefaultPortionFormat.FontHeight);

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-34505) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)