PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Apr 24, 2024 8:31 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jun 12, 2023 11:00 am 
Offline

Joined: Tue Jun 06, 2023 4:44 am
Posts: 4
Hello,

I am encountering an issue while using PDFSharp 6.0.0-preview-2 library. Specifically, I am facing difficulties when trying to create an instance of XFont using the constructor new XFont("anyfont", anysize). The error message I receive is "No appropriate font found for family name '...'". This problem occurs consistently regardless of the font I attempt to use.

I have made sure that the fonts I'm trying to use are installed on my system. However, I'm still unable to create an XFont instance with the desired font.

I would appreciate any guidance or suggestions to resolve this issue. Has anyone else experienced a similar problem with XFont in PDFSharp 6.0.0-preview-2? Are there any known workarounds or solutions for this font-related error?

Thank you in advance for your help!

this is my test code
Code:
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;

class Program
   {
   static void Main(string[] args)
      {
      PdfDocument doc = new PdfDocument();
      PdfPage page = doc.AddPage();
      XSize size = PageSizeConverter.ToSize(PageSize.A4);
      page.Width = size.Width;
      page.Height = size.Height;
      using XGraphics gx = XGraphics.FromPdfPage(page);
      XFont font = new XFont("Tahoma", 15); // this line error
      gx.DrawString("test", font, XBrushes.Black, 10, 10);
      doc.Save("test.pdf");
      doc.Close();
      }
   }


Attachments:
Untitled.png
Untitled.png [ 151.14 KiB | Viewed 1764 times ]
Untitled.png
Untitled.png [ 81.01 KiB | Viewed 1765 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 12, 2023 11:34 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
SuperMENG wrote:
I have made sure that the fonts I'm trying to use are installed on my system. However, I'm still unable to create an XFont instance with the desired font.
Since much information is missing from your post, just a wild guess:
The Core build does not use the installed fonts automatically because it works under Windows, Linux, and other platforms.
Try the WPF or GDI build - those will automatically use the installed fonts.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 12, 2023 1:43 pm 
Offline

Joined: Tue Jun 06, 2023 4:44 am
Posts: 4
TH-Soft wrote:
SuperMENG wrote:
I have made sure that the fonts I'm trying to use are installed on my system. However, I'm still unable to create an XFont instance with the desired font.
Since much information is missing from your post, just a wild guess:
The Core build does not use the installed fonts automatically because it works under Windows, Linux, and other platforms.
Try the WPF or GDI build - those will automatically use the installed fonts.


Just wanted to say a quick thank you for suggesting the "PDFSharp_WPF" version! It fixed the font issue I was facing. Your help was greatly appreciated!

Thanks again,


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 248 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group