我在silverlight中编写了一个用于查看Tiff文件的应用程序网站。 我将一个绝对uri的Tiff文件发送到silverlight app并查看/缩放或下载文件。
我使用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”的打印件,这可能吗?
答案 0 :(得分:1)
在Silverlight 4及更高版本中,Microsoft扩展了对打印文档的支持。见http://msdn.microsoft.com/en-us/library/ee671023(v=VS.95).aspx。如果您可以将TIFF转换为XAML文档或位图,则可以使您的过程更容易。