Free Support Forum -

Cannot save image to disc

Hello Aspose,

I am evaluating aspose java for my software and I have issue saving .docx with images. This is my code.

public String convertDocxToHtml(byte[] doc) {
try {
ByteArrayInputStream is = new ByteArrayInputStream(doc);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setImageSavingCallback(new HandleImageSaving());
Document asposedoc = new Document(is);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();, options);
String str = asposedoc.getText();
str = outputStream.toString();
return outputStream.toString();
} catch (Exception e) {
return “”;

public class HandleImageSaving implements IImageSavingCallback,
ISlideImageFormat {
public void imageSaving(ImageSavingArgs e) throws Exception {
if (e.getImageFileName().endsWith(".jpeg")) {
e.setImageFileName(e.getImageFileName().replace(".jpeg", “.jpg”));

Hello Aspose,

I’ve manage to fix the problem by adding following code into convertDocxToHtml:



Hi Ognjen,

It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,