• <menu id="w2i4a"></menu>
  • logo E-iceblue中文文檔

    文檔首頁>>E-iceblue中文文檔>>在 word 文檔中的字符或句子周圍應(yīng)用邊框

    在 word 文檔中的字符或句子周圍應(yīng)用邊框


    為了強(qiáng)調(diào)和美化一組字符或句子,在字符或句子周圍應(yīng)用邊框是一個(gè)不錯(cuò)的選擇。Spire.Doc 使開發(fā)人員能夠在 C# 中實(shí)現(xiàn)此功能。并且有很多內(nèi)置的邊框樣式可用,例如:Wave、Hairline、DotDash、DashSmallGap、DashLargeGap、DoubleWave、DashDotStroker、Emboss3D、Engrave3D、TwistedLines1 等等。下面的代碼展示了如何使用上面提到的一些邊框樣式來實(shí)現(xiàn)字符邊框: 

    Spire.Doc for.NET 最新下載

    注意:開始之前,請(qǐng)確保 Visual Studio 和 Spire.Doc 已正確安裝。我們將使用 Spire.Doc .dll 作為參考。

    第一步:加載word文檔

    Document doc = new Document();
    Section section = doc.AddSection();

    第 2 步:添加應(yīng)用邊框所需的字符并設(shè)置邊框樣式

    //DashSmallGap Border
    Paragraph para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    TextRange tr = para.AppendText("Spire.Doc for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DashSmallGap;
    tr.CharacterFormat.Border.Color = Color.Green;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.DarkKhaki;
    para.AppendBreak(BreakType.LineBreak);
    
    //Wave Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.PDF for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.Wave;
    tr.CharacterFormat.Border.Color = Color.Aqua;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.BurlyWood;
    para.AppendBreak(BreakType.LineBreak);
    
    //Emboss3D Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.XLS for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.Emboss3D;
    tr.CharacterFormat.FontSize = 24;
    para.AppendBreak(BreakType.LineBreak);
    
    //DashDotStroker Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.Office for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DashDotStroker;
    tr.CharacterFormat.Border.Color = Color.Olive;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.Olive;
    para.AppendBreak(BreakType.LineBreak);
    
    //DoubleWave Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.Presentation for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DoubleWave;
    tr.CharacterFormat.Border.Color = Color.Blue;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.Blue;
    para.AppendBreak(BreakType.LineBreak);

    第 3 步:保存并啟動(dòng) word 文檔

    doc.SaveToFile("S1.docx", FileFormat.Docx);
    System.Diagnostics.Process.Start("S1.docx");

    截圖效果

    如何在word文檔中的字符或句子周圍應(yīng)用邊框

    完整代碼

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Spire.Doc;
    using Spire.Doc.Documents;
    using Spire.Doc.Fields;
    using System.Drawing;
    
    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    Document doc = new Document();
    Section section = doc.AddSection();
    
    //DashSmallGap Border
    Paragraph para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    TextRange tr = para.AppendText("Spire.Doc for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DashSmallGap;
    tr.CharacterFormat.Border.Color = Color.Green;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.DarkKhaki;
    para.AppendBreak(BreakType.LineBreak);
    
    //Wave Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.PDF for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.Wave;
    tr.CharacterFormat.Border.Color = Color.Aqua;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.BurlyWood;
    para.AppendBreak(BreakType.LineBreak);
    
    //Emboss3D Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.XLS for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.Emboss3D;
    tr.CharacterFormat.FontSize = 24;
    para.AppendBreak(BreakType.LineBreak);
    
    //DashDotStroker Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.Office for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DashDotStroker;
    tr.CharacterFormat.Border.Color = Color.Olive;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.Olive;
    para.AppendBreak(BreakType.LineBreak);
    
    //DoubleWave Border
    para = section.AddParagraph();
    para.Format.HorizontalAlignment = HorizontalAlignment.Left;
    tr = para.AppendText("Spire.Presentation for .Net");
    tr.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.DoubleWave;
    tr.CharacterFormat.Border.Color = Color.Blue;
    tr.CharacterFormat.FontSize = 24;
    tr.CharacterFormat.TextColor = Color.Blue;
    para.AppendBreak(BreakType.LineBreak);
    
    doc.SaveToFile("S1.docx", FileFormat.Docx);
    System.Diagnostics.Process.Start("S1.docx");
    
    }
    }
    }
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();