Text Orientation in table cell

Hi Team,

I’m planning to use Text Orientation in a table cell. I didn’t get much help from the documentation - API Reference|Aspose.Words for .NET

I wrote a sample code with various text orientation. Could you help on the following?

  1. The font looks different for Horizontal, Upwards, Downward orientation. If I create a MS Word document manually, the font looks cleaner. Is there any setting to see text stable across different text orientation?
  2. How to set auto height of the row? I tried with RowFormat.setHeightRule(), but it didn’t help. I don’t want to set height to X pt. I’m looking for some auto option here.
  3. The PDF table goes out of the page.
See sample standalone code and output I generated.

Thanks,
Kumar

private static void writeTableWithTextOrientation(DocumentBuilder docBuilder) throws Exception
{
Table table = docBuilder.startTable();

docBuilder.insertCell();
docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.DOWNWARD);
docBuilder.write(“Downward text”);

docBuilder.insertCell();
docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.UPWARD);
docBuilder.write(“Upward text”);

docBuilder.insertCell();
docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.HORIZONTAL_ROTATED_FAR_EAST);
docBuilder.write(“HORIZONTAL_ROTATED_FAR_EAST”);

docBuilder.insertCell();
docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.VERTICAL_FAR_EAST);
docBuilder.write(“VERTICAL_FAR_EAST”);

docBuilder.insertCell();
docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.HORIZONTAL);
docBuilder.write(“HORIZONTAL text”);

Row row = docBuilder.endRow();
// row.getRowFormat().setHeightRule(HeightRule.AUTO);

docBuilder.endTable();
table.setPreferredWidth(PreferredWidth.AUTO);
table.setAllowAutoFit(true);
}

Hi Kumar,

Thanks for your inquiry.

kumaraswamy.m:

The font looks different for Horizontal, Upwards, Downward orientation. If I create a MS Word document manually, the font looks cleaner. Is there any setting to see text stable across different text orientation?

Please note that Aspose.Words mimics the same behavior as MS Word does. If you create the same table by using MS Word, you will get the same output. I have tested this scenario and have not found this issue. The Aspose.Words and MS Word generate the table with same font. It would be great if you please share your document created by MS Word. Please also share which version of MS Word you are using.
kumaraswamy.m:

How to set auto height of the row? I tried with RowFormat.setHeightRule(), but it didn’t help. I don’t want to set height to X pt. I’m looking for some auto option here.

Please use the RowFormat.setHeight method with HeightRule as EXACTLY as shown in following highlighted code snippet.


Document
doc = new Document();

DocumentBuilder docBuilder = new DocumentBuilder(doc);

Table table = docBuilder.startTable();

docBuilder.insertCell();

// Set the row formatting

RowFormat rowFormat = docBuilder.getRowFormat();

rowFormat.setHeight(200);

rowFormat.setHeightRule(HeightRule.EXACTLY);

docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.DOWNWARD);

docBuilder.write("Downward text");

docBuilder.insertCell();

docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.UPWARD);

docBuilder.write("Upward text");

docBuilder.insertCell();

docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.HORIZONTAL_ROTATED_FAR_EAST);

docBuilder.write("HORIZONTAL_ROTATED_FAR_EAST");

docBuilder.insertCell();

docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.VERTICAL_FAR_EAST);

docBuilder.write("VERTICAL_FAR_EAST");

docBuilder.insertCell();

docBuilder.getCellFormat().setOrientation(com.aspose.words.TextOrientation.HORIZONTAL);

docBuilder.write("HORIZONTAL text");

docBuilder.endTable();

table.setPreferredWidth(PreferredWidth.fromPercent(100));

table.setAllowAutoFit(true);

doc.save(MyDir + "Out.docx");


kumaraswamy.m:

The PDF table goes out of the page.

I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9581. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

>>> Please note that Aspose.Words mimics the
same behavior as MS Word does. If you create the same table by using MS
Word, you will get the same output. I have tested this scenario and have
not found this issue. The Aspose.Words and MS Word generate the table
with same font. It would be great if you please share your document
created by MS Word. Please also share which version of MS Word you are
using.

Thanks. It works as expected as you mentioned. I got messed with different fonts “Times New Roman” and “Calibri”.

>>> Please use the RowFormat.setHeight method with HeightRule as EXACTLY as shown in following highlighted code snippet.
As I mentioned, I don’t want to set any height. I’m looking for some AUTO option here. Something like minimum and maximum height would be ideal in this scenario.
In MS Word, once I change the cell text direction to Upward/Downward, the height of cell increases to around 100pt or something.

Thanks for raising defect for "The PDF table goes out of the page."

Thanks,
Kumar

Hi Kumar,

Thanks for your inquiry.

kumaraswamy.m:

As
I mentioned, I don’t want to set any height. I’m looking for some AUTO
option here. Something like minimum and maximum height would be ideal in
this scenario.
In MS Word, once I change the cell text direction to Upward/Downward, the height of cell increases to around 100pt or something.

Yes, in this case MS Word set the height of row. However, if you uncheck the ‘specify height’ check box, you will get the same output in MS Word. Please check the attached image for detail.

In your case, you need to specify the height of table’s row to achieve your requirements. Please read following documentation link for your kind reference.
http://www.aspose.com/docs/display/wordsjava/Specifying+Row+Heights

Thanks. I’ll get back if I need more info.

Hi Kumar,

Sure, Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.