oxyplot icon indicating copy to clipboard operation
oxyplot copied to clipboard

Oxyplot is not printed (blank) when Printing WPF UI which is rescaled to fit on one page using .NET 7

Open supershopping opened this issue 2 years ago • 3 comments

Steps to reproduce

  1. Clone the repo from : https://github.com/supershopping/OxyPlotPrintTest
  2. Run application
  3. Click "Add Data" button
  4. Click "Print" button and select a printer to print on a "letter size paper".

Platform: .NET version: .NET 7

Expected behaviour

My goal is to print the WPF UI Window "Main" or the Datagrid "ReportGrid". The printing code is just to transform/resacle the UI to fit on one "letter" page. The Oxyplot is supposed to resize and print.

Actual behaviour

Once the UI is printed, you can see the buttons on the right side of the UI are prined but the Oxyplot is blank and not printed. I have another application using .NET framework 4.8 instead of .NET 7. With the same printing code, the UI printing is working properly. It seems an compatability issue with Oxyplot library using .NET 7, and I am not sure how to fix this or is there a workaround?

supershopping avatar Oct 30 '23 13:10 supershopping

I did a lot of testing. It turns out the pringting issue is related to Oxyplot version 2.1.2. When I am using 2.0 version of the library, the printing is working fine. Version 2.0 works for both .NET framework 4.8 and .NET7. Sorry for the confusion from my original post.

supershopping avatar Nov 01 '23 21:11 supershopping

To clarify, it works with 2.0.0 with netframework4.8 and net7.0, but not with 2.1.2 on net7.0?

Are you able to provide any sort of reproducing example?

VisualMelon avatar Nov 02 '23 08:11 VisualMelon

Yes. The Oxyplot 2.0.0 works with netframework4.8 and net7.0, The Oxyplot 2.1.2 does not work with netframework4.8 and net7.0, I have created an example (using .NET 7) at this repo: https://github.com/supershopping/OxyPlotPrintTest

The "Master" branch is using Oxyplot 2.0 version. Printing UI is OK. [UsingVersion2.1.2] branch is using Oxyplot 2.1.2. Printing UI is not working.

You can put a breakpoint on "pd.PrintVisual(v, "My Print");" and check the "v" through WPF Visualizer. The oxplot is empty in the Visualizer. The same result when you are printing on a real letter size paper.

supershopping avatar Nov 02 '23 19:11 supershopping