AMAR MATHUR
AMAR MATHUR

Reputation: 46

How to convert System.Drawing.Font into Itextsharp Basefont

I want to get the font of a textbox into itextsharp basefont in winform c#. I also want to align the text in a PDF according to alignment of the textbox in winform.

Upvotes: 0

Views: 2083

Answers (2)

Mohammad Dayyan
Mohammad Dayyan

Reputation: 22409

You can use iTextSharp.text.Font instead as the following:

Font font = FontFactory.GetFont("Segoe UI", 18.0f, BaseColor.Black);

if you have System.Drawing.Font use the following:

System.Drawing.Font systemDrawingFont = new System.Drawing.Font("Segoe UI", 12);
Font font = FontFactory.GetFont(systemDrawingFont.Name, systemDrawingFont.Size, BaseColor.Black);

Upvotes: 0

Paulo Soares
Paulo Soares

Reputation: 1916

Use FontFactory.RegisterDirectories() to read your fonts. Get the font name from System.Drawing.Font and call FontFactory.GetFont() with that name.

Upvotes: 3

Related Questions