PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Oct 15, 2019 5:58 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Tue Aug 28, 2018 2:57 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
Updating a solution that I created and which worked fine up till now using MigraDoc GDI package 1.50.4000-beta3b. The current version RC2 as of today has the same issue.
I am adding a a paragraph here and changing formatted text in another one there, nothing major.
But now when I run unit tests and hit the line with renderer.RenderDocument() it throws this exception:

Code:
System.ArgumentNullException: 'Value cannot be null.
Parameter name: fontFamilyName'


As I do not use fontFamilyName in the code, it is not clear what should be the approach for finding the root cause.


Last edited by vorobej on Thu Aug 30, 2018 3:46 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 3:35 pm 
Offline
PDFsharp Guru
User avatar

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

Obviously MigraDoc internally calls the method "public static FontDescriptor GetOrCreateDescriptor(string fontFamilyName, XFontStyle style)" while rendering the document.

You use this parameter indirectly.

Has anything changed in your code? Or maybe on your test computer? Fonts added? Fonts removed?

Not much we can do if we do not have code to replicate the issue.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 3:49 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
Well, my Windows 10 development box could have been re-built from the master image, but this document uses Trebuchet MS which was installed both on the old and new image.
The project itself originally survived an upgraded from 7 to 10 with no issues.

It's really hard to tell if anything changed. I am going to try to debug the source to see what is missing. Providing you with all source code does not make sense even if you had time to look into that, as there is very little custom stuff - all I am doing is slapping together paragraphs, and adding less than a handful of styles using very basic stuff like bold/italic/underlined. The only unorthodox thing that I do is splitting a static PDF into pages and appending them at the end of dynamic content, but I doubt it has anything to do with this issue.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 4:53 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
I use Wingdings font for displaying check boxes. This works currently and I made no changes to the way this works.
But it seems that during the rendering process the font family for Wingdings is blank.
I am defining a style to be used with Wingdings as a descendant of Normal, with size 11, bold, KeepWithText, and 6 point space after. Here the font size is 10 which is odd.


Attachments:
Capture.PNG
Capture.PNG [ 30.09 KiB | Viewed 2132 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 5:08 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2980
Location: Cologne, Germany
We use checkboxes from Wingdings, too.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 5:10 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2980
Location: Cologne, Germany
vorobej wrote:
Providing you with all source code does not make sense [...]
The idea behind the IssueSubmissionTemplate is that we get as little source code as needed to replicate the issue. And that we only have to press F5 to replicate it.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 5:12 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
Do I control the contents of FontFamily? I do not set it in my code.
I want to avoid having to carve out a test project for you and having you to look through the code, as I am 100% positive that this is not something I am doing wrong, and not a bug in MigraDoc, as this solution has been deployed onto a WS 2012 back in April and is working fine since. All I am changing is in the data: adding 1 new paragraph and splitting another paragraph from a solid text into 2 formatted text pieces, each with its own style. I am not changing styles or the way they are loaded and configured. This must be something envrionmental, such as Windows 10 font registration or similar. So I want to understand where does the blank font family name originates. What is the significance of it? Do you see a blank font family when you use styles based on Wingdings under Windwos 10?
It also occurred to me, that I am now on Visual Studio 2017 update 15.8.1, which has broken a number of projects around here, and we had to create workarounds.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 28, 2018 8:55 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
The first time I end up in CalcCurrentVerticalInfo() in the main solution, the CurrentFont name is blank.
In the brand new test project with only one a single paragraph the CurrentFont name is populated with what I set Normal style font to.
What drives the initial value of the CurrentFont name?

The problem exists even in 'vanilla' code with 'vanilla' data, i.e. in a copy of what currently is deployed to the 2012 server and working.
It is beyond doubt, that the fact that my old Windows 10 was an upgrade of Windows 7, but the new one is a brand new install, created this issue. That, or the infamous 15.8.1 update of VS 2017.
How much testing have you done under Windows 10? I would imagine that this being one of the most bugged, and totally revamped versions of Windows, everything is possible.
I will be more than happy to assist in testing this problem, but it will be difficult to provide you with the code, as this is a large solution, and database driven as well.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2018 7:46 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2980
Location: Cologne, Germany
We are using the WPF build in our application, not the GDI build. Maybe it is an option for you to test the WPF build.

There is VS 15.8.2 now. Maybe that makes a difference.

Generating an MDDDL file could be an option if you do not want to or cannot share code with us:
http://www.pdfsharp.net/wiki/MigraDocDDL.ashx

All our development computers are on Windows 10 and we switched pretty early. And yes, sometimes the Windows updates on Exploit Wednesday break existing code that worked since the days of Windows XP (and since XP is no longer updated, the old code continues to work under XP).

Maybe it is not really a bug in PDFsharp/MigraDoc, but a special constellation that requires special treatment. I'm afraid I can't do much unless I am able to set a breakpoint on that "throw" statement and reach it in the debugger.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2018 3:44 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
The new update to VS makes precious little difference.
With the WPF Nuget package I get a different exception in the same spot:

Code:
System.InvalidOperationException: 'Cannot get a matching glyph typeface for font ''.'


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2018 4:15 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
I got rid of Trebuchet MS and Wingdings and replaced them both with Arial. Same problem. Removed Arial to not re-define the defaults, still the same problem.

Had a co-worker build this in the vanilla VSS 2017 which had no updates installed, no luck.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 29, 2018 5:35 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
Downloaded the IE11-Win7 VM image from MS, spun up a VM, installed the latest VS 2017, and my solution passed unit tests without a hiccup.

Even with .NET 4.7.2 installed under Win7 this still works fine.


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 30, 2018 3:45 pm 
Offline

Joined: Tue Jul 26, 2016 5:07 pm
Posts: 32
Okay, so here's what ended up happening:

When I read style configurations from the database, I had nullable fields for font names, parent styles, etc. And if the value was null, I did not assign anything to the corresponding property of a new style being created. This worked fine under Win7.

Under Win10 I have to assign the font name. And as a workaround I started assigning the "Normal" style's font name if it came as a NULL from the database. Now everything works under Win10 as well as under 7. Where 7 worked fine with an un-assigned font name, Win10 breaks. Essentially a style which has a parent style assigned, still needs a font name. This is a change from 7 which I was not aware of.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 337 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