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

Preview quality bad when used in other project (gdi)
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4005
Page 1 of 1

Author:  thyslo [ Wed Aug 21, 2019 9:46 am ]
Post subject:  Preview quality bad when used in other project (gdi)

Hi!

I have made a custom class for protocol reporting and printing. I set it up in a Windows Forms test project. There I created a DocumentPreview (using MDDDL for future WPF compatibility) and displayed it in a dialog:

Code:
      var preview = new DocumentPreview();
      preview.Document = DdlReader.DocumentFromString(protocol.GetDocumentDDL());

      var previewDialog = new PreviewDialog(preview);
      previewDialog.ShowDialog();


It looked great.
Attachment:
migra-01-good.png
migra-01-good.png [ 1.94 KiB | Viewed 10137 times ]


But after moving my protocol classes to an other project, an existing Windows Forms project with a big code base, the preview looked rather bad:
Attachment:
migra-02-bad.png
migra-02-bad.png [ 1.98 KiB | Viewed 10137 times ]


Both, test project and the other project are using:
MigraDoc: 1.50.5147 (gdi) from NuGet
Net-Framework: 4.5.2

My custom project for the protocol classes uses:
MigraDoc: 1.50.5147 (no gdi) from NuGet
Net-Framework: 4.5.2

Why is the preview blocky in the 2nd project?

Could it be any mysterious C# setting in the 2nd example that I'm not aware of?

Author:  Thomas Hoevel [ Wed Aug 21, 2019 11:32 am ]
Post subject:  Re: Preview quality bad when used in other project (gdi)

Did you take both screenshots on the same computer?

Maybe we see a TrueType font on the "good" image and a raster font (without anti-aliasing) on the "bad" image.

Maybe we see the same font, but once with "ClearType" anti-aliasing and once without any anti-aliasing.

Author:  Thomas Hoevel [ Wed Aug 21, 2019 11:44 am ]
Post subject:  Re: Preview quality bad when used in other project (gdi)

Two screenshots taken on my computer today:
Attachment:
Performance options - performance.png
Performance options - performance.png [ 14.45 KiB | Viewed 10132 times ]

Attachment:
Performance options - appearance.png
Performance options - appearance.png [ 18.87 KiB | Viewed 10132 times ]

Make sure "best appearance" is selected on all test machines.

Author:  thyslo [ Wed Aug 21, 2019 12:10 pm ]
Post subject:  Re: Preview quality bad when used in other project (gdi)

First, thank you for helping with my question.

I've just applied the setting from your screenshots. It was on "Let Windows choose..", now I set it to "Adjust for best appearance". But it didn't help unfortunately.

Booth screenshots were made on the same computer and the same display.

Also to me it looks as if the bad quality example misses some kind of "Clear type".

But I have no idea, why. Both examples are started in the same VS2017 successively, and both examples have the same PdfSharp and MigraDoc references.

So I only can suppose that in the bad quality example (with the big code base) somewhere a setting is applied that causes the DocumentPreview() to be created without AntiAliasing.

Author:  thyslo [ Wed Aug 21, 2019 12:38 pm ]
Post subject:  Re: Preview quality bad when used in other project (gdi)

I found it!

In the bad quality example there is an evil setting in Program.cs; just before Application.Run()
Code:
Application.SetCompatibleTextRenderingDefault(false);


I've just to find out why this is there, but when I comment out this line the protocol preview looks great:-)

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