将多个文档发送到打印机 [英] Send Multiple Documents To Printer

查看:77
本文介绍了将多个文档发送到打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在.net wpf中有一个要求。

在本地文件夹中有一些.gif或.jpg格式的图像。 />
i想要通过按钮点击将文件夹中的所有图像发送到打印机。

i搜索google那里有 Printdocument 我们只能提供一个文件 PrintFileName



但我想为每个循环提供每个文件名。任何人都可以解释怎么可能



谢谢..

hi all,
I have one Requirement in .net wpf.
There are some images in format of .gif or .jpg in a local folder.
i want to send all images in a folder to a printer in button click.
i searched google There for Printdocument we can give only one file PrintFileName

But i want to give each file name in for each loop . any one can explain how is possible

Thanks..

推荐答案

Private Sub btnPrint_Click(sender As Object, e As RoutedEventArgs) Handles btnPrint.Click
        Dim printDialog = New System.Windows.Controls.PrintDialog()
        If printDialog.ShowDialog = False Then
            Return
        End If
        Dim fixedDocument = New FixedDocument()
        fixedDocument.DocumentPaginator.PageSize = New System.Windows.Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight)
        For Each p In _lablefilenames
            Dim page As New FixedPage()
            Dim info As System.IO.FileInfo = New FileInfo(p)
            'If info.Extension.ToLower = ".gif" Then
            '    page.Width = fixedDocument.DocumentPaginator.PageSize.Height
            '    page.Height = fixedDocument.DocumentPaginator.PageSize.Width
            'Else
            page.Width = fixedDocument.DocumentPaginator.PageSize.Width
            page.Height = fixedDocument.DocumentPaginator.PageSize.Height
            'End If
            Dim img As New System.Windows.Controls.Image()
            ' PrintIt my project's name, Img folder
            'Dim uriImageSource = New Uri(p, UriKind.RelativeOrAbsolute)
            'img.Source = New BitmapImage(uriImageSource)
            Dim Bimage As New BitmapImage()
            Bimage.BeginInit()
            Bimage.CacheOption = BitmapCacheOption.OnLoad
            Bimage.UriSource = New Uri(p)
            If info.Extension.ToLower = ".gif" Then Bimage.Rotation += Rotation.Rotate90
            Bimage.EndInit()
            'img.Width = 100
            'img.Height = 100
            img.Source = Bimage
            page.Children.Add(img)
            Dim pageContent As New PageContent()
            DirectCast(pageContent, IAddChild).AddChild(page)
            fixedDocument.Pages.Add(pageContent)
        Next
        ' Print me an image please!
        printDialog.PrintDocument(fixedDocument.DocumentPaginator, "Print")
    End Sub


http://stackoverflow.com/questions/10138948/how-to-print-multiple-wpf-pages一文件 [ ^ ]


这篇关于将多个文档发送到打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