TextBox & Title not picking up the placeholder's style

Hello.

I am trying to get all the styling for my shapes in a PPTX from a template with a master slide and some layouts. I have noticed that in order for the new shapes (which I add) to get the placeholder’s styling (font, position, etc) I must not set them in my code. But when adding a ShapeTypeEx.Rectangle in the place of a PlaceholderTypeEx.Title nothing gets picked up from the placeholder’s style, while when placing a ShapeTypeEx.Rectangle in the place of a PlaceholderTypeEx.Body the font seems to be applied but nothing else. For example, one problem is that I want the shape to use the background of the placeholder. So, I set the placeholder’s background to “No Fill” but, when the shape gets inserted, its background is blue just like in your sample here: Manage TextBox|Aspose.Slides Documentation. Do you set an initial color for background and border of the textbox that prevents the shape from picking up these settings from the placeholder? What can I do to overcome this problem?

Thanks in advance.

EDIT:
I have tried things like:

lAshp.FillFormat.FillType = FillTypeEx.NotDefined;
lAshp.FillFormat.SolidFillColor.ColorType = ColorTypeEx.NotDefined;
lAshp.LineFormat.FillFormat.FillType = FillTypeEx.NotDefined;
lAshp.LineFormat.FillFormat.SolidFillColor.ColorType = ColorTypeEx.NotDefined;

…but nothing worked.

NOTE:
I am not simply adding text in a placeholder like here:

I am putting a new shape in the place of the placeholder like the sample here:

Hi Kostas,


Thanks for your growing interest in Aspose.Slides.

I have already added an issue with ID SLIDESNET-34334 as new feature request yesterday for the shapes to inherit placeholder styling when any placeholder is added in the shape. I have linked this thread with the issue so that you may be automatically notified once the feature support will be available.

However, I request you to please share the sample application highlighting your requirements along with source and generated presentations. Please also share the snapshots of your requirements. I will append the information with above stated issue so that it may be considered when the issue will be selected for resolution.

Many Thanks,

Hello.

Thanks for your reply.

1) Has issue with ID 24422 (mentioned here: <a href="https://forum.aspose.com/t/88135) been implemented?
Is it the code that I am currently using ?

2) Is there ANY other way I can put a chart in a placeholder?

3) I am attaching a demo project and the source & generated PPTX. The app loops through the shapes with placeholders and when it finds one it generates a new shape of the specified type and assigns to it the placeholder.
There are two problems with this:
a. All text boxes fail to get most of the styling from the placeholder (they become blue).
b. Most of the shapes, like the titles, don’t change their position according to the theme (when the user changes the theme). Is it because you set the position of the shape by code yourselves when I assign the placeholder to the new shape?

What I want is :
A) All the shapes for which I include placeholders (chart, table, textbox) in the template (Source-Template.pptx) to pick up the style of the placeholder in the layout when I add them on the slide progeammatically and
B) when the user changes the theme, all the styling and positioning of elemetns to change according to the new theme.

Right now, none of these seem to work nice.

4) Can I use the normal text placeholders and do what I want at least for the TextBoxes?

Please don’t wait to answer all of the questions at once. You can reply for one question at a time. Am I stuck and I would like some feedback to move ahead.
If you need any more data or clarifications, don’t hesitate to ask.

Thanks in advance,
Kostas.

Hello.


I have some more info for you.

It seems that in order for PowerPoint to re-position the elements of the slide according to the new theme that the user selects you need to name the layout exactly as the layout of the new theme (e.g. “Title Slide”).
So, the positioning is not a problem of Aspose as far as I see.

For the issue of the background of the textboxes (Title & Body) there must be a problem with your library. It would be great if you could check from where you inherit those colors.
It works great when inserting a new slide on PowerPoint so it has to be a problem in your part.

In summary, what I want you to check (in the case of assigning a placeholder to a shape) is from where you inherit the :

1) Background colors of “Title” and “Body”.
2) Borders (color and width) of “Title” and “Body”.
3) Horizontal & vertical text alignment of “Title” and “Body”.
4) Font of “Title” (including the Bold/Italic/etc attributes).

It’s only those that I’ve noticed deviating from the default behaviour of PowerPoint (when inserting new slides) so far.
If you make those values get the respective values of the placeholder it would be great!

Also there seems to be a problem with the way you create a table. You need to specify its dimesions in advance, and even if you specify NaN for its position you can’t specify NaN for its dimensions. This seems to prevent it from picking up the placeholder’s position later on.
Can you chage this somehow (e.g. allow NaN for row/column widths)?

Best Regards,
Kostas.
Hi Kostas,

I will try to answer your queries one by one for your convenience.


kgk2000:
1) Has issue with ID 24422 (mentioned here: https://forum.aspose.com/t/88135) been implemented?
Is it the code that I am currently using ?

I like to share that this issue has already been resolved and the sample code that I shared in my conversation with you in another forum thread contains the solution where by you have added the chart inside Placeholder. Also, your project shared has also been doing the same for adding the chart in Placeholder.

kgk2000:
2) Is there ANY other way I can put a chart in a placeholder?

I regret to share that there is no other way except the already prescribed one for adding chart inside placeholder.


kgk2000:
3) I am attaching a demo project and the source & generated PPTX. The app loops through the shapes with placeholders and when it finds one it generates a new shape of the specified type and assigns to it the placeholder.
There are two problems with this:
a. All text boxes fail to get most of the styling from the placeholder (they become blue).
b. Most of the shapes, like the titles, don't change their position according to the theme (when the user changes the theme). Is it because you set the position of the shape by code yourselves when I assign the placeholder to the new shape?

In summary, what I want you to check (in the case of assigning a placeholder to a shape) is from where you inherit the :

