We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

String Alignment Centre

Hi the code below is working fine, however, I would like a way to align the string centrally in the Rectangle, rather than using the "header.Left + 10" command

Many Thanks in advance,

 String drawString = "1.Retail Manager, Assistant Manager, Team Leader, Colleagues 121's and Talent Pipeline";
                PdfBrush solidBrush = new PdfSolidBrush(new PdfColor(51, 51, 255));
                     RectangleF header = new RectangleF(20, 30, 520, 20);
                          graphics.DrawRectangle(solidBrush, header);
                               PdfFont subHeadingFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 14);
                                    PdfTextElement element = new PdfTextElement(drawString,subHeadingFont);
                                         element.Brush = PdfBrushes.White;
                                                   element.Draw(page2, new PointF(header.Left + 10, header.Top + 2)); 

1 Reply

BN Bhuvaneswari Nagarajan Syncfusion Team March 28, 2017 12:04 PM UTC

Hi Corey, 
 
Thank you for using Syncfusion products, 
 
We have created the sample to achieved your requirement by using PdfStringFormat. We have attached the sample for your reference. Please find the sample from below link, 
 
 
Please let me know if you need further assistance. 
 
Regards, 
Bhuvaneswari N. 


Loader.
Up arrow icon