PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Wed Jul 02, 2025 10:31 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jun 23, 2025 12:57 pm 
Offline

Joined: Tue Feb 18, 2020 7:40 pm
Posts: 12
Hello,
I use PDFsharp-GDI 6.2.0 (nuget package)
I have problem embedding fonts. I posted my Font resolver, I also tried without ... Everything I tried it shows in Adobe Reader:

DejaVu Sans (Embedded Subset)
Type: TrueType (CID)
Encoding: Identity-H

Why it is not fully embedded. Please help me kind people.

I call it with this:
Dim options = New XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.EmbedCompleteFontFile)
Dim font = New XFont("DejaVu Sans", 12, XFontStyleEx.Regular, options)


Public Class MyFontResolver
Implements IFontResolver

Public Function ResolveTypeface(familyName As String, isBold As Boolean, isItalic As Boolean) As FontResolverInfo Implements IFontResolver.ResolveTypeface
If familyName = "DejaVu Sans" Then
Return New FontResolverInfo("dejavusans#regular", PdfFontEmbedding.EmbedCompleteFontFile)
End If
Throw New NotImplementedException("Font not supported: " & familyName)
End Function

Public Function GetFont(faceName As String) As Byte() Implements IFontResolver.GetFont
If faceName = "dejavusans#regular" Then
Return File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DejaVuSans.ttf"))
End If
Throw New FileNotFoundException("Font not found: " & faceName)
End Function
End Class


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 25, 2025 11:21 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3131
Location: Cologne, Germany
Hi!

"PdfFontEmbedding.EmbedCompleteFontFile" works as advertised and the complete TTF file will be embedded.
I cannot say why Adobe Reader sometimes shows "(embedded)" and sometimes "(embedded subset)".

You can check the size of the stream in the PDF file to verify it is identical to the size of the TTF file.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 23 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