Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to get a very simple pr

Status
Not open for further replies.

mattyboy2000

Programmer
Jul 31, 2002
129
GB
I am trying to get a very simple prototype program to print text directly to a Line printer. When I run the below code for a TextOnly driver I get the Error:

The data area passed to a system call is too small

Does anyone know why this is?? I've seen the same sort of problem in a few forums, but have never seen a solution.

Thanks matt

Public WithEvents pd As New Printing.PrintDocument()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frmSelectPrinter As New PrintDialog()
Dim frmPageSetUp As New PageSetupDialog()

Try
frmSelectPrinter.PrinterSettings = pd.PrinterSettings
frmSelectPrinter.ShowDialog()

MsgBox(pd.PrinterSettings.DefaultPageSettings.ToString)

frmPageSetUp.PageSettings = New Printing.PageSettings(pd.PrinterSettings)
If frmPageSetUp.ShowDialog = DialogResult.OK Then
MsgBox("ok")
End If
'Stop

pd.DefaultPageSettings = frmPageSetUp.PageSettings

pd.PrinterSettings = frmSelectPrinter.PrinterSettings

pd.Print()
Catch objErr As Exception
MsgBox(objErr.ToString)
Stop
End Try
End Sub

Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage
Dim strText As String = "Line 1"
Dim intCount As Int16

For intCount = 2 To 16
strText &= vbCrLf & "Line " & intCount
Next

e.Graphics.DrawString(strText, New Font("Arial", 10), Brushes.Black, 0, 0)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top