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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

String Alignment Centre

Thread ID:





129639 Mar 27,2017 11:37 AM UTC Mar 28,2017 12:04 PM UTC UWP 1
Tags: Pdf
Corey Powell
Asked On March 27, 2017 11:37 AM UTC

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)); 

Bhuvaneswari Nagarajan [Syncfusion]
Replied On 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. 
Bhuvaneswari N. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon