mattyboy2000
Programmer
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
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