【发布时间】:2018-04-17 12:21:27
【问题描述】:
我正在开发一个带有 WPF(MVVM 框架)桌面应用程序的项目。根据需要,我们在项目中集成 LiveCharts 以显示多个图表。现在,根据要求,我必须将多个图像显示为 pdf。如何使用 iTextSharp 生成 pdf?
【问题讨论】:
标签: c# wpf itext livecharts
我正在开发一个带有 WPF(MVVM 框架)桌面应用程序的项目。根据需要,我们在项目中集成 LiveCharts 以显示多个图表。现在,根据要求,我必须将多个图像显示为 pdf。如何使用 iTextSharp 生成 pdf?
【问题讨论】:
标签: c# wpf itext livecharts
我自己从 google 和 stackoverflow 找到了答案。 这是代码示例。
var DataValue = new LiveCharts.Wpf.PieChart
{
DisableAnimations = true,
Width = 600,
Height = 387,
Series = ViewModel.PieCollection
};
var viewbox = new Viewbox();
viewbox.Child = DataValue ;
viewbox.Measure(DataValue .RenderSize);
viewbox.Arrange(new Rect(new System.Windows.Point(0, 0), DataValue .RenderSize));
DataValue .Update(true, true);
viewbox.UpdateLayout();
//Save as image method with chart and name of image
SaveToPng(DataValue, "image.png");
【讨论】: