Quantcast
Channel: OxyPlot (moved to GitHub)
Viewing all articles
Browse latest Browse all 2061

Commented Unassigned: ToPdf extension method [10172]

$
0
0
The PlotModel has the ToSvg method. I was searching for the pdf export functionality and had to use one of the examples to find out how to do this.

I think it would be great if a small extension method could be added:

```
public static byte[] ToPdf(this PlotModel plotModel)
{
Argument.IsNotNull(() => plotModel);

return ToPdf(plotModel, plotModel.Width, plotModel.Height);
}

public static byte[] ToPdf(this PlotModel plotModel, double width, double height)
{
Argument.IsNotNull(() => plotModel);

using (var memoryStream = new MemoryStream())
{
PdfExporter.Export(plotModel, memoryStream, width, height);

return memoryStream.ToArray();
}
}
```
Comments: There is also simple pdf export in the core library. Use `OxyPlot.PdfExporter`, so it is possible to add an extension method here. I agree it is good to be consistent with the ToSvg extension method, but I see limited value since this is basically one line of code. Also, how much value is it to get a byte array? I think I would rather prefer to remove the `PlotModel.ToSvg` method!

Viewing all articles
Browse latest Browse all 2061

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>