Free Support Forum - aspose.com

Right align cell contents?

how do I do this with the cell property? I can’t seem to find a way to right align the cell contents of a table in the pdf?

Dear bsarram,

Thank you for considering Aspose.

You have to right-align each paragraph in the cell.

i dont understand this method, can you show an example of line(s) of code?

Dear bsarram,

Thank you for considering Aspose.

Here is an example:

[XML]
<?xml version="1.0" encoding="utf-8" ?>







example for right alignment.








[C#]
Pdf pdf1 = new Pdf();
Section sec1 = pdf1.Sections.Add();

Table tab1 = new Table();
sec1.Paragraphs.Add(tab1);
tab1.ColumnWidths = "200";
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All,new Color("black"));

Row row1 = tab1.Rows.Add();
Cell cell1 = row1.Cells.Add();

Text text1 = new Text("example for right alignment.");
text1.TextInfo.Alignment = AlignmentType.Right;
cell1.Paragraphs.Add(text1);

pdf1.Save("e:/temp/test.pdf");


[VisualBasic]
Dim pdf1 As Pdf = New Pdf
Dim sec1 As Section = pdf1.Sections.Add()

Dim tab1 As Table = New Table
sec1.Paragraphs.Add(tab1)
tab1.ColumnWidths = "200"
tab1.DefaultCellBorder = New BorderInfo(BorderSide.All, New Color("black"))

Dim row1 As Row = tab1.Rows.Add()
Dim cell1 As Cell = row1.Cells.Add()

Dim text1 As Text = New Text("example for right alignment.")
text1.TextInfo.Alignment = AlignmentType.Right
cell1.Paragraphs.Add(text1)

pdf1.Save("e:/temp/test.pdf")