FontSavingArgs Class |
Namespace: Aspose.Words.Saving
The FontSavingArgs type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Bold |
Indicates whether the current font is bold.
|
![]() ![]() | Document |
Gets the document object that is being saved.
|
![]() ![]() | FontFamilyName |
Indicates the current font family name.
|
![]() ![]() | FontFileName |
Gets or sets the file name (without path) where the font will be saved to.
|
![]() ![]() | FontStream |
Allows to specify the stream where the font will be saved to.
|
![]() ![]() | IsExportNeeded |
Allows to specify whether the current font will be exported as a font resource. Default is true.
|
![]() ![]() | IsSubsettingNeeded |
Allows to specify whether the current font will be subsetted before exporting as a font resource.
|
![]() ![]() | Italic |
Indicates whether the current font is italic.
|
![]() ![]() | KeepFontStreamOpen |
Specifies whether Aspose.Words should keep the stream open or close it after saving a font.
|
![]() ![]() | OriginalFileName |
Gets the original font file name with an extension.
|
![]() ![]() | OriginalFileSize |
Gets the original font file size.
|
Name | Description | |
---|---|---|
![]() | Equals | (Inherited from Object.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | ToString | (Inherited from Object.) |
When Aspose.Words saves a document to HTML or related formats and ExportFontResources is set to true, it saves each font subject for export into a separate file.
FontSavingArgs controls whether particular font resource should be exported and how.
FontSavingArgs also allows to redefine how font file names are generated or to completely circumvent saving of fonts into files by providing your own stream objects.
To decide whether to save a particular font resource, use the IsExportNeeded property.
To save fonts into streams instead of files, use the FontStream property.
public void SaveHtmlExportFonts() { Document doc = new Document(MyDir + "Rendering.docx"); // Set the option to export font resources HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html); options.ExportFontResources = true; // Create and pass the object which implements the handler methods options.FontSavingCallback = new HandleFontSaving(); doc.Save(ArtifactsDir + "Document.SaveHtmlExportFonts.html", options); } /// <summary> /// Prints information about fonts and saves them alongside their output .html. /// </summary> public class HandleFontSaving : IFontSavingCallback { void IFontSavingCallback.FontSaving(FontSavingArgs args) { // Print information about fonts Console.Write($"Font:\t{args.FontFamilyName}"); if (args.Bold) Console.Write(", bold"); if (args.Italic) Console.Write(", italic"); Console.WriteLine($"\nSource:\t{args.OriginalFileName}, {args.OriginalFileSize} bytes\n"); Assert.True(args.IsExportNeeded); Assert.True(args.IsSubsettingNeeded); // We can designate where each font will be saved by either specifying a file name, or creating a new stream args.FontFileName = args.OriginalFileName.Split(Path.DirectorySeparatorChar).Last(); args.FontStream = new FileStream(ArtifactsDir + args.OriginalFileName.Split(Path.DirectorySeparatorChar).Last(), FileMode.Create); Assert.False(args.KeepFontStreamOpen); // We can access the source document from here also Assert.True(args.Document.OriginalFileName.EndsWith("Rendering.docx")); } }