This is a migrated thread and some comments may be shown as answers.

Can not align a table

4 Answers 568 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 09 Mar 2020, 02:47 PM

Hello,

I have a problem. I want to create a table which should be right-aligned.

But when I try to set table.Alignment to Right It does not work.

I export this document into PDF.

 

Here is a sample code and the result screenshot.

 

1.RadFlowDocument document = new RadFlowDocument();
2.Table table = document.Sections.First().Blocks.AddTable();
3.table.Alignment = Alignment.Right;
4.TableRow row = table.Rows.AddTableRow();
5.TableCell cell = row.Cells.AddTableCell();
6.cell.Blocks.AddParagraph().Inlines.AddRun("sample text");

4 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 10 Mar 2020, 01:28 PM

Hi Daniel,

I am sorry to hear you are experiencing issues because of a missing functionality. Currently, the WordsProcessing library doesn't support the export of the table alignment (different from Left) when exporting to PDF. We have this feature request logged in our backlog: WordsProcessing: Support for Table.Alignment when exporting to PDF. You can cast you vote for the implementation as well as to subscribe to the task by clicking the Follow button to receive updates about status changes.

Regards,
Martin
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Daniel
Top achievements
Rank 1
answered on 22 Jun 2020, 12:24 PM

Hi Martin,

thank you for your answer.

Furthermore, I would like to ask you if there is a way to set TextDirection to right in the table cell while exporting to pdf.

I need numbers to be right aligned.

I will appreciate even if you advise me some hack to do that.

0
Martin
Telerik team
answered on 23 Jun 2020, 07:23 AM

Hi Daniel,

The right (or central) alignment of a table is related to a specific layout which should be calculated while drawing the content in the PDF document. I am afraid I cannot suggest an alternative which will allow you to achieve this in the current implementation. I am sorry I couldn't help more.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Richard
Top achievements
Rank 1
Iron
answered on 12 May 2023, 03:30 PM

Came across this post when I was trying to right-align a column (cell) in a table - I managed to do it like this;



...

row = table.Rows.AddTableRow();

TableCell cell = row.Cells.AddTableCell();
var cellParagraph = cell.Blocks.AddParagraph();

// qty of 100 in column, lets right justify it.
cellParagraph.TextAlignment = Alignment.Right;
cellParagraph.Inlines.AddRun("100");

...

Hope that helps anyone in future.

Dimitar
Telerik team
commented on 15 May 2023, 05:18 AM | edited

Hi Richard, 

I am glad that you have found a solution for your case. Please note that the right alignment is now supported and you can also align the entire table. 

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,

Dimitar

Tags
WordsProcessing
Asked by
Daniel
Top achievements
Rank 1
Answers by
Martin
Telerik team
Daniel
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Iron
Share this question
or