1) Background colors of "Title" and "Body".
2) Borders (color and width) of "Title" and "Body".
3) Horizontal & vertical text alignment of "Title" and "Body".
4) Font of "Title" (including the Bold/Italic/etc attributes).


What I want is :
A) All the shapes for which I include placeholders (chart, table, textbox) in the template (Source-Template.pptx) to pick up the style of the placeholder in the layout when I add them on the slide programmatically and
B) when the user changes the theme, all the styling and positioning of elements to change according to the new theme.

Right now, none of these seem to work nice.

I have observed your requirements and I feel when the shape will inherit properties of added placeholder the above issues will be addressed. I have linked the sample project and requirements shared with issue ID SLIDESNET-34334. We will be able to share further feedback with you in this regard once the feature support will be available.

kgk2000:
4) Can I use the normal text placeholders and do what I want at least for the TextBoxes?
I have not been able to understand the requirement shared. But I like to share that one can form the text box using Aspose.Slides like other normal shapes as text box is also an AutoShapeEx instance.

kgk2000:
Also there seems to be a problem with the way you create a table. You need to specify its dimensions in advance, and even if you specify NaN for its position you can't specify NaN for its dimensions. This seems to prevent it from picking up the placeholder's position later on.
Can you chage this somehow (e.g. allow NaN for row/column widths)?

I don't feel it is possible as dimension includes number of rows and columns needed for the table to be added. Also, like PowerPoint the minimum table row height or column width that can be set is 29.


I hope this will clear the concept to you. Please share, if I may help you further in this regard.

Many Thanks,
kgk2000:
4) Can I use the normal text placeholders and do what I want at least for the TextBoxes?
I have not been able to understand the requirement shared. But I like to share that one can form the text box using Aspose.Slides like other normal shapes as text box is also an AutoShapeEx instance.

What I ask is whether I can use the old and simple text placeholders (TextHolder) and avoid the new Aspose placeholders (at least for textboxes only). In that way, I wont have to add a new shape (hopping that the placeholder properties will be applied to it) but only to insert my text into the TextHolder (that already has the properties defined). But I guess this will increase the complexity of my code (dealing with two different types of placeholders), so it's better for me to wait for you to make your modifications. I just don't know how long this can take.


kgk2000:
Also there seems to be a problem with the way you create a table. You need to specify its dimensions in advance, and even if you specify NaN for its position you can't specify NaN for its dimensions. This seems to prevent it from picking up the placeholder's position later on.
Can you change this somehow (e.g. allow NaN for row/column widths)?
I don't feel it is possible as dimension includes number of rows and columns needed for the table to be added. Also, like PowerPoint the minimum table row height or column width that can be set is 29.


My problem is that when I create a table right now it doesn't move where the theme tells it to move. The only thing that I can imagine that can cause this, is setting the table coordinates and size by code. What I would like is to be able, for example, to specify NaN for column width and row height like that (hoping that this will solve the problem) :

double NaN = double.NaN;
Slide.Shapes.AddTable(NaN, NaN, new double[]{NaN,NaN}, new double[]{NaN,NaN});

Again, you do know the number of rows & columns of the table and I think it is possible not to set it’s dimensions (or inherit them from the placeholder). Right now, the code above throws an exception because NaN is not a valid width or height. And if I specify a real value for height & width the table doesn’t follow the theme’s layout.
If you can think of any other reason that the table doesn’t move with the theme change, let me know. Right now, unfortunately, I can’t imagine anything else. :frowning:

I attach a new project that shows the problem with the table in detail. The file “Aspose vs PowerPoint (2 Slides).pptx” has two slides, one created with Aspose and one created with PowerPoint. They both use the same layout. However, the one created by PowerPoint moves the table when you change the theme (from the “Design” tab), while the one created with Aspose doesn’t.
From my understanding, by specifying a table width or height different than the one the placeholder uses, you prevent the table from following the position specified in the theme’s layout. You can verify this by modifying the table size in the slide created with PowerPoint (inside “Aspose vs PowerPoint (2 Slides).pptx”). Once you do this, the table stops following the layout of the theme.
Perhaps it’s just that the table doesn’t inherit the exact position of the placeholder assigned to it that creates the problem. If that is the case, the list of inheritance problems becomes:


1) Background colors of “Title” and “Body”.
2) Borders (color and width) of “Title” and “Body”.
3) Horizontal & vertical text alignment of “Title” and “Body”.
4) Font of “Title” (including the Bold/Italic/etc attributes).
5) Position & (mostly) size of “Table”.

I hope I have helped you locate the problem and understand my requirements. If you could provide a fix for these 5 problems soon it would be great.

Best Regards,
Kostas.

Update:

It seems that setting the dimensions of the table like that:

	double w = shape.Width / 3.0;
double h = shape.Height / 2.0;
slide.Shapes.AddTable(float.NaN, float.NaN, new double[] { w, w, w }, new double[] { h, h });

…makes the table adjust it’s width according to the theme. The height doesn’t follow (perhaps I should use a default value)…
So, setting the width of the new Table to the width of the placeholder makes at least the table width follow the theme.
I would like, if possible, some feedback on how long it may take you to address these issues and realease a new version.
Or, if you could suggest some workarounds, it would also be great.
Also, some other things that I want to ask:
  1. Is there any way to remove layouts from a master slide with Aspose (I don’t see any obvious way to do this)?
  2. How is issue with ID SLIDESNET-33471 going? I’m thinkning that if I can’t add shapes that follow the theme exactly, then perhaps I could re-apply a new theme…

Best Regards,
Kostas.

Hi Kostas,


