com.aspose.words
Interface IImageSavingCallback


public interface IImageSavingCallback 

Implement this interface if you want to control how Aspose.Words saves images when saving a document to HTML. May be used by other formats.

Example:

Shows how to define custom logic for controlling how images are saved when exporting to HTML based formats.
public void saveHtmlExportImages() throws Exception
{
    Document doc = new Document(getMyDir() + "Document.doc");

    // Create and pass the object which implements the handler methods.
    HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
    options.setImageSavingCallback(new HandleImageSaving());

    doc.save(getMyDir() + "Document.SaveWithCustomImagesExport Out.html", options);
}

public class HandleImageSaving implements IImageSavingCallback
{
    public void imageSaving(ImageSavingArgs e) throws Exception
    {
        // Change any images in the document being exported with the extension of "jpeg" to "jpg".
        if (e.getImageFileName().endsWith(".jpeg"))
            e.setImageFileName(e.getImageFileName().replace(".jpeg", ".jpg"));
    }
}

Method Summary
abstract voidimageSaving(ImageSavingArgs args)
           Called when Aspose.Words saves an image to HTML.
 

Method Detail

imageSaving

public abstract void imageSaving(ImageSavingArgs args)
                              throws java.lang.Exception
Called when Aspose.Words saves an image to HTML.

Example:

Shows how to define custom logic for controlling how images are saved when exporting to HTML based formats.
public void saveHtmlExportImages() throws Exception
{
    Document doc = new Document(getMyDir() + "Document.doc");

    // Create and pass the object which implements the handler methods.
    HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
    options.setImageSavingCallback(new HandleImageSaving());

    doc.save(getMyDir() + "Document.SaveWithCustomImagesExport Out.html", options);
}

public class HandleImageSaving implements IImageSavingCallback
{
    public void imageSaving(ImageSavingArgs e) throws Exception
    {
        // Change any images in the document being exported with the extension of "jpeg" to "jpg".
        if (e.getImageFileName().endsWith(".jpeg"))
            e.setImageFileName(e.getImageFileName().replace(".jpeg", ".jpg"));
    }
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.