【问题标题】:How to printing a document in silverlight如何在 Silverlight 中打印文档
【发布时间】:2013-01-29 15:09:47
【问题描述】:

我在 silverlight 中编写了一个应用程序 Web 以查看 Tiff 文件。 我将 Tiff 文件的绝对 uri 发送到 silverlight 应用程序,它会查看/缩放或下载文件。

我使用 PrintDocument 库打印 tiff,但发送到打印机的文件非常大(100kb 的 tiff 文件需要 500Mb)。

现在这是我的打印代码:

 Protected Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
    Try
        If (PrintPageCount = 0) Then
            PrintPageCount = ImageTiff.NumberOfDirectories
            PrintCurrPage = 0
        End If
        If (PrintCurrPage < PrintPageCount) Then
            ImageTiff.SetDirectory(PrintCurrPage)
            Dim cnv As New Canvas With
                {
                    .Width = 840,
                    .Height = 1180,
                    .Background = New ImageBrush With {
                             .ImageSource = GetWritableBmp(ImageTiff, larghezza, altezza),
                             .Stretch = Stretch.Fill
                     }
                }
            ev.PageVisual = cnv
            PrintCurrPage += 1
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
        End If
    Catch ex As Exception
        MessageBox.Show("Errore handler:" & ex.Message & vbCrLf & ex.StackTrace)
    End Try
End Sub

还有我的打印按钮事件处理程序

 Private Sub ButtonPrint_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonPrint.Click
    Try
        Dim pdoc As New PrintDocument()
        AddHandler pdoc.PrintPage, AddressOf Me.pd_PrintPage
        pdoc.Print(Uri.AbsoluteUri)
    Catch ex As Exception
        MessageBox.Show("Errore:" & ex.Message)
    End Try
End Sub

我想将“http://www.mysite.it/tifffiles/mytif.tif”的打印直接发送到打印机,可以吗?

【问题讨论】:

  • 我知道这样的事情可以通过使用 3rd 方控制来实现,例如。阿缪尼。

标签: silverlight printing uri tiff printdocument


【解决方案1】:

在 Silverlight 4 及更高版本中,Microsoft 扩展了对打印文档的支持。见http://msdn.microsoft.com/en-us/library/ee671023(v=VS.95).aspx。如果您可以将 TIFF 转换为 XAML 文档或位图,它可能会使您的过程更容易。

【讨论】:

    猜你喜欢
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多