Document

ResourceSavingArgs.Document property

Gets the document object that is currently being saved.

public Document Document { get; }

Examples

Shows how to use a callback to track external resources created while converting a document to HTML.

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());

Shows how to use a callback to track external resources created while converting a document to HTML (FontSavingCallback).

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