TableSubstitutionRuleSave Method (Stream) |
Namespace: Aspose.Words.Fonts
// Create a blank document and a new FontSettings object Document doc = new Document(); FontSettings fontSettings = new FontSettings(); doc.FontSettings = fontSettings; // Create a new table substitution rule and load the default Windows font substitution table TableSubstitutionRule tableSubstitutionRule = fontSettings.SubstitutionSettings.TableSubstitution; tableSubstitutionRule.LoadWindowsSettings(); // In Windows, the default substitute for the "Times New Roman CE" font is "Times New Roman" Assert.AreEqual(new[] { "Times New Roman" }, tableSubstitutionRule.GetSubstitutes("Times New Roman CE").ToArray()); // We can save the table for viewing in the form of an XML document tableSubstitutionRule.Save(ArtifactsDir + "Font.TableSubstitutionRule.Windows.xml"); // Linux has its own substitution table // If "FreeSerif" is unavailable to substitute for "Times New Roman CE", we then look for "Liberation Serif", and so on tableSubstitutionRule.LoadLinuxSettings(); Assert.AreEqual(new[] { "FreeSerif", "Liberation Serif", "DejaVu Serif" }, tableSubstitutionRule.GetSubstitutes("Times New Roman CE").ToArray()); // Save the Linux substitution table using a stream using (FileStream fileStream = new FileStream(ArtifactsDir + "Font.TableSubstitutionRule.Linux.xml", FileMode.Create)) { tableSubstitutionRule.Save(fileStream); }