aspose.word 插入段落样式失效或段落文本样式无效 请配合正确食用方式

Apose.word 样式失效的情况,再根据目前自己跌倒的次数,自己默默写上一点笔记

以下将展示一些aspose word 文档的属性和一些方法给大家参照 方便日后处理文档查找解决方法使用。请大家自行对照自己出现的问题和想要的效果来查看

以下是对Section页面的一些设置示例

using Aspose.Words;
using System.Drawing.Printing;
namespace AsposeWord
{
 public static void WordPageSetup()
 {
            object oMissing = System.Reflection.Missing.Value;
            Document doc=new Document();
            #region 文档格式设置
            doc.Sections[0].PageSetup.LineStartingNumber =1;//行编号
            doc.Sections[0].PageSetup.Orientation =Orientation.Landscape;//页面方向
            doc.Sections[0].PageSetup.TopMargin = float.Parse("2.54");//上页边距
            doc.Sections[0].PageSetup.BottomMargin = float.Parse("2.54");//下页边距
            doc.Sections[0].PageSetup.LeftMargin = float.Parse("3.17");//左页边距
            doc.Sections[0].PageSetup.RightMargin =float.Parse("3.17");//右页边距
            doc.Sections[0].PageSetup.Gutter = float.Parse("1.0");//装订线位置
            doc.Sections[0].PageSetup.HeaderDistance = float.Parse("1.5");//页眉
            doc.Sections[0].PageSetup.FooterDistance = float.Parse("1.75");//页脚
            doc.Sections[0].PageSetup.PageWidth = float.Parse("20.0");//纸张宽度
            doc.Sections[0].PageSetup.PageHeight = float.Parse("29.7");//纸张高度
            //纸张来源
            PrinterSettings settings = new PrinterSettings();
            doc.Sections[0].PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind;
            //纸张来源
            doc.Sections[0].PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
            doc.Sections[0].PageSetup.SectionStart =SectionStart.Continuous;//节的起始位置:新建页
            doc.Sections[0].PageSetup.OddAndEvenPagesHeaderFooter = false;//页眉页脚-奇偶页不同
            doc.Sections[0].PageSetup.DifferentFirstPageHeaderFooter = true;//页眉页脚-首页不同
            doc.Sections[0].PageSetup.VerticalAlignment = PageVerticalAlignment.Center; ;//页面垂直对齐方式
            doc.Sections[0].PageSetup.SuppressEndnotes = true;//不隐藏尾注
            doc.Sections[0].PageSetup.LayoutMode = SectionLayoutMode.Grid;//版式模式为“只指定行网格”
 }
}

以下是对Paragraphs的一些示例:

using Aspose.Words;
using System.Drawing.Printing;
namespace AsposeWord
{
 public static void WordPageSetup()
 {
   #region 段落格式设定
       Paragraph p =new Paragraph(doc);
       p.ParagraphFormat.LeftIndent = float.Parse("2.0");//左缩进
       p.ParagraphFormat.RightIndent = float.Parse("2.0");//右缩进
       p.ParagraphFormat.SpaceBefore = float.Parse("2.0");//段前间距
       p.ParagraphFormat.SpaceBeforeAuto = false;//
       p.ParagraphFormat.SpaceAfter = float.Parse("2.0");//段后间距
       p.ParagraphFormat.SpaceAfterAuto = false;//
       p.ParagraphFormat.LineSpacingRule =LineSpacingRule.AtLeast;//单倍行距
       p.ParagraphFormat.Alignment =ParagraphAlignment.Justify;//段落2端对齐
       p.ParagraphFormat.WidowControl = false;//孤行控制
       p.ParagraphFormat.KeepWithNext = false;//与下段同页
       p.ParagraphFormat.KeepTogether = false;//段中不分页
       p.ParagraphFormat.PageBreakBefore = false;//段前分页
       p.ParagraphFormat.FirstLineIndent = float.Parse("2.0");//首行缩进
       p.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText;
       p.ParagraphFormat.FarEastLineBreakControl =false ;
       p.ParagraphFormat.WordWrap = false;
       p.ParagraphFormat.HangingPunctuation = false;
       p.ParagraphFormat.AddSpaceBetweenFarEastAndAlpha = false;
       p.ParagraphFormat.AddSpaceBetweenFarEastAndDigit = false;
   #endregion 段落格式设定
   #region 文字样式
       p.ParagraphFormat.Style.Name = "样式名称";
       p.ParagraphFormat.Style.Font.NameAscii = "Times New Roman";
       p.ParagraphFormat.Style.Font.NameOther = "Times New Roman";
       p.ParagraphFormat.Style.Font.Name = "宋体";
       p.ParagraphFormat.Style.Font.Size = 0.3;
       p.ParagraphFormat.Style.Font.Bold = false;
       p.ParagraphFormat.Style.Font.Italic = false;
       p.ParagraphFormat.Style.Font.Underline =Underline.Dash;//下划线
       p.ParagraphFormat.Style.Font.UnderlineColor = Color.AliceBlue;//设置下划线颜色
       p.ParagraphFormat.Style.Font.StrikeThrough = false;//删除线
       p.ParagraphFormat.Style.Font.DoubleStrikeThrough = false;//双删除线
       p.ParagraphFormat.Style.Font.Outline = false;//空心
       p.ParagraphFormat.Style.Font.Emboss = false;//阳文
       p.ParagraphFormat.Style.Font.Shadow = false;//阴影
       p.ParagraphFormat.Style.Font.Hidden = false;//隐藏文字
       p.ParagraphFormat.Style.Font.SmallCaps = false;//小型大写字母
       p.ParagraphFormat.Style.Font.AllCaps = false;//全部大写字母
       p.ParagraphFormat.Style.Font.Color = Color.AliceBlue;
       p.ParagraphFormat.Style.Font.Engrave = false;//阴文
       p.ParagraphFormat.Style.Font.Superscript = false;//上标
       p.ParagraphFormat.Style.Font.Subscript = false;//下标
       p.ParagraphFormat.Style.Font.Spacing = 0.2;//字符间距
       p.ParagraphFormat.Style.Font.Scaling = 2;//字符缩放
       p.ParagraphFormat.Style.Font.Position = 1.2;//位置
       p.ParagraphFormat.Style.Font.Kerning = 0.2;//字体间距调整
   #endregion
   }
}

稍后还会继续更新 你也可以去看一下我最近的一个站点(你好呀!菜鸡)内容

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值