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

Free Support Forum - aspose.com

How to add paragraph with left and right aligned text on the same line in c#

Hi, I am trying to create Resume pdf. In that want to add candidate details in the header of first page left and right aligned on the same line. Can you please help me with this? I have tried this using table but its not working as expected.
Thanks

@manasiak

Can you please share sample expected output and the code you have tried using table so that we can help you accordingly.

Thanks for your reply.
I want resume to be in below formatimage.png (16.2 KB)

Below is the code
Table table = new Table();
table.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;
table.DefaultCellPadding = new MarginInfo();
table.DefaultCellPadding.Left = 5;
table.DefaultCellPadding.Right = 5;
table.DefaultCellPadding.Top = 5;
table.DefaultCellPadding.Bottom = 5;

Row row = table.Rows.Add();
row.Cells.Add(CandidateName);
Cell cell = row.Cells.Add(Candidate CurrentCompany);
cell.VerticalAlignment = VerticalAlignment.Center;
cell.Alignment = HorizontalAlignment.Center;

Row rowDecsription = table.Rows.Add();
Cell cell1 = rowDecsription.Cells.Add(Candidate Designation);
cell1.ColSpan = 1;
Cell cell2 = rowDecsription.Cells.Add(Candidate Education);
cell2.VerticalAlignment = VerticalAlignment.Center;
cell2.ColSpan = 2;
cell2.Alignment = HorizontalAlignment.Center;
table.Rows.Add();
table.Rows.Add();

@manasiak

You can add two cells in a single row and apply different alignments on the same line with the below code:

Document document = new Document();
Page page = document.Pages.Add();
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.ColumnWidths = "300 300";
table.ColumnAdjustment = ColumnAdjustment.AutoFitToWindow;
table.DefaultCellPadding = new MarginInfo();
table.DefaultCellPadding.Left = 5;
table.DefaultCellPadding.Right = 5;
table.DefaultCellPadding.Top = 5;
table.DefaultCellPadding.Bottom = 5;
Aspose.Pdf.Row row = table.Rows.Add();
Aspose.Pdf.Cell cell1 = row.Cells.Add("Candidate Name: ");
cell1.VerticalAlignment = VerticalAlignment.Center;
cell1.Alignment = HorizontalAlignment.Left;
Aspose.Pdf.Cell cell2 = row.Cells.Add("Current Company: ");
cell2.VerticalAlignment = VerticalAlignment.Center;
cell2.Alignment = HorizontalAlignment.Right;
table.Top = 100;
table.Left = 50;
page.Paragraphs.Add(table);
document.Save(dataDir + "Table.pdf");

Thanks for you help. I will try above code.

@manasiak

Take your time and feel free to share your feedback.