I like to share that the concerned issue associated with this thread has been created just recently. It is in waiting queue for investigation. Actually, as per Aspose policy, the issues related to Aspose.Priority and Aspose.Enterprise support forum (paid support) are considered for investigation first. Then based on their complexity they are scheduled for resolution. After resolution paid support customer issues the issues belonging to normal support forums like Aspose.Slides or Aspose.Total are selected for investigation on first come and first serve basis. Then based on their complexity they are scheduled for resolution. In my opinion, the requirement highlighted by you involves complexity in implementation. However, I will be able to further comment on this only when the issue will be scheduled for investigation by our development on its due turn.

Unfortunately, I am unable to offer any workaround at this point of time in this regard. However, I may suggest you to use copy paragraph and copy portions features mentioned over this documentation link for inheriting the source placeholder text formatting to target placeholder. Likewise, you can also develop an approach to copy some basis properties of source placeholder shapes to added target placeholder shape.

Many Thanks,

Here is what I use to copy the format from the placeholder to the shape (for textboxes):


		public static void CopyTextBoxFormat(AutoShapeEx pSrcShape, AutoShapeEx pDestShape)
{
// Copy Paragraph Formatting.
ParagraphEx lSrcPar = pSrcShape.TextFrame.Paragraphs[0];
ParagraphEx lDestPar = pDestShape.TextFrame.Paragraphs[0];
		<span style="color:#2b91af;">ParagraphFormatDataEx</span> lParaData = lSrcPar.CreateParagraphFormatData();

		lDestPar.ParagraphFormat.Alignment = lParaData.Alignment;
		lDestPar.ParagraphFormat.DefaultTabSize = lParaData.DefaultTabSize;
		lDestPar.ParagraphFormat.MarginLeft = lParaData.MarginLeft;
		lDestPar.ParagraphFormat.MarginRight = lParaData.MarginRight;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;
		lDestPar.ParagraphFormat.Indent = lParaData.Indent;
		lDestPar.ParagraphFormat.Depth = lParaData.Depth;
		lDestPar.ParagraphFormat.SpaceAfter = lParaData.SpaceAfter;
		lDestPar.ParagraphFormat.SpaceBefore = lParaData.SpaceBefore;
		lDestPar.ParagraphFormat.SpaceWithin = lParaData.SpaceWithin;

		lDestPar.ParagraphFormat.BulletType = lParaData.BulletType;
		lDestPar.ParagraphFormat.BulletChar = lParaData.BulletChar;
		lDestPar.ParagraphFormat.BulletColor.Color = lParaData.BulletColor;
		lDestPar.ParagraphFormat.BulletHeight = lParaData.BulletHeight;
		lDestPar.ParagraphFormat.BulletFont = lParaData.BulletFont;
		lDestPar.ParagraphFormat.NumberedBulletStyle = lParaData.NumberedBulletStyle;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;

		lDestPar.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = lParaData.DefaultPortionFormat.FillFormat.FillType;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontBold = lParaData.DefaultPortionFormat.FontBold ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontItalic = lParaData.DefaultPortionFormat.FontItalic ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontUnderline = lParaData.DefaultPortionFormat.FontUnderline;


		<span style="color:green;">// Copy Portion Format.</span>
		<span style="color:#2b91af;">PortionEx</span> lSrcPort = lSrcPar.Portions[0];
		<span style="color:#2b91af;">PortionEx</span> lDestPort = lDestPar.Portions[0];

		lDestPort.PortionFormat.FillFormat.FillType = lSrcPort.PortionFormat.FillFormat.FillType;
		lDestPort.PortionFormat.FillFormat.SolidFillColor.Color = lSrcPort.PortionFormat.FillFormat.SolidFillColor.Color;
		lDestPort.PortionFormat.FontBold = lSrcPort.PortionFormat.FontBold;
		lDestPort.PortionFormat.FontHeight = lSrcPort.PortionFormat.FontHeight;
		lDestPort.PortionFormat.FontBold = lSrcPort.PortionFormat.FontItalic;
		lDestPort.PortionFormat.FontUnderline = lSrcPort.PortionFormat.FontUnderline;
		lDestPort.PortionFormat.LatinFont = lSrcPort.PortionFormat.LatinFont;
		lDestPort.PortionFormat.EastAsianFont = lSrcPort.PortionFormat.EastAsianFont;
		lDestPort.PortionFormat.ComplexScriptFont = lSrcPort.PortionFormat.ComplexScriptFont;
		lDestPort.PortionFormat.FontBold = lSrcPort.PortionFormat.NormaliseHeight;
		lDestPort.PortionFormat.FontBold = lSrcPort.PortionFormat.ProofDisabled;
		lDestPort.PortionFormat.SmartTagClean = lSrcPort.PortionFormat.SmartTagClean;
		lDestPort.PortionFormat.Spacing = lSrcPort.PortionFormat.Spacing;
		lDestPort.PortionFormat.StrikethroughType = lSrcPort.PortionFormat.StrikethroughType;
		lDestPort.PortionFormat.SymbolFont = lSrcPort.PortionFormat.SymbolFont;
		lDestPort.PortionFormat.TextCapType = lSrcPort.PortionFormat.TextCapType;
		lDestPort.PortionFormat.Escapement = lSrcPort.PortionFormat.Escapement;

// lDestPort.PortionFormat.UnderlineFillFormat = lSrcPort.PortionFormat.UnderlineFillFormat;
// lDestPort.PortionFormat.UnderlineLineFormat = lSrcPort.PortionFormat.UnderlineLineFormat;
// lDestPort.PortionFormat.HighlightColor = lSrcPort.PortionFormat.HighlightColor;

		<span style="color:green;">// Copy Fill.</span>
		pDestShape.FillFormat.SolidFillColor.PresetColor = pSrcShape.FillFormat.SolidFillColor.PresetColor;
		pDestShape.FillFormat.SolidFillColor.ColorType = pSrcShape.FillFormat.SolidFillColor.ColorType;
		pDestShape.FillFormat.SolidFillColor.Saturation = pSrcShape.FillFormat.SolidFillColor.Saturation;
		pDestShape.FillFormat.SolidFillColor.SchemeColor = pSrcShape.FillFormat.SolidFillColor.SchemeColor;
		pDestShape.FillFormat.SolidFillColor.SystemColor = pSrcShape.FillFormat.SolidFillColor.SystemColor;
		pDestShape.FillFormat.FillType = pSrcShape.FillFormat.FillType;
		pDestShape.FillFormat.SolidFillColor.Color = pSrcShape.FillFormat.SolidFillColor.Color;

		<span style="color:green;">// Copy Border (Line).</span>
		pDestShape.LineFormat.FillFormat.SolidFillColor.PresetColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.PresetColor;
		pDestShape.LineFormat.FillFormat.SolidFillColor.ColorType = pSrcShape.LineFormat.FillFormat.SolidFillColor.ColorType;
		pDestShape.LineFormat.FillFormat.SolidFillColor.Saturation = pSrcShape.LineFormat.FillFormat.SolidFillColor.Saturation;
		pDestShape.LineFormat.FillFormat.SolidFillColor.SchemeColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SchemeColor;
		pDestShape.LineFormat.FillFormat.SolidFillColor.SystemColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SystemColor;
		pDestShape.LineFormat.FillFormat.FillType = pSrcShape.LineFormat.FillFormat.FillType;
		pDestShape.LineFormat.FillFormat.SolidFillColor.Color = pSrcShape.LineFormat.FillFormat.SolidFillColor.Color;

		pDestShape.LineFormat.FillFormat.GradientFormat.GradientDirection = pSrcShape.LineFormat.FillFormat.GradientFormat.GradientDirection;
		pDestShape.LineFormat.FillFormat.GradientFormat.GradientShape = pSrcShape.LineFormat.FillFormat.GradientFormat.GradientShape;
		<span style="color:green;">//pDestShape.LineFormat.FillFormat.GradientFormat.GradientStops = pSrcShape.LineFormat.FillFormat.GradientFormat.GradientStops;</span>
		pDestShape.LineFormat.FillFormat.GradientFormat.LinearGradientAngle = pSrcShape.LineFormat.FillFormat.GradientFormat.LinearGradientAngle;
		pDestShape.LineFormat.FillFormat.GradientFormat.LinearGradientScaled = pSrcShape.LineFormat.FillFormat.GradientFormat.LinearGradientScaled;
		pDestShape.LineFormat.FillFormat.GradientFormat.TileFlip = pSrcShape.LineFormat.FillFormat.GradientFormat.TileFlip;

		pDestShape.LineFormat.Style = pSrcShape.LineFormat.Style;
		pDestShape.LineFormat.Width = pSrcShape.LineFormat.Width;
		pDestShape.LineFormat.MiterLimit = pSrcShape.LineFormat.MiterLimit;
		pDestShape.LineFormat.JoinStyle = pSrcShape.LineFormat.JoinStyle;
		pDestShape.LineFormat.EndArrowheadWidth = pSrcShape.LineFormat.EndArrowheadWidth;
		pDestShape.LineFormat.EndArrowheadStyle = pSrcShape.LineFormat.EndArrowheadStyle;
		pDestShape.LineFormat.EndArrowheadLength = pSrcShape.LineFormat.EndArrowheadLength;
		pDestShape.LineFormat.DashStyle = pSrcShape.LineFormat.DashStyle;
		pDestShape.LineFormat.CustomDashPattern = pSrcShape.LineFormat.CustomDashPattern;
		pDestShape.LineFormat.CapStyle = pSrcShape.LineFormat.CapStyle;
		pDestShape.LineFormat.BeginArrowheadWidth = pSrcShape.LineFormat.BeginArrowheadWidth;
		pDestShape.LineFormat.BeginArrowheadStyle = pSrcShape.LineFormat.BeginArrowheadStyle;
		pDestShape.LineFormat.BeginArrowheadLength = pSrcShape.LineFormat.BeginArrowheadLength;
		pDestShape.LineFormat.Alignment = pSrcShape.LineFormat.Alignment;
	}

