Hello,
I am trying to set some ImageData attributes such as bottom border or bottom crop but it does not seems to works since Aspose Words 15.2.0 (merge Shape / DrawingML). I want to migrate to Aspose Words 16.11.0
I do the following code,
Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
InputStream image = new FileInputStream(new File(“C:\test.png”));
Shape shape = builder.insertImage(image);
ImageData imageData = shape.getImageData();
Border bottomBorder = imageData.getBorders().getByBorderType(BorderType.BOTTOM);
bottomBorder.setLineStyle(LineStyle.SINGLE);
bottomBorder.setLineWidth(1);
bottomBorder.setColor(Color.BLACK);
bottomBorder.setShadow(true);
document.save(“test.docx”);
The document test.docx does not have bottom border for Aspose version 16.11.0 but the same code works in Aspose version < 15.2.0
Thank you in advance for your assistance.
Jean Pascal Lim
Hi Jean,
Hi Jean,
DocumentBuilder builder = new DocumentBuilder(document);
// This constructor creates shape with markup language “Vml”.
Shape shape = new Shape(document, ShapeType.IMAGE);
// Set path to file here.
InputStream is = new FileInputStream(new File(“D:\temp\aspose.words.jpg”));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
while ((nRead = is.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
shape.getImageData().setImageBytes(buffer.toByteArray());
shape.setWrapType(WrapType.INLINE);
ImageData imageData = shape.getImageData();
Border bottomBorder = imageData.getBorders().getByBorderType(BorderType.BOTTOM);
bottomBorder.setLineStyle(LineStyle.SINGLE);
bottomBorder.setLineWidth(1);
bottomBorder.setColor(Color.BLACK);
bottomBorder.setShadow(true);
builder.insertNode(shape);
document.save(“D:\temp\awjava-17.1.0.docx”);