Charles p

Charles p

  • NA
  • 17
  • 0

printing a web application

Sep 19 2008 1:49 PM

Hi, 

I am trying to print a summary of what the user entered.  I would like the whole form to print, but if not, i would settle for printing variables.  I have tried 2 diffrent ways.  I tried the javascript way to print the whole form, and it works, but when it prints, it comes out all messed up.  Nothings in the right place and everything is dark or just not good.  I was thinking its because I may have too many colors and stuff going on on the page.  So I tried to print variables on a white background using some code I found online.  It works, but when a variable is to big, the letters just go off the page.  Can someone tell me how to print the whole app correctly or could someone show me how to fix my variable printing class and sub proc. so that it doesnt print off the poage, but instead does a word wrap type deal.

 

Thanks in advance,

C

 

My printing variables class and sub:

Public Class myPrinter

Friend TextToBePrinted As String

Public Sub prt(ByVal text As String)

TextToBePrinted = text

Dim prn As New Drawing.Printing.PrintDocument

Using (prn)

prn.PrinterSettings.PrinterName _

= "pdf995"

AddHandler prn.PrintPage, _

AddressOf Me.PrintPageHandler

prn.Print()

RemoveHandler prn.PrintPage, _

AddressOf Me.PrintPageHandler

End Using

End Sub

Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Drawing.Printing.PrintPageEventArgs)

Dim myFont As New Drawing.Font("Microsoft San Serif", 10)

args.Graphics.DrawString(TextToBePrinted, _

New Drawing.Font(myFont, Drawing.FontStyle.Regular), _

Drawing.Brushes.Black, 50, 50)

End Sub

End Class