문제

I've written an application web in silverlight for view Tiff files. I send an absolut uri of Tiff files to silverlight app and it view /zooming or download a file.

I print the tiff with PrintDocument library, but the file sent to printer is very large (500Mb for 100kb of tiff file).

Now this is my code for printing:

 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

And my event handler for print button

 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

I want to send print of "http://www.mysite.it/tifffiles/mytif.tif" directly to printer, this is possible?

도움이 되었습니까?

해결책

In Silverlight 4 and above, Microsoft extended support for printing documents. See http://msdn.microsoft.com/en-us/library/ee671023(v=VS.95).aspx. If you can covert the TIFF to a XAML document or Bitmap it may make your process easier.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top