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.

Mon May 21, 2018 4:54 pm

I need to step through a presentation and add two overlays - one that says "Attachment" in a burnt-orange box with white text, and one that's a section + page # constructed based on context external to the slide in question, borderless, no fill, dark grey text.

Code for the first is as follows:

(Where AddInfoBox and PageBox are Rectanflef objects declared with appropriate size & location)

Code: Select all
                        IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, AddlInfoBox);
                        shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
                        shape.TextFrame.Text = "Attachment";
                        shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
                        shape.Fill.SolidColor.Color = Color.FromArgb(173, 103, 13); // burnt orange
                        shape.Line.Style = TextLineStyle.None;
                        shape.Line.Width = 0;
                        TextRange tr = shape.TextFrame.TextRange;
                        tr.FontHeight = 12;
                        tr.LatinFont = new TextFont("Arial");
                        tr.IsBold = TriState.True;
                        tr.Fill.SolidColor.Color = Color.White;


This works correctly, [Edit: I noticed it still has a thin black border on this box as well] so I would assume that setting the correct values for the same properties would work for the second part:

Code: Select all
                       IAutoShape shape2 = slide.Shapes.AppendShape(ShapeType.Rectangle, PageBox);
                        shape2.TextFrame.Text = currentPage.ToString() + IntToLetters(++slideCount);
                        shape2.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
                        shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
                        shape2.Line.Style = TextLineStyle.None;
                        shape2.Line.Width = 0;
                        TextRange tr2 = shape2.TextFrame.TextRange;
                        tr2.FontHeight = 9;
                        tr2.LatinFont = new TextFont("Arial");
                        tr2.IsBold = TriState.False;
                        tr2.Fill.SolidColor.Color = Color.FromArgb(109, 110, 106);


This results in white text on a solid white fill with a black border. What am I missing here?


Spire.Presentation version is 3.4.1.9040.

drl2
 
Posts: 4
Joined: Thu Feb 15, 2018 3:37 pm

Tue May 22, 2018 3:20 am

Hello,

Thanks for your post.
If you want to set the shape border to be none, please change the following code
Code: Select all
shape.Line.Style = TextLineStyle.None;
shape.Line.Width = 0;

to
Code: Select all
shape.Line.FillType = FillFormatType.None;


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue May 22, 2018 5:56 pm

Thanks, that worked to remove the border from the top item. I still need to address bottom section - the attempt at a borderless, transparent background, grey-text rectangle that's displaying as a bordered, white solid fill, white text rectangle. In fact, the change that worked to remove the border from the top section, when applied to the bottom section, changed the thin black border to a thick blue one.

Attached is what it looks like now. If you look at the resulting file there's a page # like "5B" in there in white text.

Code: Select all
IAutoShape shape2 = slide.Shapes.AppendShape(ShapeType.Rectangle, PageBox);
shape2.TextFrame.Text = currentPage.ToString() + IntToLetters(++slideCount);
shape2.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
shape.Line.FillType = Spire.Presentation.Drawing.FillFormatType.None;
TextRange tr2 = shape2.TextFrame.TextRange;
tr2.FontHeight = 9;
tr2.LatinFont = new TextFont("Arial");
tr2.IsBold = TriState.False;
tr2.Fill.SolidColor.Color = Color.FromArgb(109, 110, 106);

drl2
 
Posts: 4
Joined: Thu Feb 15, 2018 3:37 pm

Wed May 23, 2018 2:39 am

Hello,

Thank you for your reply.
Kindly note the below points.
1. If you want the second shape to be borderless, set the line style for the related "shape2" object rather than "shape" object.
2. The code "shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;" could actually output a rectangle with no fill. If you would like a solid transparent fill, just refer to the below code.
Code: Select all
shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
shape2.Fill.SolidColor.Color = Color.Transparent;

3. When setting fill color, the declaration of fill pattern is indispensable.
Code: Select all
tr2.Fill.FillType = FillFormatType.Solid;//indispensable
tr2.Fill.SolidColor.Color = Color.FromArgb(109, 110, 106);


Full code:
Code: Select all
IAutoShape shape2 = slide.Shapes.AppendShape(ShapeType.Rectangle, PageBox);
shape2.TextFrame.Text = currentPage.ToString() + IntToLetters(++slideCount);
shape2.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
shape2.Fill.SolidColor.Color = Color.Transparent;
shape2.Line.FillType = Spire.Presentation.Drawing.FillFormatType.None;//this should be "shape2" object

TextRange tr2 = shape2.TextFrame.TextRange;
tr2.FontHeight = 9;
tr2.LatinFont = new TextFont("Arial");
tr2.IsBold = TriState.False;
tr2.Fill.FillType = FillFormatType.Solid;//must be before color setting, indispensable
tr2.Fill.SolidColor.Color = Color.FromArgb(109, 110, 106);


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Mon Jun 11, 2018 3:30 am

Hi drl2,

How is the issue now?
Your feedback would be greatly appreciated.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Presentation