Hello, I have a problem with exporting vertical text. I have table in html with VERTICAL text in one cell:
<colgroup>
<col style="width: 33.2936%;" data-mce-style="width: 33.2936%;">
<col style="width: 33.2936%;" data-mce-style="width: 33.2936%;">
<col style="width: 33.2936%;" data-mce-style="width: 33.2936%;">
</colgroup>
<tbody>
<tr style="height: 66.3594px;" data-mce-style="height: 66.3594px;">
<td class="rotate-text" style="transform: rotate(180deg); writing-mode: vertical-rl;" data-mce-style="transform: rotate(180deg); writing-mode: vertical-rl;">VERTICAL</td>
<td>
<br>
</td>
<td>
<br>
</td>
</tr>
</tbody>
</table>
How can I detect that text in this cell is vertical?
And how to export it to MS Word like this?
P.S. I`m detecting table in Document using this way - document.getChildNodes(NodeType.TABLE, true)
Than I get var tableRows = table.getRows() … getCells() etc.
But there is no sign that text is vertical in the cell.
Maybe I should add something in this HTML table?
@cagecrew You can use writing-mode attaribute in html to specify text direction in cells:
<html>
<body>
<table cellspacing="0" cellpadding="0" style="border:0.75pt solid #000000;">
<tr>
<td style="writing-mode:tb-rl;">
Vertical
</td>
<td style="writing-mode:tb-rl;">
Vertical
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
You can specify text direction it table cell programmatically using CellFormat.Orientation property
1 Like
Thanks, it is OK. But now I have another problem, I made cell.getCellFormat().setOrientation(TextOrientation.UPWARD); but receive this:

Row don`t fit height to vertical text, despite this
row.getRowFormat().setHeightRule(HeightRule.AUTO);
How can I make the Row grow vertically?
Any ideas how to fix this?
@cagecrew In this case you should explicitely specify row height:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.startTable();
builder.insertCell();
builder.insertCell();
builder.getCellFormat().setOrientation(TextOrientation.UPWARD);
builder.getRowFormat().setHeight(100);
builder.write("Vertical");
builder.endRow();
builder.endTable();
doc.save("C:\\Temp\\out.docx");
But i don’t know how long will be vertical content or whether it will be vertical at all. I want to set height of the row dynamically, depending on content
@cagecrew I am afraid there is no other way to achieve this. MS Word does the same when you change text orientation in cell - it sets height of the row explicitly. So you should calculate text width and then set row height accordingly.
1 Like