…or using the “CreateData” functions:


		public static void CopyTextBoxFormat(AutoShapeEx pSrcShape, AutoShapeEx pDestShape)
{
// Copy Paragraph Formatting.
ParagraphEx lSrcPar = pSrcShape.TextFrame.Paragraphs[0];
ParagraphEx lDestPar = pDestShape.TextFrame.Paragraphs[0];
		<span style="color:#2b91af;">ParagraphFormatDataEx</span> lParaData = lSrcPar.CreateParagraphFormatData();

		lDestPar.ParagraphFormat.Alignment = lParaData.Alignment;
		lDestPar.ParagraphFormat.DefaultTabSize = lParaData.DefaultTabSize;
		lDestPar.ParagraphFormat.MarginLeft = lParaData.MarginLeft;
		lDestPar.ParagraphFormat.MarginRight = lParaData.MarginRight;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;
		lDestPar.ParagraphFormat.Indent = lParaData.Indent;
		lDestPar.ParagraphFormat.Depth = lParaData.Depth;
		lDestPar.ParagraphFormat.SpaceAfter = lParaData.SpaceAfter;
		lDestPar.ParagraphFormat.SpaceBefore = lParaData.SpaceBefore;
		lDestPar.ParagraphFormat.SpaceWithin = lParaData.SpaceWithin;

		lDestPar.ParagraphFormat.BulletType = lParaData.BulletType;
		lDestPar.ParagraphFormat.BulletChar = lParaData.BulletChar;
		lDestPar.ParagraphFormat.BulletColor.Color = lParaData.BulletColor;
		lDestPar.ParagraphFormat.BulletHeight = lParaData.BulletHeight;
		lDestPar.ParagraphFormat.BulletFont = lParaData.BulletFont;
		lDestPar.ParagraphFormat.NumberedBulletStyle = lParaData.NumberedBulletStyle;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;

		lDestPar.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = lParaData.DefaultPortionFormat.FillFormat.FillType;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontBold = lParaData.DefaultPortionFormat.FontBold ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontItalic = lParaData.DefaultPortionFormat.FontItalic ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontUnderline = lParaData.DefaultPortionFormat.FontUnderline;


		<span style="color:green;">// Copy Portion Format.</span>
		<span style="color:blue;">var</span> lSrcPort = lSrcPar.Portions[0].CreatePortionFormatData();
		<span style="color:blue;">var</span> lDestPort = lDestPar.Portions[0];

		lDestPort.PortionFormat.FillFormat.FillType = lSrcPort.FillFormat.FillType;
		lDestPort.PortionFormat.FillFormat.SolidFillColor.Color = lSrcPar.Portions[0].FillFormat.SolidFillColor.Color;
		lDestPort.PortionFormat.FontBold = lSrcPort.FontBold ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontHeight = lSrcPort.FontHeight;
		lDestPort.PortionFormat.FontBold = lSrcPort.FontItalic ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontUnderline = lSrcPort.FontUnderline;
		lDestPort.PortionFormat.LatinFont = lSrcPort.LatinFont;
		lDestPort.PortionFormat.EastAsianFont = lSrcPort.EastAsianFont;
		lDestPort.PortionFormat.ComplexScriptFont = lSrcPort.ComplexScriptFont;
		lDestPort.PortionFormat.FontBold = lSrcPort.NormaliseHeight ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontBold = lSrcPort.ProofDisabled ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.SmartTagClean = lSrcPort.SmartTagClean;
		lDestPort.PortionFormat.Spacing = lSrcPort.Spacing;
		lDestPort.PortionFormat.StrikethroughType = lSrcPort.StrikethroughType;
		lDestPort.PortionFormat.SymbolFont = lSrcPort.SymbolFont;
		lDestPort.PortionFormat.TextCapType = lSrcPort.TextCapType;
		lDestPort.PortionFormat.Escapement = lSrcPort.Escapement;

// lDestPort.PortionFormat.UnderlineFillFormat = lSrcPort.PortionFormat.UnderlineFillFormat;
// lDestPort.PortionFormat.UnderlineLineFormat = lSrcPort.PortionFormat.UnderlineLineFormat;
// lDestPort.PortionFormat.HighlightColor = lSrcPort.PortionFormat.HighlightColor;

		<span style="color:green;">// Copy Fill.</span>
		<span style="color:blue;">var</span> lSrcFillFmt = pSrcShape.CreateFillFormatData();
		<span style="color:blue;">var</span> lDestFileFmt = pDestShape.FillFormat;

		lDestFileFmt.SolidFillColor.PresetColor = pSrcShape.FillFormat.SolidFillColor.PresetColor;
		lDestFileFmt.SolidFillColor.ColorType = pSrcShape.FillFormat.SolidFillColor.ColorType;
		lDestFileFmt.SolidFillColor.Saturation = pSrcShape.FillFormat.SolidFillColor.Saturation;
		lDestFileFmt.SolidFillColor.SchemeColor = pSrcShape.FillFormat.SolidFillColor.SchemeColor;
		lDestFileFmt.SolidFillColor.SystemColor = pSrcShape.FillFormat.SolidFillColor.SystemColor;
		lDestFileFmt.FillType = lSrcFillFmt.FillType;
		lDestFileFmt.SolidFillColor.Color = pSrcShape.FillFormat.SolidFillColor.Color;

		<span style="color:green;">// Copy Border (Line).</span>
		<span style="color:blue;">var</span> lSrcLineFmt = pSrcShape.CreateLineFormatData();
		<span style="color:blue;">var</span> lDestLineFmt = pDestShape.LineFormat;

		lDestLineFmt.FillFormat.SolidFillColor.PresetColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.PresetColor;
		lDestLineFmt.FillFormat.SolidFillColor.ColorType = pSrcShape.LineFormat.FillFormat.SolidFillColor.ColorType;
		lDestLineFmt.FillFormat.SolidFillColor.Saturation = pSrcShape.LineFormat.FillFormat.SolidFillColor.Saturation;
		lDestLineFmt.FillFormat.SolidFillColor.SchemeColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SchemeColor;
		lDestLineFmt.FillFormat.SolidFillColor.SystemColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SystemColor;
		lDestLineFmt.FillFormat.FillType = lSrcLineFmt.FillFormat.FillType;
		lDestLineFmt.FillFormat.SolidFillColor.Color = pSrcShape.LineFormat.FillFormat.SolidFillColor.Color;

		lDestLineFmt.FillFormat.GradientFormat.GradientDirection = lSrcLineFmt.FillFormat.GradientFormat.GradientDirection;
		lDestLineFmt.FillFormat.GradientFormat.GradientShape = lSrcLineFmt.FillFormat.GradientFormat.GradientShape;
		<span style="color:green;">//lDestLineFmt.FillFormat.GradientFormat.GradientStops = pSrcShape.LineFormat.FillFormat.GradientFormat.GradientStops;</span>
		lDestLineFmt.FillFormat.GradientFormat.LinearGradientAngle = lSrcLineFmt.FillFormat.GradientFormat.LinearGradientAngle;
		lDestLineFmt.FillFormat.GradientFormat.LinearGradientScaled = lSrcLineFmt.FillFormat.GradientFormat.LinearGradientScaled ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestLineFmt.FillFormat.GradientFormat.TileFlip = lSrcLineFmt.FillFormat.GradientFormat.TileFlip;

		lDestLineFmt.Style = lSrcLineFmt.Style;
		lDestLineFmt.Width = lSrcLineFmt.Width;
		lDestLineFmt.MiterLimit = lSrcLineFmt.MiterLimit;
		lDestLineFmt.JoinStyle = lSrcLineFmt.JoinStyle;
		lDestLineFmt.EndArrowheadWidth = lSrcLineFmt.EndArrowheadWidth;
		lDestLineFmt.EndArrowheadStyle = lSrcLineFmt.EndArrowheadStyle;
		lDestLineFmt.EndArrowheadLength = lSrcLineFmt.EndArrowheadLength;
		lDestLineFmt.DashStyle = lSrcLineFmt.DashStyle;
		lDestLineFmt.CustomDashPattern = lSrcLineFmt.CustomDashPattern;
		lDestLineFmt.CapStyle = lSrcLineFmt.CapStyle;
		lDestLineFmt.BeginArrowheadWidth = lSrcLineFmt.BeginArrowheadWidth;
		lDestLineFmt.BeginArrowheadStyle = lSrcLineFmt.BeginArrowheadStyle;
		lDestLineFmt.BeginArrowheadLength = lSrcLineFmt.BeginArrowheadLength;
		lDestLineFmt.Alignment = lSrcLineFmt.Alignment;
	}</pre></pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;">Again, it breaks the theming.

