没有找到适合姓氏Arial的字体。实现IFontResolver并分配给GlobalFontSettings.FontResolver来使用字体

问题描述 投票:0回答:1

这是错误:

没有找到适合姓氏 Arial 的字体。实现 IFontResolver 并分配给 GlobalFontSettings.FontResolver 来使用字体

 using (SaveFileDialog sfd = new SaveFileDialog() )
 {
     if (sfd.ShowDialog() == DialogResult.OK)
     {
        
         PdfDocument doc = new PdfDocument();

         doc.Info.Title = "PDF";

       
         PdfPage page = doc.AddPage();

         XGraphics gfx = XGraphics.FromPdfPage(page);

     
         XFont font = new XFont("Arial", 25);

         for (int i = 0; i < txtBoxList.Count; i++)
         {
       
             gfx.DrawString(txtBoxList[i].Text, font, XBrushes.Black, new XPoint(0, 0));

         }
         doc.Save(sfd.FileName);
     }

在一些文本框中我写了一些文本,我想保存在pdf中,put给了我这个错误,我不知道该怎么办

c# winforms pdfsharp
1个回答
0
投票

您正在使用 PDFsharp 的核心版本,该版本可在 Windows、Linux、MacOS 等操作系统下运行。它只能使用您通过

IFontResolver
界面提供的字体。

如果您只想在 Windows 下运行,请使用 WPF 或 GDI+ 版本 - 它们将自动使用 Windows 文件夹中的字体。
否则实现 IFontResolver。

© www.soinside.com 2019 - 2024. All rights reserved.