Exporting OxyPlot PlotModel to a ReportDocument yields a blurry image

1.1k Views Asked by At

Long time lurker, first time poster.

I'm currently working an WPF app that makes use of OxyPlot to generate a graph. I wish to export the generated graph to a ReportDocument (RDLC) and print it as a PDF using CutePdf. I am able to do this successfully.

Currently the approach I have take to do this is by executing the below code snippet.

using (var memStream = new MemoryStream())
{
   PngExporter.Export(PlotModel, memStream, 850, 700, OxyColors.White, 120);
   var fromStream = Image.FromStream(memStream);
   fromStream.Save(memStream, ImageFormat.Png);
   imageArray = new byte[memStream.Length];
   memStream.Seek(0, SeekOrigin.Begin);
   memStream.Read(imageArray, 0, (int) memStream.Length);
}

var stringBytes = Convert.ToBase64String(imageArray);

To pass this to a RDLC, I have to convert the memory stream to a Base64String and pass that as a parameter. As so;

var parameter = new ReportParameter("Chart", stringBytes);

reportViewer.LocalReport.SetParameters(parameter);

However, whilst this is all fine and dandy, the image output in the PDF seems to be incredibly blurry and pixelated when I zoom into it, whilst the surrounding text on the page is crisp.

I've had a go at plainly saving the image to disk as PNG/BMP/JPG but that also seems to return a blurry image so it's not a sizing issue.

  using (var stream = File.Create("testChart.png"))
  {
     var pngExporter = new PngExporter();
     pngExporter.Export(PlotModel, stream);
  }

I've attached a copy of the PDF with this post to show what I mean.

Thanks!

0

There are 0 best solutions below