The background, the border and the font color (and perhaps more than these) stop following the theme…

You do you implement the inheritance of the styling from the placeholder?
Do you copy the values as I try to do or there is some internal XML handling that I can’t do with Aspose by myself?
Best Regards,
Kostas.

Hi Kostas,


I have observed the sample code shared by you and request you to please share the sample application along with source and generated presentation. Please also share the desired presentation and I will work with your sample application to investigate the possibilities available to achieve the desired output. I like to re-iterate here as well the concerned issue attached with this thread actually refers to inheriting the associated placeholder properties to any given shape. So, when the issue will be investigated and resolved by our development team, I am hopeful that the issue will get resolved.

Many Thanks,
Hello.

I am attaching a sample project with:
  1. A template PPTX (with a master and a layout).
  2. A desired generated PPTX.
  3. An Aspose-generated PPTX where I did NOT copy by code the styling of the placeholder to each shape. In this PPTX the textboxes do follow the theme changes, but the starting/initial textboxes (before the user changes the theme) don't have most of the styling of the placeholder.
  4. An Aspose-generated PPTX where I did copy by code the styling of the placeholder to each shape. In this PPTX the textboxes do NOT follow the theme changes, but the starting/initial textboxes (before the user changes the theme) have most (if not all) of the styling of the placeholder.

