代码之家  ›  专栏  ›  技术社区  ›  user3112242

在Silverlight中打印。缺少一些页面

  •  1
  • user3112242  · 技术社区  · 9 年前

    我正在维护一个从银光灯打印支票的旧应用程序。 支票在网格中,用户选择它们并按下打印按钮。 我验证了网格中选择的所有支票都会发送到打印机,但我注意到有时实际打印输出中会丢失一些支票。我检查EndPrint是否有错误,但没有错误。 我如何确保所有数据都被实际打印?

    下面是printpage事件的代码

    StackPanel stackPanel = new StackPanel();
    CheckInfo check = selectedChecks[printItemIndex];
    PrintCheck printCheck = BuildPrintCheck(check);
    stackPanel.Children.Add(printCheck);
    stackPanel.Measure(new Size(args.PrintableArea.Width, double.PositiveInfinity));
    if (++printItemIndex < selectedChecks.Count) 
           args.HasMorePages = true;
    
    args.PageVisual = stackPanel;
    
    2 回复  |  直到 9 年前
        1
  •  1
  •   user3112242    9 年前

    我在这里找到了解决此问题的方法 http://www.thomasclaudiushuber.com/blog/2009/11/25/how-to-print-dynamically-created-images-in-silverlight-4-beta/

    基本上,不是将图像直接放入页面,而是放置一个矩形,并在运行时动态加载图像,将其设置为图像画笔的图像源,然后将矩形的填充属性设置为图像刷。

        2
  •  0
  •   user3112242    9 年前

    好吧,原来SilverLight5(运行时)在打印图像方面存在问题。运行SilverLight4的客户端不存在此问题。 下面是我在代码中修复它的方法

        private void PlaceImages()
            {
    
                var logoStreamResourceInfo = Application.GetResourceStream(new Uri("myApp;/Images/logo.png", UriKind.Relative));
                var logo = new BitmapImage();
                logo.SetSource(logoStreamResourceInfo.Stream);
                var logoImageBrush = new ImageBrush();
                logoImageBrush.ImageSource = logo;
                upperLogo.Fill = logoImageBrush;
                lowerLogo.Fill = logoImageBrush;
    
            }