Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 5 not printing on some printers

I have a Silverlight 5 OOB application (with Elevated Permissions) that's just been deployed to a number of our users. Some of these users are reporting that prints are coming out blank or very faint. These printers do print Word documents correctly and I am unable to reproduce the problem on my own printers.

All users are on Windows XP SP3 32 bit, and I am developing on Win7 64 bit.

As anyone seen this issue before? Or any idea what could be causing this?

Help much appreciated.

Many Thanks, Andrew

like image 723
Andrew Winn Avatar asked May 09 '12 12:05

Andrew Winn


1 Answers

I Should Got Solution May Be useFull To You.............................

First i created a new PrintDocument, and hooked up some handlers for its PrintPage event.

mobjPrintDocument = New PrintDocument
RemoveHandler mobjPrintDocument.PrintPage, AddressOf Print_Report
AddHandler mobjPrintDocument.PrintPage, AddressOf Print_Report

Then we can call the PrintBitmap function on the PrintDocument whenever you want to print. Here I am doing it when the user clicks the Print button.

Private Sub xbtnPrint_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
    mintPageIndex = 0
    mobjPrintDocument.PrintBitmap(FileName)
  End Sub

Now comes the important part. We can hijack the content targeted by hooking into the PrintPage event (as handled above). I can set the e.PageVisual to any visual xaml element and the PrintBitmap will handle it. Here I use the GetPages function and loop through to make sure I print each page (a pdfviewer element). However, you can point it to any visual element like I said.

Private Sub Print_Report(sender As System.Object, e As PrintPageEventArgs)
    e.PageVisual = xobjReportViewer.GetPages(mintPageIndex)
    mintPageIndex += 1
    e.HasMorePages = mintPageIndex < xobjReportViewer.GetPages.Count
  End Sub

The e.HasMorePages allows you to force the firing of this event until you are finished.

Hope this is helpful to someone. With Silverlight 5 and the Post-Script printer support, alot of printers that have a PostScript emulator may not be compatible, but will also not default to bitmap printing. This workaround fixes that, making printing a little bit more stable in a LOB type application.

like image 199
Jignesh.Raj Avatar answered Oct 16 '22 16:10

Jignesh.Raj