public interface IResourceSavingCallback
Example:
public void usingMachineFonts() throws Exception {
Document doc = new Document(getMyDir() + "Font.DisappearingBulletPoints.doc");
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
saveOptions.setUseTargetMachineFonts(true);
saveOptions.setFontFormat(ExportFontFormat.TTF);
saveOptions.setExportEmbeddedFonts(false);
saveOptions.setResourceSavingCallback(new ResourceSavingCallback());
doc.save(getArtifactsDir() + "UseMachineFonts.html", saveOptions);
}
private static class ResourceSavingCallback implements IResourceSavingCallback {
/**
* Called when Aspose.Words saves an external resource to fixed page HTML or SVG.
*/
public void resourceSaving(final ResourceSavingArgs args) throws Exception {
args.setResourceStream(new ByteArrayOutputStream());
args.setKeepResourceStreamOpen(true);
String extension = FilenameUtils.getExtension(args.getResourceFileName());
switch (extension) {
case "ttf":
case "woff":
Assert.fail("'ResourceSavingCallback' is not fired for fonts when 'UseTargetMachineFonts' is true");
break;
}
}
}
| Method Summary | ||
|---|---|---|
abstract void | resourceSaving(ResourceSavingArgs args) | |
| Called when Aspose.Words saves an external resource to fixed page HTML or SVG formats. | ||
| Method Detail |
|---|
resourceSaving | |
public abstract void resourceSaving(ResourceSavingArgs args) throws java.lang.Exception | |
Example:
Shows how used target machine fonts to display the document.
public void usingMachineFonts() throws Exception {
Document doc = new Document(getMyDir() + "Font.DisappearingBulletPoints.doc");
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
saveOptions.setUseTargetMachineFonts(true);
saveOptions.setFontFormat(ExportFontFormat.TTF);
saveOptions.setExportEmbeddedFonts(false);
saveOptions.setResourceSavingCallback(new ResourceSavingCallback());
doc.save(getArtifactsDir() + "UseMachineFonts.html", saveOptions);
}
private static class ResourceSavingCallback implements IResourceSavingCallback {
/**
* Called when Aspose.Words saves an external resource to fixed page HTML or SVG.
*/
public void resourceSaving(final ResourceSavingArgs args) throws Exception {
args.setResourceStream(new ByteArrayOutputStream());
args.setKeepResourceStreamOpen(true);
String extension = FilenameUtils.getExtension(args.getResourceFileName());
switch (extension) {
case "ttf":
case "woff":
Assert.fail("'ResourceSavingCallback' is not fired for fonts when 'UseTargetMachineFonts' is true");
break;
}
}
}