【问题标题】:Get bytearray of a font in C#在 C# 中获取字体的字节数组
【发布时间】:2010-08-01 14:34:28
【问题描述】:

我目前正在使用 iTextSharp,我想使用自定义字体。

这是我目前所拥有的:

PrivateFontCollection fonts;
FontFamily family = LoadFontFamily("TheFont.ttf", out fonts);
var reader = new PdfReader("KurtBonne_test.pdf");
var stamper = new PdfStamper(reader,
new FileStream("Kurt Bonne_test_withtext.pdf", FileMode.Create));
var over = stamper.GetOverContent(1);
over.BeginText();
var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

//var bf = BaseFont.CreateFont("Test", BaseFont.CP1252, BaseFont.EMBEDDED, true,?,?)
over.SetFontAndSize(bf, 10);
over.SetTextMatrix(0, 140);
over.ShowText("page " + 0);
over.EndText();
stamper.Close();

现在,显然 BaseFont.CreateFont 有一个带有这个签名的重载方法:

BaseFont.CreateFont(string name, string encoding, bool cached, byte[] ttfAfm, byte[] pfb);

现在,我该如何使用 TheFont.ttf?不知何故,我需要一个字节数组(ttfAfm)...

【问题讨论】:

  • 顺便说一句,IText# 杀了我,因为 PdfReader 没有实现 IDisposable

标签: fonts itextsharp itext


【解决方案1】:

为什么不按照this tutorial 中为“我昂贵的自定义字体”指定的内容做呢?

【讨论】:

  • 嗯,还没有找到那个链接。 Thx,一定会在那里找到我想要的。
猜你喜欢
  • 2021-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多