如何使用VB WPF打印JPEG文件

时间:2019-02-14 09:24:50

标签: wpf vb.net visual-studio

我的计算机中有jpeg文件。我如何在WPF中使用VB.NET打印该文件。我已经尝试使用printDialoge方法 我当前的代码是:-

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnPrint.Click
        Dim Pd As New PrintDialog
        Dim vis As New DrawingVisual
        Dim drc As DrawingContext
        Dim img As System.Windows.Media.ImageSource
        Dim img1 As BitmapImage

        img1 = New BitmapImage(New Uri("C:\Windows\Temp\c.jpeg"))
        img = img1
        drc = vis.RenderOpen()
        drc.DrawImage(img1, New Rect(New Size(img1.Width, img1.Height)))
        If Pd.ShowDialog = True Then
            Pd.PrintVisual(vis, "fdfd")
        End If

    End Sub

0 个答案:

没有答案