SetClip not working with Drawstring

Hi ,
I am trying to draw string in pdf using drawstring method. I certain cases, my text exceeds the width of my textbox. Hence I tried using SetClip for clipping the text. I dont want to use wordwrap since clipping is all the client needs. Please see the below code that I am using

           var format = new PdfStringFormat
            {
                LineLimit = false,
                WordWrap = wordWrap ? PdfWordWrapType.Word : PdfWordWrapType.None,
                Alignment = alignment.ToPdfTextAlignment(),
                LineAlignment = vAlign.ToPdfVerticalAlignment()
            };

           graphics.SetClip(new RectangleF((float)effectiveX, (float)effectiveY, (float)effectiveWidth,
                          (float)effectiveHeight));


           graphics.DrawString(text, font,color, new RectangleF((float)effectiveX, (float)effectiveY, (float)effectiveWidth,
                          (float)effectiveHeight),format);


Am I doing it right?

1 Reply 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team June 1, 2021 12:19 PM UTC

Hi Lakshmi, 
 
Thank you for contacting Syncfusion support. 
 
We can able to draw the exceeded text within the rectangle bounds by using DrawString method on our library.  We have created a simple sample for drawing the large multi-line text within the rectangle bounds, the text renders properly. We have attached the sample and output document for your reference. Kindly please try the sample on your end and let us know if it is suites your requirement.  
 
 
 
Please let us know if you need any further assistance with this. 
  
Regards, 
Gowthamraj K 


Marked as answer
Loader.
Up arrow icon