Hi guys! Do you want to preserve legacy control characters in Word documents? Many of you must want to work with font fallback for Google Noto fonts? You will love to export the list labels of Word document into TXT file format with specific character and change the text alignment of axis tick labels of chart. So what’s the solution?

It is Aspose.Words for .NET 19.3. You can work with these features using it.

So how to work these features? Let’s talk about these one by one.

Preserve Legacy Control Characters while Exporting Document to OOXML

Some document formats support legacy control characters. MS Word does not save these symbols to DOCX format (more accurately in OOXML formats). However, we added new property KeepLegacyControlChars in OoxmlSaveOptions class to preserve such control characters. So far only one legacy character (ShortDateTime) is supported which declared in the “DOC” format.

Here’s how you can use this property:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document(dataDir + "Document.doc");
OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.FlatOpc);
so.KeepLegacyControlChars = true;
dataDir = dataDir + "Document_out.docx";
// Save the document to disk.
doc.Save(dataDir, so);

Predefined Font Fallback Settings for Google Noto Fonts

You may know about Noto. It is a font family comprising over a hundred individual fonts. We have added predefined font fallback settings for Google Noto fonts. These are free fonts licensed under SIL OFL.

Let me clarify two things here:

  • The predefined settings uses only Sans style Noto fonts with regular weight.
  • Aspose.Words does not support advanced typography. So, the Noto fonts that use advanced typography may be rendered inaccurately

The following code example shows how to use predefined font fallback settings.

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
// The path to the documents directory.
Document doc = new Document(dataDir + "Rendering.doc");
FontSettings fontSettings = new FontSettings();
fontSettings.FallbackSettings.LoadNotoFallbackSettings();
// Set font settings
doc.FontSettings = fontSettings;
dataDir = dataDir + "Rendering.FontFallbackGoogleNoto_out.pdf";
doc.Save(dataDir);

Don’t stop reading now! There are more Aspose.Words’ features for you. Amazing, isn’t it?

Text Alignment of Axis Tick Labels

By default, MS Word aligns Chart Label to the center. However, you can change it using ChartAxis.TickLabelAlignment property. We have simple example for you here:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document(dataDir + "Document.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
ChartAxis axis = shape.Chart.AxisX;
//This property has effect only for multi-line labels.
axis.TickLabelAlignment = ParagraphAlignment.Right;
doc.Save(dataDir + "Document_out.docx");

Sound good? Yes, it is!

Indentation of List Levels When Exporting Word Document to Plain Text Format

Starting from Aspose.Words 19.3, you can get the ListIndentation object and specify how many and which character to use for indentation of list levels. By default, no indentation is exported to text file format.

Here’s how to work with list indentation.

Using Tab Character
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc = new Document("input_document");
TxtSaveOptions options = new TxtSaveOptions();
options.ListIndentation.Count = 1;
options.ListIndentation.Character = '\t';
doc.Save(dataDir + "output.txt", options);

Using Space Character

Using Default Indentation
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET
Document doc1 = new Document("input_document");
doc1.Save(dataDir + "output1.txt");
Document doc2 = new Document("input_document");
TxtSaveOptions options = new TxtSaveOptions();
doc2.Save(dataDir + "output2.txt", options);

Wait, there are many other features, enhancement, and bug fixes included in this release. Here you can get the detail!

When time allows you can check out API examples at Github, talk about this release and other API related issues in our forum.