intsol
1
1111.png (14.8 KB)
图片中段落
左边部分 是用PPT里自带的段落符号功能
右边部分 是使用代码生成的
存在差异,是否有办法解决, 下载的demo生成的右边部分的样式
代码
para.ParagraphFormat.Bullet.Type = BulletType.Symbol;
para.ParagraphFormat.Bullet.Color.ColorType = ColorType.RGB;
para.ParagraphFormat.Bullet.Color.Color = BulletColor;
para.ParagraphFormat.Bullet.IsBulletHardColor = NullableBool.True;
@intsol,
我已经观察了这些要求,并希望分享您需要在ParagraphFormat类中将HangingPunctuation proerty设置为true以实现此目的。 请在代码中添加以下行。
para.ParagraphFormat.HangingPunctuation = NullableBool.True;
@intsol,
我请求您提供示例代码以及源代码演示和生成的输出。 一旦请求的信息将被共享,我们将能够进一步调查此问题。
intsol
5
生成的PPT样例1111.png (36.8 KB)
以下是我的代码
public void test_ppt()
{
Presentation MyPres = null;//PPT应用的实例
ISlide sld = null;//PPT中的幻灯片
ILayoutSlide blankLayout = null;
string DownLoadFilePath = string.Empty;
Paragraph para = null;
IAutoShape ashp = null;
IShape shp = null;
ITextFrame txtFrm = null;
IPPImage imgx = null;
string Paragraph = “first line word here 我是第一行\nsecond line word here 我是第二行\nthird line word here 我是第三行”;
//打开PPT
PPTCom.Instance.openPPT(ref DownLoadFilePath, ref MyPres, ref blankLayout);
//添加空页
sld = MyPres.Slides.AddEmptySlide(blankLayout);
#region 插入多行文字
ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 300, 200);
//Accessing the text frame of created autoshape
txtFrm = ashp.TextFrame;
//Removing the default exisiting paragraph
txtFrm.Paragraphs.RemoveAt(0);
var list_Paragraph = Paragraph.Split((new string[] { "\n" }), StringSplitOptions.None);
foreach (var str in list_Paragraph)
{
para = new Paragraph();
para.Text = str;
//Adding Paragraph to text frame
txtFrm.Paragraphs.Add(para);
// Setting paragraph bullet style and symbol
//文字前的样式
para.ParagraphFormat.Bullet.Type = BulletType.Symbol;
// Setting Bullet Height
para.ParagraphFormat.Bullet.Height = 100;
para.ParagraphFormat.Bullet.Char = Convert.ToChar(8226);
//位置
para.ParagraphFormat.Alignment = TextAlignment.Left;
//缩进
para.ParagraphFormat.Indent = (float)20;
////缩进
// Setting bullet color
para.ParagraphFormat.Bullet.Color.ColorType = ColorType.RGB;
para.ParagraphFormat.Bullet.Color.Color = PPTCom.Instance.RGB("000000");
para.ParagraphFormat.Bullet.IsBulletHardColor = NullableBool.True; // set IsBulletHardColor to true to use own bullet color
para.ParagraphFormat.HangingPunctuation = NullableBool.True;
// Create Portion object for paragraph
IPortion portion = para.Portions[0];
//portion.Text = "Text here";
portion.PortionFormat.FillFormat.FillType = FillType.Solid;
portion.PortionFormat.FillFormat.SolidFillColor.Color = PPTCom.Instance.RGB("000000");
//// Set font to Bold
// Set font to Bold
portion.PortionFormat.FontBold = NullableBool.True;
//// Set font to Italic
// Set font to Italic
portion.PortionFormat.FontItalic = NullableBool.True;
//字体大小
portion.PortionFormat.FontHeight = (float)22;
}
#endregion
//保存PPT
PPTCom.Instance.SavePPT(MyPres, AppDomain.CurrentDomain.BaseDirectory + DownLoadFilePath);
}
@intsol,
我观察了你的意见。您能否访问此线程链接以满足您的要求。另请访问此链接了解详细信息。如果仍有问题,请与我们分享反馈意见。