Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jun 14, 2022 10:51 am

Hi,

I want to make the Amount column in right alignment in pdf grid cell. I have given the PDFTextAlignment to right but its not working properly. Please find the sample code and attached result and do the needfull. Thanks in advance.

Note: Want to align the FinalFee to Right Align and rest of the columns in Center Align
Capture.PNG
.

My example code:

PdfStringFormat stringFormat = new PdfStringFormat(PdfTextAlignment.Right);

for (int i = 0; i < dtResult.Rows.Count; i++)
{
row = grid.Rows.Add();
for (int k = 0; k < dtResult.Columns.Count; k++)
{
row.Cells[k].Value = dtResult.Rows[i][k].ToString();

if (k == 3)//Final Fee make it right alignment
row.Cells[k].Style.StringFormat = stringFormat;// new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
else
row.Cells[k].Style.StringFormat = stringFormat; // new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

row.Cells[k].Style.Font = new PdfFont(PdfFontFamily.Courier, 8f);
row.Cells[k].Style.Borders.All = new PdfPen(System.Drawing.Color.Transparent);
}
}

JayanthiJaya
 
Posts: 22
Joined: Thu Jan 21, 2021 6:06 am

Wed Jun 15, 2022 4:08 am

hi,

Please let me know is there any update on this issue?

JayanthiJaya
 
Posts: 22
Joined: Thu Jan 21, 2021 6:06 am

Wed Jun 15, 2022 6:58 am

Hi,

Thank you for your inquiry.
Please correct the row.Cells[k].Style.StringFormat as row.Cells[k].StringFormat to have a test. If the problem still exists, please provide the following information to help us further investigate your issue. You can attach your information here or send it to us via email (support@e-iceblue.com). Thank you in advance.
1) Your full testing code
2) Test environment, such as win10, 64bit.
3) Application type, such as Console App, .NET Framework 4.8.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Wed Jun 15, 2022 9:32 am

Hi,

Now the alignment is working properly. Thank you for your response :D .

JayanthiJaya
 
Posts: 22
Joined: Thu Jan 21, 2021 6:06 am

Thu Jun 16, 2022 1:34 am

Hi,

Thanks for your feedback.
If you have other questions, please feel free to write back.
Have a nice day :D

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron