ResourceFileName
ResourceSavingArgs.ResourceFileName property
Gets or sets the file name (without path) where the resource will be saved to.
public string ResourceFileName { get; set; }
Remarks
This property allows you to redefine how the resource file names are generated during export to fixed page HTML or SVG.
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 resource into a different file. Note that file names must be unique.
Aspose.Words automatically generates a unique file name for every resource when exporting to fixed page HTML or SVG format. How the resource 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 resource file name looks like <document base file name>.<image number>.<extension>.
When saving a document to a stream, the generated resource file name looks like Aspose.Words.<document guid>.<image number>.<extension>.
ResourceFileName
must contain only the file name without the path. Aspose.Words determines the path for saving and the value of the src
attribute for writing to fixed page HTML or SVG using the document file name, the ResourcesFolder
or ResourcesFolder
and ResourcesFolderAlias
or ResourcesFolderAlias
properties.
ResourcesFolder
ResourcesFolder
ResourcesFolderAlias
ResourcesFolderAlias
Examples
Shows how to use a callback to track external resources created while converting a document to HTML.
public void ResourceSavingCallback()
{
Document doc = new Document(MyDir + "Bullet points with alternative font.docx");
FontSavingCallback callback = new FontSavingCallback();
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions
{
ResourceSavingCallback = callback
};
doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.UsingMachineFonts.html", saveOptions);
Console.WriteLine(callback.GetText());
}
private class FontSavingCallback : IResourceSavingCallback
{
/// <summary>
/// Called when Aspose.Words saves an external resource to fixed page HTML or SVG.
/// </summary>
public void ResourceSaving(ResourceSavingArgs args)
{
mText.AppendLine($"Original document URI:\t{args.Document.OriginalFileName}");
mText.AppendLine($"Resource being saved:\t{args.ResourceFileName}");
mText.AppendLine($"Full uri after saving:\t{args.ResourceFileUri}\n");
}
public string GetText()
{
return mText.ToString();
}
private readonly StringBuilder mText = new StringBuilder();
}
See Also
- class ResourceSavingArgs
- namespace Aspose.Words.Saving
- assembly Aspose.Words