We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Table Object: Right Alignment

Hello Team,

We are using Aspose.Words 7.1.0.0 to generate word and PDF reports.

We are using table, text, label objects on the report.

When orientation is set to RTL, text in the report gets entirely right aligned, but this is not the case with Table object.

Table object remains at the left hand side of the report, though the text inside the table gets right aligned.

Attached are both word and PDF output for your reference.

Best Regards,

Dwarika

Hello Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. If you would like to set table alignment for your table to right, you can try using the following code:

// Open document.

Document doc = new Document("Aspose+Copy.doc");

// Get collection of rows

NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);

// Loop through all rows

foreach (Row row in rows)

{

// Set Alignment to right

row.RowFormat.Alignment= RowAlignment.Right;

}

doc.Save("out.pdf");

Best regards,

Hello Team,

We are setting left indent to move table object to right side. like following

documentBuilder.RowFormat.LeftIndent = rightIndent;

will this solve purpose?

Regards,

Dwarika

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. If you would like to build RTL table and move it left, then LeftIndent should work for you. Here is code example, which shows how to builder RTL table.

// Create Documentbuilder object, which will be used to buil th edocument.

DocumentBuilder builder = new DocumentBuilder();

// Configure builder to build RTL docuemnt.

builder.PageSetup.Bidi = true;

builder.ParagraphFormat.Bidi = true;

builder.RowFormat.Bidi = true;

builder.Font.Bidi = true;

// Specify the font and font size to be used for the right-to-left text.

builder.Font.NameBi = "Andalus";

// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia.

// For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx

builder.Font.LocaleIdBi = 1025;

// Set let indent of table, since our table is RTL indent will be added at right.

builder.RowFormat.LeftIndent = 150;

// Build table.

builder.CellFormat.Borders.LineStyle = LineStyle.Single;

builder.InsertCell();

// Insert some Arabic text.

builder.Writeln("مرحبًا");

builder.InsertCell();

builder.Writeln("مرحبًا");

builder.EndRow();

builder.InsertCell();

builder.Writeln("مرحبًا");

builder.InsertCell();

builder.Writeln("مرحبًا");

builder.EndRow();

builder.EndTable();

// Save output document

builder.Document.Save(@"Test001\out.doc");

But, you should note, that Apsose.Words does not support RTL upon rendering yet. So such approach will not work if you save output document as PDF, XPS or print document using Aspose.Words.

Best regards.