What I want is the textboxes to follow the theme changes (when the user changes the theme from the Design tab) AND have the placeholder's styling before the user makes any changes to the theme.
The desired output is shown in a separate PPTX. This file has a slide that was created with PowerPoint from the same layout used by Aspose. This works great. The ones created with Aspose have problems.

Best Regards,
Kostas.
This is my updated code for copying the styling (nothing changes to my problems):

		public static void CopyTextBoxFormat(AutoShapeEx pSrcShape, AutoShapeEx pDestShape)
	{
		<span style="color:green;">//return;</span>

		<span style="color:#2b91af;">TextFrameEx</span> lSrcTf = pSrcShape.TextFrame;
		<span style="color:#2b91af;">TextFrameEx</span> lDestTf = pDestShape.TextFrame;

		<span style="color:green;">// Copy TextFrame Styling.</span>
		lDestTf.TextVerticalType = lSrcTf.TextVerticalType;
		lDestTf.WrapText = lSrcTf.WrapText;
		lDestTf.MarginTop = lSrcTf.MarginTop;
		lDestTf.MarginRight = lSrcTf.MarginRight;
		lDestTf.MarginLeft = lSrcTf.MarginLeft;
		lDestTf.MarginBottom = lSrcTf.MarginBottom;
		lDestTf.CenterText = lSrcTf.CenterText;
		lDestTf.AutofitType = lSrcTf.AutofitType;
		lDestTf.AnchoringType = lSrcTf.AnchoringType;

		<span style="color:green;">// Copy Paragraph Formatting.</span>
		<span style="color:#2b91af;">ParagraphEx</span> lSrcPar = lSrcTf.Paragraphs[0];
		<span style="color:#2b91af;">ParagraphEx</span> lDestPar = lDestTf.Paragraphs[0];

		<span style="color:#2b91af;">ParagraphFormatDataEx</span> lParaData = lSrcPar.CreateParagraphFormatData();

		lDestPar.ParagraphFormat.Alignment = lParaData.Alignment;
		lDestPar.ParagraphFormat.DefaultTabSize = lParaData.DefaultTabSize;
		lDestPar.ParagraphFormat.MarginLeft = lParaData.MarginLeft;
		lDestPar.ParagraphFormat.MarginRight = lParaData.MarginRight;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;
		lDestPar.ParagraphFormat.Indent = lParaData.Indent;
		lDestPar.ParagraphFormat.Depth = lParaData.Depth;
		lDestPar.ParagraphFormat.SpaceAfter = lParaData.SpaceAfter;
		lDestPar.ParagraphFormat.SpaceBefore = lParaData.SpaceBefore;
		lDestPar.ParagraphFormat.SpaceWithin = lParaData.SpaceWithin;

		lDestPar.ParagraphFormat.BulletType = lParaData.BulletType;
		lDestPar.ParagraphFormat.BulletChar = lParaData.BulletChar;
		lDestPar.ParagraphFormat.BulletColor.Color = lParaData.BulletColor;
		lDestPar.ParagraphFormat.BulletHeight = lParaData.BulletHeight;
		lDestPar.ParagraphFormat.BulletFont = lParaData.BulletFont;
		lDestPar.ParagraphFormat.NumberedBulletStyle = lParaData.NumberedBulletStyle;
		lDestPar.ParagraphFormat.FontAlignment = lParaData.FontAlignment;

		lDestPar.ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = lParaData.DefaultPortionFormat.FillFormat.FillType;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontBold = lParaData.DefaultPortionFormat.FontBold ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontItalic = lParaData.DefaultPortionFormat.FontItalic ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPar.ParagraphFormat.DefaultPortionFormat.FontUnderline = lParaData.DefaultPortionFormat.FontUnderline;


		<span style="color:green;">// Copy Portion Format.</span>
		<span style="color:blue;">var</span> lSrcPort = lSrcPar.Portions[0].CreatePortionFormatData();
		<span style="color:blue;">var</span> lDestPort = lDestPar.Portions[0];

		lDestPort.PortionFormat.FillFormat.FillType = lSrcPort.FillFormat.FillType;
		lDestPort.PortionFormat.FillFormat.SolidFillColor.Color = GetColorCopy(lSrcPort.FillFormat.SolidFillColor); <span style="color:green;">//lSrcPar.Portions[0].FillFormat.SolidFillColor.Color;</span>
		lDestPort.PortionFormat.FontBold = lSrcPort.FontBold ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontHeight = lSrcPort.FontHeight;
		lDestPort.PortionFormat.FontBold = lSrcPort.FontItalic ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontUnderline = lSrcPort.FontUnderline;
		lDestPort.PortionFormat.LatinFont = lSrcPort.LatinFont;
		lDestPort.PortionFormat.EastAsianFont = lSrcPort.EastAsianFont;
		lDestPort.PortionFormat.ComplexScriptFont = lSrcPort.ComplexScriptFont;
		lDestPort.PortionFormat.FontBold = lSrcPort.NormaliseHeight ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.FontBold = lSrcPort.ProofDisabled ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestPort.PortionFormat.SmartTagClean = lSrcPort.SmartTagClean;
		lDestPort.PortionFormat.Spacing = lSrcPort.Spacing;
		lDestPort.PortionFormat.StrikethroughType = lSrcPort.StrikethroughType;
		lDestPort.PortionFormat.SymbolFont = lSrcPort.SymbolFont;
		lDestPort.PortionFormat.TextCapType = lSrcPort.TextCapType;
		lDestPort.PortionFormat.Escapement = lSrcPort.Escapement;

// lDestPort.PortionFormat.UnderlineFillFormat = lSrcPort.PortionFormat.UnderlineFillFormat;
// lDestPort.PortionFormat.UnderlineLineFormat = lSrcPort.PortionFormat.UnderlineLineFormat;
// lDestPort.PortionFormat.HighlightColor = lSrcPort.PortionFormat.HighlightColor;

		<span style="color:green;">// Copy Fill.</span>
		<span style="color:blue;">var</span> lSrcFillFmt = pSrcShape.CreateFillFormatData();
		<span style="color:blue;">var</span> lDestFileFmt = pDestShape.FillFormat;

		lDestFileFmt.SolidFillColor.PresetColor = pSrcShape.FillFormat.SolidFillColor.PresetColor;
		lDestFileFmt.SolidFillColor.ColorType = pSrcShape.FillFormat.SolidFillColor.ColorType;
		lDestFileFmt.SolidFillColor.Saturation = pSrcShape.FillFormat.SolidFillColor.Saturation;
		lDestFileFmt.SolidFillColor.SchemeColor = pSrcShape.FillFormat.SolidFillColor.SchemeColor;
		lDestFileFmt.SolidFillColor.SystemColor = pSrcShape.FillFormat.SolidFillColor.SystemColor;
		lDestFileFmt.FillType = lSrcFillFmt.FillType;
		lDestFileFmt.SolidFillColor.Color = GetColorCopy(lSrcFillFmt.SolidFillColor); <span style="color:green;">//pSrcShape.FillFormat.SolidFillColor.Color;</span>

		<span style="color:green;">// Copy Border (Line).</span>
		<span style="color:blue;">var</span> lSrcLineFmt = pSrcShape.CreateLineFormatData();
		<span style="color:blue;">var</span> lDestLineFmt = pDestShape.LineFormat;

		lDestLineFmt.FillFormat.SolidFillColor.PresetColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.PresetColor;
		lDestLineFmt.FillFormat.SolidFillColor.ColorType = pSrcShape.LineFormat.FillFormat.SolidFillColor.ColorType;
		lDestLineFmt.FillFormat.SolidFillColor.Saturation = pSrcShape.LineFormat.FillFormat.SolidFillColor.Saturation;
		lDestLineFmt.FillFormat.SolidFillColor.SchemeColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SchemeColor;
		lDestLineFmt.FillFormat.SolidFillColor.SystemColor = pSrcShape.LineFormat.FillFormat.SolidFillColor.SystemColor;
		lDestLineFmt.FillFormat.FillType = lSrcLineFmt.FillFormat.FillType;
		lDestLineFmt.FillFormat.SolidFillColor.Color = GetColorCopy(lSrcLineFmt.FillFormat.SolidFillColor); <span style="color:green;">//pSrcShape.LineFormat.FillFormat.SolidFillColor.Color;</span>

		lDestLineFmt.FillFormat.GradientFormat.GradientDirection = lSrcLineFmt.FillFormat.GradientFormat.GradientDirection;
		lDestLineFmt.FillFormat.GradientFormat.GradientShape = lSrcLineFmt.FillFormat.GradientFormat.GradientShape;
		<span style="color:green;">//lDestLineFmt.FillFormat.GradientFormat.GradientStops = pSrcShape.LineFormat.FillFormat.GradientFormat.GradientStops;</span>
		lDestLineFmt.FillFormat.GradientFormat.LinearGradientAngle = lSrcLineFmt.FillFormat.GradientFormat.LinearGradientAngle;
		lDestLineFmt.FillFormat.GradientFormat.LinearGradientScaled = lSrcLineFmt.FillFormat.GradientFormat.LinearGradientScaled ? <span style="color:#2b91af;">NullableBool</span>.True : <span style="color:#2b91af;">NullableBool</span>.False;
		lDestLineFmt.FillFormat.GradientFormat.TileFlip = lSrcLineFmt.FillFormat.GradientFormat.TileFlip;

		lDestLineFmt.Style = lSrcLineFmt.Style;
		lDestLineFmt.Width = lSrcLineFmt.Width;
		lDestLineFmt.MiterLimit = lSrcLineFmt.MiterLimit;
		lDestLineFmt.JoinStyle = lSrcLineFmt.JoinStyle;
		lDestLineFmt.EndArrowheadWidth = lSrcLineFmt.EndArrowheadWidth;
		lDestLineFmt.EndArrowheadStyle = lSrcLineFmt.EndArrowheadStyle;
		lDestLineFmt.EndArrowheadLength = lSrcLineFmt.EndArrowheadLength;
		lDestLineFmt.DashStyle = lSrcLineFmt.DashStyle;
		lDestLineFmt.CustomDashPattern = lSrcLineFmt.CustomDashPattern;
		lDestLineFmt.CapStyle = lSrcLineFmt.CapStyle;
		lDestLineFmt.BeginArrowheadWidth = lSrcLineFmt.BeginArrowheadWidth;
		lDestLineFmt.BeginArrowheadStyle = lSrcLineFmt.BeginArrowheadStyle;
		lDestLineFmt.BeginArrowheadLength = lSrcLineFmt.BeginArrowheadLength;
		lDestLineFmt.Alignment = lSrcLineFmt.Alignment;
	}</pre><pre style="font-family: Consolas; font-size: 13px; background-color: white; background-position: initial initial; background-repeat: initial initial;"><br></pre>

