Aspose.word设置页眉

引用:https://blog.youkuaiyun.com/sinat_35165183/article/details/54743612

 

                 StreamWriter sw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/temp.html"), false, Encoding.Default);
                        sw.Write("<html><head></head><body>");
                        sw.Write(ar1.note);
                        sw.Write("</body></html>");
                        sw.Close();
                        string strs = "<html><head></head><body>" + ar1.note + "</body></html>";
                        Document doc = new Document();
                        DocumentBuilder builder = new DocumentBuilder(doc);
                        builder.InsertHtml(strs);

                        Section currentSection = builder.CurrentSection;
                        Aspose.Words.PageSetup pageSetup = currentSection.PageSetup;
                        pageSetup.HeaderDistance = 50;

 

                        builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
                        //builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
                        //builder.Underline = Underline.Single;
                        builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                        // Set font properties for header text.    
                        //builder.Font.Name = "仿宋_GB2312";
                        //builder.RowFormat.Alignment = RowAlignment.Center;
                        builder.Font.Bold = true;
                        builder.Font.Size = 18;
                        // Specify header title for the first page.
                        //if (headflag == 1)
                        //{
                        builder.Write(article.HeaderPrimary);
                        //}
                            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
                            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                            builder.Write(article.FooterPrimary);


                        string path = Server.MapPath("~/word/" + article.company);
                        if (!System.IO.Directory.Exists(path)) {
                            System.IO.Directory.CreateDirectory(path);
                        }

                        doc.Save(path +"/" + article.company + t + ".doc");  

                        object oFalse = false;
                        object oTrue = true;
                        object oMissing = System.Reflection.Missing.Value;
                        t++;

 

 

 

 

 

=============================================================

字体颜色:    

                        Aspose.Words.Font font = builder.Font;
                        font.Size = 16;
                        font.Bold = true;
                        font.Color = Color.Blue;

======================================

 设置标题                       

                        //builder.RowFormat.Alignment = RowAlignment.Center;
                        //builder.CellFormat.Borders.LineStyle = LineStyle.Single;
                        //builder.InsertHtml("<h1>1、分析数据</h1>");
                        //builder.InsertHtml("<h2>1.1 数据一</h2>");
                        //builder.InsertHtml("<h2>1.2 数据二</h2>");
                        //builder.InsertHtml("<h3>1.2.1 计算分析</h3>");

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值