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.

Mon Mar 11, 2024 7:38 am

When I use the following:

Code: Select all
page.Canvas.DrawString("text", font, brush, new RectangleF(), new(PdfTextAlignment.Justify, PdfVerticalAlignment.Bottom),


The text isn't justified aligned. It is just aligned left. How can I fix this?

PaulDictu2
 
Posts: 6
Joined: Mon Mar 11, 2024 7:27 am

Mon Mar 11, 2024 9:10 am

Hello,

Thanks for your inquiry.
Sorry, I didn't reproduce the issue you mentioned with our latest Spire.PDF Pack(Hot Fix) Version:10.2.2, If you are not using the latest version, please update and retest. Additionally, I have attached my complete test code for your reference, and the corresponding result file has also been uploaded to the attachment. If this is not the effect you want, please reply to us with more details about your needs. Some screenshots or complete test code will be helpful. Thank you in advance.
Code: Select all
PdfDocument doc = new PdfDocument();
PdfPen pen = new PdfPen(Color.Black);
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 20f), true);
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins(30, 50));
RectangleF rectangle = new RectangleF(40, 20, 480, 60);
page.Canvas.DrawString("text text", font, PdfBrushes.Red, rectangle, new PdfStringFormat(PdfTextAlignment.Justify, PdfVerticalAlignment.Bottom));
page.Canvas.DrawRectangle(pen, rectangle);
String result = "res.pdf";
doc.SaveToFile(result);


Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF

cron