ccubed
August 4th, 2008, 11:45 AM
Okay, so i have this code. I need to print in a specific format and in landscape. So far, all I get is one line of jumbled text with all the lines in it. Apparently, VbNewLine doesn't make the printer go to a new line. Anyway to do that and make it print in landscape? Because currently, it won't print in landscape, instead it prints one line in normal mode.
Sub print_formated()
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog
printer.Document = doc
printer.ShowDialog()
AddHandler doc.PrintPage, AddressOf PrintPageHandler
doc.PrinterSettings().DefaultPageSettings.Landscape = True
doc.Print()
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim canvas As Graphics = e.Graphics
canvas.DrawString("WO#: " & wonumtxb.Text & vbTab & vbTab & "Maintenance Control TimeSheet" & vbTab & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Name: " & emplasttxb.Text & " | " & " Emp No: " & empnumcmb.SelectedItem & " | " & " Area " & convert_area(EmpCraft.Text) & " | " & " Lettered Shift: " & shiftnumcmb.SelectedItem & " | " & " Time: " & Date.Today.Hour.ToString & ":" & Date.Today.Minute.ToString & " | " & " Shift No: " & (shiftnumcmb.SelectedIndex + 1).ToString & " | " & " Supv: " & shiftnametxb.Text & " | " & " Date: " & Date.Today.ToString & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Job No." & vbTab & " | Acct " & vbTab & " | Cntr " & vbTab & " | Work Code " & vbTab & " | Description " & vbTab & vbTab & vbTab & " | Act Time " & vbTab & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
End Sub
I was thinking it may just be better to create a string in the background with all this crap then print that string, or have a hidden richtextbox that i create it in.
Sub print_formated()
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog
printer.Document = doc
printer.ShowDialog()
AddHandler doc.PrintPage, AddressOf PrintPageHandler
doc.PrinterSettings().DefaultPageSettings.Landscape = True
doc.Print()
End Sub
Private Sub PrintPageHandler(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim canvas As Graphics = e.Graphics
canvas.DrawString("WO#: " & wonumtxb.Text & vbTab & vbTab & "Maintenance Control TimeSheet" & vbTab & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Name: " & emplasttxb.Text & " | " & " Emp No: " & empnumcmb.SelectedItem & " | " & " Area " & convert_area(EmpCraft.Text) & " | " & " Lettered Shift: " & shiftnumcmb.SelectedItem & " | " & " Time: " & Date.Today.Hour.ToString & ":" & Date.Today.Minute.ToString & " | " & " Shift No: " & (shiftnumcmb.SelectedIndex + 1).ToString & " | " & " Supv: " & shiftnametxb.Text & " | " & " Date: " & Date.Today.ToString & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
canvas.DrawString("Job No." & vbTab & " | Acct " & vbTab & " | Cntr " & vbTab & " | Work Code " & vbTab & " | Description " & vbTab & vbTab & vbTab & " | Act Time " & vbTab & " | " & vbNewLine, _font, Brushes.Black, 0, 0)
End Sub
I was thinking it may just be better to create a string in the background with all this crap then print that string, or have a hidden richtextbox that i create it in.