PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Jun 03, 2020 1:09 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Aug 29, 2019 11:27 pm 

Joined: Thu Aug 29, 2019 11:08 pm
Posts: 1
So this morning, I had a windows update.

Right after the update, my program is just broken.

It crashes on loading a custom font. Here is the exact code.

   Dim options As XPdfFontOptions = New XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always)
   Dim privateFonts As New System.Drawing.Text.PrivateFontCollection()
   privateFonts.AddFontFile(MyApp.fontPath & "thefont.ttf")
   Dim MyCustomFont As XFont = New XFont(privateFonts.Families(0), 12, XFontStyle.Bold, options)

it crashes with (on the 4th line) with:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

the addfontfile appears to not work. it comes back empty, where on a non upgraded machine it comes up valid.

Now Microsoft says you have to modify the app.config file. but I spent the entire day today messing with this and it just wont work. I literally have tried everything. I think its something else


Does anyone have any ideas? I am totally lost.

Ive confirmed it works on a machine that is not upgraded, and is broken on any machine that is.

The .exe's that where compiled before today all work, so at least my existing user based isn't affected

Reply with quote  
PostPosted: Tue Sep 03, 2019 9:15 am 
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3044
Location: Cologne, Germany
The caption is "Error compiling", but it looks like you are getting a run-time error.

You are using PrivateFontCollection, not XPrivateFontCollection. If AddFontFile no longer works this may not make a difference though.

The recommended way to use custom fonts is the WPF build of PDFsharp and the IFontResolver interface. While using XPrivateFontCollection should still work it is not the recommended way any more.

Thomas Hoevel
PDFsharp Team

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 42 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