use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.
the class ContainerParseTest method testParagraphInTableCellLayout.
@Test
public void testParagraphInTableCellLayout() throws Exception {
String html = "<table><tbody><tr>" + "<td><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/>" + "<p><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/></p>" + "<img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/><img src='" + PNG_IMAGE_DATA + "' height='16' width='19'/></td></tr></tbody></table>";
List<Object> tConvert = convert(html);
Assert.assertTrue(tConvert.size() == 1);
for (Object t : tConvert) {
Assert.assertTrue(t instanceof Tbl);
Tbl table = (Tbl) t;
List<Object> convert = ((Tc) ((Tr) table.getContent().get(0)).getContent().get(0)).getContent();
Assert.assertTrue(convert.size() == 3);
for (Object o : convert) {
Assert.assertTrue(o instanceof P);
P paragraph = (P) o;
List<Object> content = paragraph.getContent();
Assert.assertTrue(content.size() == 2);
for (Object child : content) {
Assert.assertTrue(child instanceof R);
R run = ((R) child);
List<Object> rContent = run.getContent();
Assert.assertTrue(rContent.size() == 1);
Assert.assertTrue(rContent.get(0) instanceof Drawing);
}
}
}
}
use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.
the class ComplexTable method addTc.
private static void addTc(Tr tr, String label, String text, String width) {
Tc tc = factory.createTc();
TcPr tcPr = new TcPr();
TblWidth tblwidth = new TblWidth();
tblwidth.setType("dxa");
tblwidth.setW(new BigInteger(width));
tcPr.setTcW(tblwidth);
tc.setTcPr(tcPr);
tc.getEGBlockLevelElts().add(wordMLPackage.getMainDocumentPart().createParagraphOfText(text));
tr.getEGContentCellContent().add(tc);
}
use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.
the class Docx4jUtils method addTableCell.
private void addTableCell(Tr tableRow, String content, int width, DocxStyle style, int horizontalMergedCells, String verticalMergedVal) {
Tc tableCell = factory.createTc();
addCellStyle(tableCell, content, style);
setCellWidth(tableCell, width);
setCellVMerge(tableCell, verticalMergedVal);
setCellHMerge(tableCell, horizontalMergedCells);
if (style.isNoWrap()) {
setCellNoWrap(tableCell);
}
tableRow.getContent().add(tableCell);
}
use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.
the class Docx4jUtils method addTableCell.
private void addTableCell(Tr tableRow, P image, int width, DocxStyle style, int horizontalMergedCells, String verticalMergedVal) {
Tc tableCell = factory.createTc();
addImageCellStyle(tableCell, image, style);
setCellWidth(tableCell, width);
setCellVMerge(tableCell, verticalMergedVal);
setCellHMerge(tableCell, horizontalMergedCells);
tableRow.getContent().add(tableCell);
}
use of org.docx4j.wml.Tc in project Java-Tutorial by gpcodervn.
the class NestedTable method addTc.
protected static void addTc(Tr tr, String text) {
Tc tc = factory.createTc();
TcPr tcPr = new TcPr();
TblWidth width = new TblWidth();
width.setType("dxa");
width.setW(new BigInteger("3192"));
tcPr.setTcW(width);
tc.setTcPr(tcPr);
tc.getEGBlockLevelElts().add(wordMLPackage.getMainDocumentPart().createParagraphOfText(text));
tr.getEGContentCellContent().add(tc);
}
Aggregations