public static void Run() { // ExStart:RuleBasedFontsReplacement // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // ExStart:RuleBasedFontsReplacement // Load presentation Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); // Load source font to be replaced IFontData sourceFont = new FontData("SomeRareFont"); // Load the replacing font IFontData destFont = new FontData("Arial"); // Add font rule for font replacement IFontSubstRule fontSubstRule = new FontSubstRule(sourceFont, destFont, FontSubstCondition.WhenInaccessible); // Add rule to font substitute rules collection IFontSubstRuleCollection fontSubstRuleCollection = new FontSubstRuleCollection(); fontSubstRuleCollection.Add(fontSubstRule); // Add font rule collection to rule list presentation.FontsManager.FontSubstRuleList = fontSubstRuleCollection; // Arial font will be used instead of SomeRareFont when inaccessible Bitmap bmp = presentation.Slides[0].GetThumbnail(1f, 1f); // ExEnd:RuleBasedFontsReplacement // Save the image to disk in JPEG format bmp.Save(dataDir + "Thumbnail_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); // ExEnd:RuleBasedFontsReplacement }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); // ExStart:RuleBasedFontsReplacement // Load presentation Presentation presentation = new Presentation(dataDir + "Fonts.pptx"); // Load source font to be replaced IFontData sourceFont = new FontData("SomeRareFont"); // Load the replacing font IFontData destFont = new FontData("Arial"); // Add font rule for font replacement IFontSubstRule fontSubstRule = new FontSubstRule(sourceFont, destFont, FontSubstCondition.WhenInaccessible); // Add rule to font substitute rules collection IFontSubstRuleCollection fontSubstRuleCollection = new FontSubstRuleCollection(); fontSubstRuleCollection.Add(fontSubstRule); // Add font rule collection to rule list presentation.FontsManager.FontSubstRuleList = fontSubstRuleCollection; // Arial font will be used instead of SomeRareFont when inaccessible Bitmap bmp = presentation.Slides[0].GetThumbnail(1f, 1f); // ExEnd:RuleBasedFontsReplacement // Save the image to disk in JPEG format bmp.Save(dataDir + "Thumbnail_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); }