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

    文檔首頁>>E-iceblue中文文檔>>將復選框和圖片內(nèi)容控件添加到 Word 文檔

    將復選框和圖片內(nèi)容控件添加到 Word 文檔


    除了Combo Box、Text、Date Picker 和 Drop-Down List 內(nèi)容控件外,Checkbox 和圖片內(nèi)容控件也是 Word 文檔中使用最多的內(nèi)容控件。Spire.Doc 支持在word文檔中添加多種內(nèi)容控件。本文將向您展示如何通過 Spire.Doc for .NET 在 word 文檔中添加復選框和圖片內(nèi)容控件。

    Spire.Doc for.NET 最新下載

    如何添加復選框和圖片內(nèi)容控件的代碼片段:

    using System;
    using System.Drawing;
    namespace AddCheckbox
    {
    
    class Program
    {
    
    static void Main(string[] args)
    {
    //Create a new word document
    Document document = new Document();
    
    //Add a section to the document
    Section section = document.AddSection();
    
    //Add a document to the section
    Paragraph paragraph = section.AddParagraph();
    
    //Add checkbox content control
    StructureDocumentTagInline sdt = new StructureDocumentTagInline(document);
    paragraph = section.AddParagraph();
    sdt = new StructureDocumentTagInline(document);
    sdt.CharacterFormat.FontSize = 20;
    paragraph.ChildObjects.Add(sdt);
    sdt.SDTProperties.SDTType = SdtType.CheckBox;
    SdtCheckBox scb = new SdtCheckBox();
    sdt.SDTProperties.ControlProperties = scb;
    TextRange tr = new TextRange(document);
    tr.CharacterFormat.FontName = "MS Gothic";
    tr.CharacterFormat.FontSize = 20;
    sdt.ChildObjects.Add(tr);
    scb.Checked = true;
    
    sdt.SDTProperties.Alias = "CheckoBox";
    sdt.SDTProperties.Tag = "Checkbox";
    
    //Add picture content control
    paragraph = section.AddParagraph();
    sdt = new StructureDocumentTagInline(document);
    paragraph.ChildObjects.Add(sdt);
    sdt.SDTProperties.ControlProperties = new SdtPicture();
    
    sdt.SDTProperties.Alias = "Picture";
    sdt.SDTProperties.Tag = "Picture";
    
    DocPicture pic = new DocPicture(document) { Width = 10, Height = 10 };
    pic.LoadImage(Image.FromFile("Logo.jpg"));
    sdt.SDTContent.ChildObjects.Add(pic);
    
    document.SaveToFile("Sample.docx", FileFormat.Docx2013);
    
    }
    }
    }

    word文檔添加復選框和圖片內(nèi)容控件后的有效截圖:

    Add checkbox and picture content control to word document in C#


    歡迎下載|體驗更多E-iceblue產(chǎn)品

    如需獲取更多產(chǎn)品相關信息請咨詢慧都在線客服  


    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    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); })();