简体   繁体   English

如何在UWP中将Oxyplot导出为PNG?

[英]How to export Oxyplot to PNG in UWP?

I am using Oxyplot for UWP and would like to export my plot to a png. 我正在将Oxyplot用于UWP,并想将我的绘图导出到png。 It is possible to export to PDF in UWP but I was wondering if there was a work around for exporting to PNG. 可以在UWP中导出为PDF,但是我想知道是否存在可以导出为PNG的方法。 I know exporting to PNG is possible in WPF but not yet supported with the PngExporter in UWP like so: 我知道可以在WPF中导出到PNG,但尚不支持UWP中的PngExporter,如下所示:

using (var stream = File.Create(ApplicationData.Current.LocalFolder.Path + "\\" + "test.png"))
{
    var pngExporter = new PngExporter { Width = 800, Height = 400 };
    pngExporter.Export(PluggingPlot, stream);
}

This is the section included in their documentation document: 这是其文档文档中包含的部分: 文档图片

When trying to install either of those libraries on UWP it causes errors and functionality issues of the application as to be expected. 尝试在UWP上安装这些库中的任何一个时,都会导致应用程序出现错误和功能问题,这是可以预期的。

Is there any sort of work around for this PNG issue for UWP? UWP的此PNG问题是否有任何解决方法? Or is PDF the only exporting option available to me? 还是PDF是我唯一可用的导出选项? Possible to export to PDF then convert PDF to PNG maybe? 可以导出为PDF,然后将PDF转换为PNG吗? Thanks for any help on a work-around! 感谢您对解决方法的任何帮助!

How to export Oxyplot to PNG in UWP? 如何在UWP中将Oxyplot导出为PNG?

Currently, Oxyplot has not provided to convert PDF to PNG within UWP platform. 目前,Oxyplot还没有提供在UWP平台内将PDF转换为PNG的功能。 However, you could convert PDF to png with PDFTron . 但是,您可以使用PDFTron将PDF转换为png。 And this code sample . 和此代码示例 For converting pdf to png please check PDFDraw class. 要将pdf转换为png,请检查PDFDraw类。

try
{
    // A) Open the PDF document.
    using (PDFDoc doc = new PDFDoc(Path.Combine(InputPath, "tiger.pdf")))
    {
        // Initialize the security handler, in case the PDF is encrypted.
        doc.InitSecurityHandler();

        // B) The output resolution is set to 92 DPI.
        draw.SetDPI(92);

        // C) Rasterize the first page in the document and save the result as PNG.
        pdftron.PDF.Page pg = doc.GetPage(1);
        String output_file_path = Path.Combine(OutputPath, "tiger_92dpi.png");
        draw.Export(pg, output_file_path);
        WriteLine(String.Format("Example 1: Result saved in {0}", output_file_path));
        await AddFileToOutputList(output_file_path).ConfigureAwait(false);

        // Export the same page as TIFF
        output_file_path = Path.Combine(OutputPath, "tiger_92dpi.tif");
        draw.Export(pg, output_file_path, "TIFF");
        await AddFileToOutputList(output_file_path).ConfigureAwait(false);
    }
}
catch (Exception e)
{
    WriteLine(GetExceptionMessage(e));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM