Printing In Silverlight. Some pages missing

时间:2016-02-12 20:44:20

标签: silverlight

I am maintaining an old application that prints checks from silverlight. The checks are in a grid and the user selects them and presses the print button. I verified that all the checks selected in the grid do get sent to the printer but I noticed that sometimes some are missing in the actual printout. I check the EndPrint even for errors and there is none. How can I make sure all the data gets actually printed?

Here is the code for the printpage event

function downloadFileViaFTPURL($remote_data)
{
    // I dunno why, but this made it work...
    $search_replace = ["\\" => "/"];

    foreach ($search_replace as $search => $replace) {
        $remote_data = str_replace($search, $replace, $remote_data);
    }

    if ($remote_data = fopen($remote_data, "r")) {
        $filename = explode("/", $remote_data);
        $filename = end($filename);

        if (!file_exists("/path/to/folderforfile")) {
            mkdir("/path/to/folderforfile", 0755, true);
        }

        if (file_put_contents("/path/to/folderforfile/$filename", $remote_data)) {

            return true;

        }
    }
    return false;
}

downloadFileViaFTPURL("ftp://FTPUSER:FTPPASS@HOST.COM\Path\To\File.jpg");

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:0)

好吧事实证明,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;

        }