MSChart 渲染打印 EMF 错误

发布于 2024-12-10 03:29:00 字数 409 浏览 0 评论 0原文

使用 Microsoft 的图表控件 System.Windows.Forms.DataVisualization.Charting.Chart,我尝试将图表渲染为矢量图形。这里的最终目标是将图表渲染为足够高质量的图像,以便嵌入到 PDF 中并用于打印。

问题在于图表控件生成的 EMF 质量较低,并且不能代表控件在打印时的外观。在带有任何曲线的图表中,当嵌入 PDF 中时,EMF 只会显示为无法识别的像素化混乱。

我的问题是,有人在打印中成功使用过微软的图表控件吗?在这一点上,我什至不关心使用 EMF,因为该引擎看起来在不久的将来不会得到修复。我尝试使用高 DPI 渲染为 PNG,但这会影响图表上各个组件的厚度(设置为像素大小),以折线图中的系列线为例。

我不确定是否缺少某些设置,但如果有一个技巧可以使这些图表保持良好状态,我将非常有兴趣听到它。

Using Microsoft's charting control, System.Windows.Forms.DataVisualization.Charting.Chart, I am trying to render a chart to vector graphics. The ultimate goal here is to render a chart to a high enough quality image to be embedded in a PDF and used for print.

The problem is that the EMFs the Chart control produces are low quality, and do not represent what the control looked like at print time. In charts with any curved lines, the EMF simply shows up as an unrecognizable pixelated mess when embedded in a PDF.

My question is, has anybody successfully used Microsoft's charting controls in print? At this point, I am not even concerned with using EMF, as that engine looks like it will not be fixed any time in the near future. I have tried rendering to PNG with a high DPI, but this affects the thickness of various components on the chart (set to a pixel size), with the series lines in a line graph as one example.

I'm not sure if there are settings I am missing, but if there's a trick to getting these charts out in good shape I would be very interested to hear about it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷到爆炸 2024-12-17 03:29:00

如果有人感兴趣,看起来我已经找到了答案。如果图表中使用任何半透明颜色,则在生成的 EMF 文件中将无法正确渲染。只要避免部分透明的颜色(Alpha 不是 0 或 255),保存为 EMF 似乎总是可以。

需要注意的一件事是,某些效果(似乎)需要实现透明度,因此设置这些效果也会破坏生成的 EMF。此类效果的一个示例是将饼图设置为凹形。渲染到 EMF 没有问题的饼图一旦设置为凹面,就会变得无法识别。

希望这可以帮助某人节省我们解决此问题所需的三天时间。

If anybody's interested, it looks like I have found the answer. If any semi-transparent color is used in a chart, it will not render properly in the EMF file coming out. As long as you avoid partially transparent colors (Alpha that is not 0 or 255), saving as EMF seems to always come out OK.

One thing to take note of is that certain effects (seem to) require transparency to be achieved, and so setting those will also corrupt the resulting EMF. One example of that sort of effect is setting a Pie chart to concave. A pie chart that renders to EMF with no problem will become unrecognizable once it is set to concave.

Hope this helps someone save the three days it took us to work this out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文