PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

SOLVED Exception when rendering
http://forum.pdfsharp.com/viewtopic.php?f=2&t=3835
Page 1 of 1

Author:  vorobej [ Tue Aug 28, 2018 2:57 pm ]
Post subject:  SOLVED Exception when rendering

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.

Author:  Thomas Hoevel [ Tue Aug 28, 2018 3:35 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Tue Aug 28, 2018 3:49 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Tue Aug 28, 2018 4:53 pm ]
Post subject:  Re: Exception when rendering

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 9850 times ]

Author:  Thomas Hoevel [ Tue Aug 28, 2018 5:08 pm ]
Post subject:  Re: Exception when rendering

We use checkboxes from Wingdings, too.

Author:  Thomas Hoevel [ Tue Aug 28, 2018 5:10 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Tue Aug 28, 2018 5:12 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Tue Aug 28, 2018 8:55 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  Thomas Hoevel [ Wed Aug 29, 2018 7:46 am ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Wed Aug 29, 2018 3:44 pm ]
Post subject:  Re: Exception when rendering

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 ''.'

Author:  vorobej [ Wed Aug 29, 2018 4:15 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Wed Aug 29, 2018 5:35 pm ]
Post subject:  Re: Exception when rendering

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.

Author:  vorobej [ Thu Aug 30, 2018 3:45 pm ]
Post subject:  Re: Exception when rendering

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/