pdfsharp - 字体嵌入?

发布于 2024-08-07 07:18:34 字数 211 浏览 2 评论 0原文

我得到一个包含其他语言字体的文件。他们无法下载该字体,所以他们希望我将其嵌入到 pdf 中。

现在,我只有 PDF Reader,所以无法编辑或创建 pdf 文件。所以我决定使用 PDFSharp 库在 C#.NET 中快速完成此操作,但我似乎无法弄清楚如何使用 pdfSharp 嵌入字体?!

另外,我只需要处理 1 个文件,所以如果您知道手动执行此操作的方法,那就太好了。

I am given a file that has some other language font. They can not download the font, so they want me to embed it in the pdf.

Now, I only have PDF Reader, so I cant edit or create a pdf file. so I decided to quickly do it in C#.NET using PDFSharp library, but I just cant seem to figure out how to embed fonts using pdfSharp?!

Also, it's only 1 file that I have to process, so if you know of a way to do it manually, then that would be great too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怕倦 2024-08-14 07:18:34

有两种方法可以做到这一点。对于要嵌入的每种字体,如下所示:

var options = new XPdfFontOptions(PdfFontEmbedding.Always);
var font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);

然后,如果您使用该字体,它将被嵌入。

如果您希望嵌入页面上使用的所有字体,您可以这样做:

var page = new PdfPage();
var gfx = XGraphics.FromPdfPage(page);
gfx.MFEH = PdfFontEmbedding.Automatic;

第二种方法也适用于 MigraDoc 代码中使用的任何字体。

There are two ways to do this. For each font you want to embed like this:

var options = new XPdfFontOptions(PdfFontEmbedding.Always);
var font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);

Then if you use the font, it will get embedded.

If you want all fonts use on a page to be embedded you can do it like this:

var page = new PdfPage();
var gfx = XGraphics.FromPdfPage(page);
gfx.MFEH = PdfFontEmbedding.Automatic;

The second approach will also work for any fonts used in MigraDoc code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文