public class FontSavingArgs
When Aspose.Words saves a document to HTML or related formats and To decide whether to save a particular font resource, use the To save fonts into streams instead of files, use the Example:
Document doc = new Document(getMyDir() + "Rendering.docx");
// Configure a SaveOptions object to export fonts to separate files.
// Set a callback that will handle font saving in a custom manner.
HtmlSaveOptions options = new HtmlSaveOptions();
{
options.setExportFontResources(true);
options.setFontSavingCallback(new HandleFontSaving());
}
// The callback will export .ttf files and save them alongside the output document.
doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options);
File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf"));
for (File fontFilename : fontFileNames) {
System.out.println(fontFilename.getName());
}
/// <summary>
/// Prints information about exported fonts and saves them in the same local system folder as their output .html.
/// </summary>
public static class HandleFontSaving implements IFontSavingCallback {
public void fontSaving(FontSavingArgs args) throws Exception {
System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName()));
if (args.getBold()) System.out.print(", bold");
if (args.getItalic()) System.out.print(", italic");
System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize()));
// We can also access the source document from here.
Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx"));
Assert.assertTrue(args.isExportNeeded());
Assert.assertTrue(args.isSubsettingNeeded());
String[] splittedFileName = args.getOriginalFileName().split("\\\\");
String fileName = splittedFileName[splittedFileName.length - 1];
// There are two ways of saving an exported font.
// 1 - Save it to a local file system location:
args.setFontFileName(fileName);
// 2 - Save it to a stream:
args.setFontStream(new FileOutputStream(fileName));
Assert.assertFalse(args.getKeepFontStreamOpen());
}
}
Property Getters/Setters Summary | ||
---|---|---|
boolean | getBold() | |
Indicates whether the current font is bold.
|
||
Document | getDocument() | |
Gets the document object that is being saved.
|
||
java.lang.String | getFontFamilyName() | |
Indicates the current font family name.
|
||
java.lang.String | getFontFileName() | |
void | setFontFileName(java.lang.Stringvalue) | |
Gets or sets the file name (without path) where the font will be saved to. | ||
java.io.OutputStream | getFontStream() | |
void | setFontStream(java.io.OutputStreamvalue) | |
Allows to specify the stream where the font will be saved to. | ||
boolean | isExportNeeded() | |
void | isExportNeeded(booleanvalue) | |
Allows to specify whether the current font will be exported as a font resource. Default is true .
|
||
boolean | isSubsettingNeeded() | |
void | isSubsettingNeeded(booleanvalue) | |
Allows to specify whether the current font will be subsetted before exporting as a font resource. | ||
boolean | getItalic() | |
Indicates whether the current font is italic.
|
||
boolean | getKeepFontStreamOpen() | |
void | setKeepFontStreamOpen(booleanvalue) | |
Specifies whether Aspose.Words should keep the stream open or close it after saving a font. | ||
java.lang.String | getOriginalFileName() | |
Gets the original font file name with an extension.
|
||
int | getOriginalFileSize() | |
Gets the original font file size.
|
public boolean getBold()
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public Document getDocument()
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public java.lang.String getFontFamilyName()
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public java.lang.String getFontFileName() / public void setFontFileName(java.lang.String value)
This property allows you to redefine how the font file names are generated during export to HTML.
When the event is fired, this property contains the file name that was generated by Aspose.Words. You can change the value of this property to save the font into a different file. Note that file names must be unique.
Aspose.Words automatically generates a unique file name for every embedded font when exporting to HTML format. How the font file name is generated depends on whether you save the document to a file or to a stream.
When saving a document to a file, the generated font file name looks like <document base file name>.<original file name><optional suffix>.<extension>.
When saving a document to a stream, the generated font file name looks like Aspose.Words.<document guid>.<original file name><optional suffix>.<extension>.
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public java.io.OutputStream getFontStream() / public void setFontStream(java.io.OutputStream value)
This property allows you to save fonts to streams instead of files during HTML export.
The default value is null
. When this property is null
, the font
will be saved to a file specified in the
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public boolean isExportNeeded() / public void isExportNeeded(boolean value)
true
.
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public boolean isSubsettingNeeded() / public void isSubsettingNeeded(boolean value)
Fonts can be exported as complete original font files or subsetted to include only the characters that are used in the document. Subsetting allows to reduce the resulting font resource size.
By default, Aspose.Words decides whether to perform subsetting or not by comparing the original font file size
with the one specified in
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public boolean getItalic()
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public boolean getKeepFontStreamOpen() / public void setKeepFontStreamOpen(boolean value)
Default is false
and Aspose.Words will close the stream you provided
in the true
to keep the stream open.
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public java.lang.String getOriginalFileName()
This property contains the original file name of the current font if it is known. Otherwise it can be an empty string.
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }
public int getOriginalFileSize()
This property contains the original file size of the current font if it is known. Otherwise it can be zero.
Example:
Shows how to define custom logic for exporting fonts when saving to HTML.Document doc = new Document(getMyDir() + "Rendering.docx"); // Configure a SaveOptions object to export fonts to separate files. // Set a callback that will handle font saving in a custom manner. HtmlSaveOptions options = new HtmlSaveOptions(); { options.setExportFontResources(true); options.setFontSavingCallback(new HandleFontSaving()); } // The callback will export .ttf files and save them alongside the output document. doc.save(getArtifactsDir() + "HtmlSaveOptions.SaveExportedFonts.html", options); File[] fontFileNames = new File(getArtifactsDir()).listFiles((d, name) -> name.endsWith(".ttf")); for (File fontFilename : fontFileNames) { System.out.println(fontFilename.getName()); } /// <summary> /// Prints information about exported fonts and saves them in the same local system folder as their output .html. /// </summary> public static class HandleFontSaving implements IFontSavingCallback { public void fontSaving(FontSavingArgs args) throws Exception { System.out.println(MessageFormat.format("Font:\t{0}", args.getFontFamilyName())); if (args.getBold()) System.out.print(", bold"); if (args.getItalic()) System.out.print(", italic"); System.out.println(MessageFormat.format("\nSource:\t{0}, {1} bytes\n", args.getOriginalFileName(), args.getOriginalFileSize())); // We can also access the source document from here. Assert.assertTrue(args.getDocument().getOriginalFileName().endsWith("Rendering.docx")); Assert.assertTrue(args.isExportNeeded()); Assert.assertTrue(args.isSubsettingNeeded()); String[] splittedFileName = args.getOriginalFileName().split("\\\\"); String fileName = splittedFileName[splittedFileName.length - 1]; // There are two ways of saving an exported font. // 1 - Save it to a local file system location: args.setFontFileName(fileName); // 2 - Save it to a stream: args.setFontStream(new FileOutputStream(fileName)); Assert.assertFalse(args.getKeepFontStreamOpen()); } }