C#向Word插入排版精良的TextBox
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Doc;
using Spire.Doc.Fields;
using Spire.Doc.Documents;
using System.Drawing;
namespace textbox
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();
document.LoadFromFile("李白生平.docx");
TextBox TB = document.Sections[0].Paragraphs[0].AppendTextBox(150, 300);
TB.Format.HorizontalOrigin = HorizontalOrigin.Page;
TB.Format.HorizontalPosition = 370;
TB.Format.VerticalOrigin = VerticalOrigin.Page;
TB.Format.VerticalPosition = 155;
TB.Format.TextWrappingStyle = TextWrappingStyle.Square;
TB.Format.TextWrappingType = TextWrappingType.Both;
TB.Format.LineStyle = TextBoxLineStyle.Double;
TB.Format.LineColor = Color.LightGoldenrodYellow;
TB.Format.LineDashing = LineDashing.Solid;
TB.Format.LineWidth = 3;
TB.Format.InternalMargin.Top = 12;
TB.Format.InternalMargin.Bottom = 8;
TB.Format.InternalMargin.Left = 12;
TB.Format.InternalMargin.Right = 12;
TB.Format.FillEfects.Type = BackgroundType.Picture;
TB.Format.FillEfects.Picture = Image.FromFile("2.jpg");
Paragraph para1 = TB.Body.AddParagraph();
para1.Format.AfterSpacing = 6;
para1.Format.HorizontalAlignment = HorizontalAlignment.Center;
TextRange TR1 = para1.AppendText("李白");
TR1.CharacterFormat.FontName = "华文新魏";
TR1.CharacterFormat.FontSize = 16;
TR1.CharacterFormat.Bold = true;
Paragraph para2 = TB.Body.AddParagraph();
Image image = Image.FromFile("李白.jpg");
DocPicture picture = para2.AppendPicture(image);
picture.Width = 120;
picture.Height = 160;
para2.Format.AfterSpacing = 8;
para2.Format.HorizontalAlignment = HorizontalAlignment.Center;
Paragraph para3 = TB.Body.AddParagraph();
TextRange TR2 = para3.AppendText("盛唐最杰出的诗人,中国历史最伟大的浪漫主义诗人杜甫赞其文章“笔落惊风雨,诗成泣鬼神”");
TR2.CharacterFormat.FontName = "华文新魏";
TR2.CharacterFormat.FontSize = 11;
para3.Format.LineSpacing = 15;
para3.Format.HorizontalAlignment = HorizontalAlignment.Left;
para3.Format.SuppressAutoHyphens = true;
document.SaveToFile("R1.docx");
System.Diagnostics.Process.Start("R1.docx");
}
}
}
- .NET Core系列之MemoryCache 初识
- 007手机一键Root(安机网一键Root) v3.0 官方最新版 一键ROOT您的Android手机
- 12306密码被盗了怎么办?12306密码外泄解决方法
- 12个字的qq网名
- 150M迷你型无线路由器怎么设置?
- 192.168.1.1打不开怎么办?路由器192.168.1.1打不开的原因以及解决办法
- 2011年电子报合订本 电子报 编辑部 中文 PDF版 [84M]
- 2015年1月15日小米新旗舰发布会现场图文直播
- 2016.3.1vivo Xplay5新品发布会现场视频直播 优酷直播
- 2016华为P9发布会视频直播地址 4月15日华为P9国行发布会直播