Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt

Specifies the font to use when inserting text. This property is temporarily overridden by the <font> tag in the XHTML. If this property is not set, the document's default font is used.

Signature
C#
C#
<table class="diff-macro"><thead><tr><th class="diff-macro-title">unmigrated-wiki-markup</th></tr></thead><tbody><tr><td class="diff-macro-body"><pre>
 public SoftArtisans.OfficeWriter.WordWriter.Font DefaultFont{ get; set; }
</pre></td></tr></tbody></table>
Signature
vb.net
vb.net
Public <p>Public Property DefaultFont() As SoftArtisans.OfficeWriter.WordWriter.Font</p>Font
Remarks

The default value is null. The font in the document's default style will be used. (This is generally Times New Roman 12 pt.)

Example
Code Block
csharp
csharp
titleC#
    //--- Create a WordApplication and open a Document
  WordApplication wordApp = new WordApplication();
  Document doc = wordApp.Create();
			
  //--- Create the HTMLToWord object
  HTMLToWord h2w = new HTMLToWord();

  //--- Create the font to use when inserting HTML
  //--- Start by getting the "Normal" font from the Document
  Font font = doc.Styles[NamedStyle.BuiltIn.Normal].Font;

  //--- Change the font to 10 pt. Arial with red text
  font.FontName = "Arial";
  font.FontSize = 10;
  font.TextColor = System.Drawing.Color.Red;

  //--- Set this as the default font on the HTMLToWord object
  h2w.InsertProperties.DefaultFont = font;

  //--- Insert the htmlFragment at the end of the document.
  h2w.InsertHTML(htmlFragment, doc, Nothing, doc);

Code Block
vb.net
vb.net
titlevb.net
    '--- Create a WordApplication and open a Document
  Dim wordApp As New WordApplication()
  Dim doc As Document = wordApp.Create()
			
  '--- Create the HTMLToWord object
  Dim h2w As New HTMLToWord()

  '--- Create the font to use when inserting HTML
  '--- Start by getting the "Normal" font from the Document
  Dim font as Font = doc.Styles(NamedStyle.BuiltIn.Normal).Font

  '-- Change the font to 10 pt. Arial with red text
  font.FontName = "Arial"
  font.FontSize = 10
  font.TextColor = System.Drawing.Color.Red

  '--- Set this as the default font on the HTMLToWord object
  h2w.InsertProperties.DefaultFont = font

  '--- Insert the htmlFragment at the end of the document.
  h2w.InsertHTML(htmlFragment, doc, Nothing, doc)