Hi,
our customer has this issue:
we use aspose cells version 17.8 and aspose words 16.12.0 and when we get the image of a chart from a workbook using Chart.ToImage and then insert it into Word document, using ImageData.setImage, the resulting image as no text.
We try to reproduce this issue locally but we can not.
Do you have any idea what could be the possible cause of this issue? Could it be something related to the customer application server?
We use this code to read the image from Excel:
public InputStream getChart(String sheet, String name) {
if(sheet == null) {
return null;
}
InOutStream inOutStream = new InOutStream();
try {
Worksheet worksheet = currentWorkbook.getWorksheets().get(sheet);
Chart chart = worksheet.getCharts().get(name);
chart.toImage(inOutStream, AsposeCellsUtils.getImageOrPrintOptions());
} catch (Exception e) {
return null;
}
return inOutStream.toInputStream();
}
We use this code to insert the image into Word:
Shape shapeToReplace = (Shape) sdt.getChild(NodeType.SHAPE, 0, true);
if (shapeToReplace == null) {
throw new OOXMLException(“Image object not present inside picture content control”);
}
InputStream imageStream = res.getImageStream();
try {
ImageData imageData = shapeToReplace.getImageData();
if (imageStream == null) {
imageStream = this.getClass().getResourceAsStream("/images/imagePlaceholder.png");
sdt.isShowingPlaceholderText(true);
imageData.setImage(imageStream);
resizeShape(shapeToReplace, imageData);
} else {
imageData.setImage(imageStream);
if (sdt.isShowingPlaceholderText()) {
resizeShape(shapeToReplace, imageData);
sdt.isShowingPlaceholderText(false);
}
}
} catch (Exception e) {
throw new OOXMLException(e);
}
This is an example of the result:
chart.png (3.2 KB)
Thanks
Giulio