【问题标题】:How to convert System.Drawing.Font into Itextsharp Basefont如何将 System.Drawing.Font 转换为 Itextsharp Basefont
【发布时间】:2015-12-15 02:53:47
【问题描述】:

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

【问题讨论】:

  • 欢迎来到 stackoverflow :) 到目前为止你尝试了什么?
  • 我想根据winform文本框字体使basefont动态(不固定字体名称,字体大小,粗体,斜体,下划线)。我不知道如何执行此操作。

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


【解决方案1】:

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

【讨论】:

  • 请举个例子,那就是 niec
【解决方案2】:

您可以改用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);

【讨论】:

    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 2013-06-05
    • 2010-11-20
    • 2012-09-23
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    相关资源
    最近更新 更多