I am trying to insert html content into a cell Using aspose words for java, but the html contains <div>
tags, and this tags (I suppose) adds extra blank spaces. I can’t remove the divs, because this is generated when I create an Html document from another word document. In this example you can see the extra blank space, so how can I remove it?
Example:
try {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
Cell cellContest = builder.insertCell();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
builder.endRow();
builder.getCellFormat().clearFormatting();
builder.getCellFormat().setVerticalAlignment(VerticalAlignment.TOP);
builder.getCellFormat().setLeftPadding(5);
builder.getCellFormat().setTopPadding(1);
builder.getCellFormat().setWrapText(true);
Cell cell1 = builder.insertCell();
Shape oval = new Shape(doc, ShapeType.ELLIPSE);
oval.setWrapType(WrapType.SQUARE);
oval.setAnchorLocked(true);
oval.setWidth(20);
oval.setHeight(10);
oval.setStrokeColor(Color.RED);
oval.setLeft(1);
oval.setTop(0);
builder.insertNode(oval);
builder.insertHtml("<html><body><div><span style=\"font-family:Verdana; font-size:10pt\">#1. Daniel, Mora R.</span></div></body></html>");
// builder.insertHtml("Sample 1");
Cell cell2 = builder.insertCell();
builder.insertHtml("Sample 2");
Cell cell3 = builder.insertCell();
builder.insertHtml("Sample 3");
Cell cell4 = builder.insertCell();
builder.insertHtml("Sample 4");
builder.endRow();
builder.insertCell();
Shape oval2 = new Shape(doc, ShapeType.ELLIPSE);
oval2.setWrapType(WrapType.SQUARE);
oval2.setAnchorLocked(true);
oval2.setWidth(20);
oval2.setHeight(10);
oval2.setStrokeColor(Color.RED);
oval2.setLeft(1);
oval2.setTop(0);
builder.insertNode(oval2);
// builder.getCellFormat().setLeftPadding(5 + oval.getWidth() + 1);
// builder.insertHtml("<html><body><div><p style=\"margin:0pt\"><span style=\"font-family:Verdana; font-size:10pt\">#1. ABAD, Mark V.</span></p></div></body></html>");
builder.insertHtml("<html><body><span style=\"font-family:Verdana; font-size:10pt\">#11. Daniel, Mora R.</span></body></html>");
// builder.insertHtml("Sample 1");
Cell cell12 = builder.insertCell();
builder.insertHtml("Sample 12");
Cell cell13 = builder.insertCell();
builder.insertHtml("Sample 13");
Cell cell14 = builder.insertCell();
builder.insertHtml("Sample 14");
builder.endRow();
builder.endTable();
doc.save("sample.docx");
System.out.println("Finish!!!!!!");
} catch (Exception e) {
e.printStackTrace();
}