我正在尝试在 wpf 中打印 tableview ,但唯一的问题是我只打印第一页(就像截图一样)。向下滚动时并非所有数据。
private void Print(Visual v)
{
System.Windows.FrameworkElement e = v as System.Windows.FrameworkElement;
if (e == null)
return;
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == true)
{
Transform originalScale = e.LayoutTransform;
System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);
double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / e.ActualWidth, capabilities.PageImageableArea.ExtentHeight /e.ActualHeight);
e.LayoutTransform = new ScaleTransform(scale, scale);
System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
e.Measure(sz);
e.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
pd.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;
pd.PrintVisual(v, "print chart");
e.LayoutTransform = originalScale;
}
}