Hello i hope someone can help. i have got the coding to print on a A4 paper but i need to change it so that it prints on to a paper that is:
Width.9.9 cm
Height.20.9 cm
to print preview then print i have coding as:
Private Sub PrintToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripButton.Click ‘PrintDocument1.DefaultPageSettings.PaperSource.Kind = “Custom”
‘PrintDocument1.DefaultPageSettings.PaperSize.Height = 21 ‘PrintDocument1.DefaultPageSettings.PaperSize.Width = 10 PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
‘ e.Graphics.FillRectangle(Brushes.Red, New Rectangle(500, 500, 500, 500)) Dim text As String = CompanyTextBox.Text Dim text2 As String = Me.FirstNameTextBox.Text + ” ” + Me.LastNameTextBox.Text Dim printFont As New System.Drawing.Font _ (“Arial”, 12, System.Drawing.FontStyle.Bold)
‘ Draw the content.
e.Graphics.DrawString(text, printFont, _
System.Drawing.Brushes.Black, 10, 10)
e.Graphics.DrawString(text2, printFont, _
System.Drawing.Brushes.Black, 10, 50)
e.Graphics.DrawString( _
text, _
printFont, _
System.Drawing.Brushes.Black, _
e.MarginBounds.Right, _
e.MarginBounds.Top _
)
e.Graphics.DrawString( _
text2, _
printFont, _
Brushes.Black, _
CSng( _
( _
e.PageBounds.Width – _
e.Graphics.MeasureString(text, Font).Width _
) * 0.5 _
), _
1000.0F _
)
End Sub
i hope someone can help i have search high and low for the coding, when i change the paper by add the coding as:
‘PrintDocument1.DefaultPageSettings.PaperSize.Height = 21
‘PrintDocument1.DefaultPageSettings.PaperSize.Width = 10
“PaperSize cannot be changed unless the Kind property is set to Custom.”
thanks for all your help.