如何将System.Drawing.Font转换为Itextsharp Basefont

时间:2015-12-15 02:53:47

标签: c# .net winforms visual-studio itextsharp

我想在winform c#中将文本框的字体变成itextsharp basefont。 我还想根据winform中文本框的对齐方式在PDF中对齐文本。

2 个答案:

答案 0 :(得分:2)

使用FontFactory.RegisterDirectories()读取字体。从System.Drawing.Font获取字体名称,并使用该名称调用FontFactory.GetFont()

答案 1 :(得分:0)

您可以使用iTextSharp.text.Font代替以下内容:

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

如果您System.Drawing.Font使用以下内容:

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