I am working on a project to place text on a line in a PDF. The line will have a max width of a variable amount. I have successfully written a function to repeatedly reduce the size of the font by 0.5 points at a time, until the text fits. Is there any way that I can affect the horizontal scaling only? Or, perhaps the character spacing, as well?
CMChinnu Muniyappan Syncfusion Team August 9, 2017 12:30 PM UTC
Thank you for contacting Syncfusion support.
The font size reducing workaround is the right way to fit the text with in smaller bounds. And we can scale the text horizontally/vertically by using PdfGraphics.ScaleTransform. If horizontal scaling is applied to a string then the whole string will shrink compared to its regular size. we have created a simple sample for your reference, please refer the below code snippet and sample for more details.
//Create a new PDF document
PdfDocument doc = newPdfDocument();
//Add a new page
PdfPage page = doc.Pages.Add();
string text = "Hello World!.";
//Create new PDF font
PdfFont font = newPdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);