Hi Kostas,


Thank you for sharing the code. I am observing and working over the solution provided and need some time in this regard to try available options if there are any in your scenario. I will share the feedback with you as soon as I will complete my investigation.

Many Thanks,

Hi Kostas,


I have worked with the sample code shared by you in your last post and the presentation generated is same as desired. Please observe the attached image and generated presentation for your kind reference. Can you please share what difference your pointing to in desired presentation that is not available in Aspose generated presentation.

Many Thanks,

Hello,


The difference appears when you try to change the theme from the Design tab.
While the “Desired” updates the textboxes with the new styling (font name , fotn size, etc) when the theme changes, the “Generated” does not.

Best Regards,
Kostas

Hi Kostas,


I have observed the requirement shared. I like to suggest another approach that you can use on your end. You can have different slide layout types with desired slide types you want to have in your target presentation. The layout slides can be combination of different types of placeholders as per your requirement. Then you can add slides in presentation using Aspose.Slides and follow any layout slide from added layout slide list. The placeholder following the respective layout slides will be added and this way you will have a slide that will be having same number and types of placeholder as you have in layout slide. They will follow the design changes when you will change in master slides.

var presentation = new PresentationEx(path + “Source-Template.pptx”);
//var presentation = new PresentationEx();
presentation.UpdateDateTimeFields = true;
int id = presentation.Slides.AddEmptySlide(presentation.LayoutSlides[0]);

