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();
asposedoc.save(outputStream, options);
String str = asposedoc.getText();
str = outputStream.toString();
return outputStream.toString();
} catch (Exception e) {
e.printStackTrace();
}
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”));
}
}
}