officefileapi-401149-word-processing-document-api-hyphenation.md
RichEditDocumentServer can enable or suppress word hyphenation at line breaks.
When you load a document, the following scenarios are possible:
Link a dictionary that specifies hyphenation rules. The RichEditDocumentServer.HyphenationDictionaries property provides access to the dictionary collection. You can use two dictionary types:
The RichEditDocumentServer uses dictionaries that match the document’s culture. You can specify the dictionary’s culture in the object constructor. If the culture is not specified, the dictionary’s culture is set to the machine’s current culture.
Use the following properties to hyphenate document text:
| Property | Description |
|---|---|
| Document.Hyphenation | Specifies whether to hyphenate text automatically. If dictionaries are not provided, the property has no effect. |
| Document.HyphenateCaps | Gets or sets whether to hyphenate words in CAPS. |
| Paragraph.SuppressHyphenation | Specifies whether to limit hyphenation to a specific paragraph. |
The following code snippet enables hyphenation and export a document to the PDF format.
//Load a document
wordProcessor.LoadDocument("Grimm.docx");
//Specify hyphenation settings
wordProcessor.Document.Hyphenation = true;
wordProcessor.Document.HyphenateCaps = true;
//Export the result to the PDF format
wordProcessor.ExportToPdf("Result.pdf");
//Open the result
Process.Start(new ProcessStartInfo("Result.pdf") { UseShellExecute = true });
'Load a Document
wordProcessor.LoadDocument("Grimm.docx")
'Specify hyphenation settings
wordProcessor.Document.Hyphenation = True
wordProcessor.Document.HyphenateCaps = True
'Export the result to the PDF format
wordProcessor.ExportToPdf("Result.pdf")
'Open the result
Process.Start(New ProcessStartInfo("Result.pdf") With {.UseShellExecute = True})