SlideEx slide = presentation.Slides[id];

foreach (ShapeEx shape in slide.Shapes)
{
if (shape.Placeholder != null)
{
switch (shape.Placeholder.Type)
{
case PlaceholderTypeEx.Object:
{
AutoShapeEx lAshp = (AutoShapeEx)shape;
lAshp.TextFrame.Paragraphs[0].Portions[0].Text = “Afafdfa”;
}
break;
case PlaceholderTypeEx.Title:
{
AutoShapeEx lAshp = (AutoShapeEx)shape;
lAshp.TextFrame.Paragraphs[0].Portions[0].Text = “This is my test !!!”;
}
break;
}
}
}
//string str = @“C:\Users\kgk\Documents\visual studio 2012\Projects\del3\Generated” + (bCopyTextBoxFormat ? “(CopyPlaceholderFormat)" : “”) + “.pptx”;
string str = path+"Generated_3” + (bCopyTextBoxFormat ? “_(CopyPlaceholderFormat)” : “”) + “.pptx”;
presentation.Save(str, Aspose.Slides.Export.SaveFormat.Pptx);


This is different from your previous requirement for adding a placeholder in slides and following the formatting of any selected placeholder you wish to. In the old solution, you were in fact copying the properties from one place holder to other shape. This was not in fact maintaining the link that if you make a change in source placeholder it will also get reflected in another placeholder shape where by you have copied the previous values. I hope the above solution will certainly solve the issue on your end.

Many Thanks,

That works.

Thanks!

Hi Kostas,


That is really appreciable that things worked on your end. Please share, if I may help you further in this regard.

Many Thanks,

No. Everything is OK now. :slight_smile:

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