Back to Devexpress

Document.EmbedFonts Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document-ac892c2e.md

latest3.0 KB
Original Source

Document.EmbedFonts Property

Gets or sets whether to embed fonts used in the document.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
bool EmbedFonts { get; set; }
vb
Property EmbedFonts As Boolean

Property Value

TypeDescription
Boolean

true to embed fonts; otherwise false.

|

Remarks

Use this property to define whether to include font files in a document, so that the document can be viewed and printed on any computer, regardless of whether the font is installed on that computer.

Example

The code sample below loads a document to the RichEditDocumentServer instance, formats the document header and applies the Chiller font, enables font embedding, and saves the result.

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
//...

using (var wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument(@"C:\Docs\Word (RTF) Document API for NET.docx");
    Paragraph titleParagraph = wordProcessor.Document.Paragraphs[0];
    CharacterProperties characterProperties = wordProcessor.Document.BeginUpdateCharacters(titleParagraph.Range);
    characterProperties.FontName = "Chiller";
    characterProperties.FontSize = 16;
    wordProcessor.Document.EndUpdateCharacters(characterProperties);
    wordProcessor.Document.EmbedFonts = true;
    string fileName = /*the path to the OneDrive folder*/ 
    wordProcessor.SaveDocument(fileName, DocumentFormat.Docx);
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
'...

Using wordProcessor As New RichEditDocumentServer()
  wordProcessor.LoadDocument("C:\Docs\Word (RTF) Document API for NET.docx")
  Dim titleParagraph As Paragraph = wordProcessor.Document.Paragraphs(0)
  Dim characterProperties As CharacterProperties = wordProcessor.Document.BeginUpdateCharacters(titleParagraph.Range)
  characterProperties.FontName = "Chiller"
  characterProperties.FontSize = 16
  wordProcessor.Document.EndUpdateCharacters(characterProperties)
  wordProcessor.Document.EmbedFonts = True
  Dim fileName As String = wordProcessor.SaveDocument(fileName, DocumentFormat.Docx)
End Using

See Also

Document Interface

Document Members

DevExpress.XtraRichEdit.API.Native Namespace