A
Aquali
Guest
Hi everyone
Here I am currently on the development of a label printing software under VB .NET. the printing is done well but does not take all the label. (it does this on standard printing software when I change the parameters which seem to correspond to the visibleClipBound of my program)
I think my problem is on the side of printableArea or visibleClipBound but I can't find how to edit it. PageBound.width returns me 300 and MarginBounds returns me 100. Could it come from there? How to do?
Or is it possible to create a custom picture dimension?
There is my code :
Public Class Form1
Private Sub PrintAction()
Dim PrintDoc As New Printing.PrintDocument
Dim paper As New Printing.PaperSize("Custom Paper Size", 500, 500)
PrintDoc.DefaultPageSettings.PaperSize = paper
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Left = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Right = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Top = 0
Dim PrintDlg As New PrintDialog ' This allows you to choose a printer rather than to print on system default printer
PrintDlg.Document = PrintDoc
PrintDlg.PrinterSettings = PrintDoc.PrinterSettings
If PrintDlg.ShowDialog <> DialogResult.OK Then
Exit Sub
End If
AddHandler PrintDoc.PrintPage, AddressOf PrintHandler
PrintDoc.Print()
RemoveHandler PrintDoc.PrintPage, AddressOf PrintHandler
End Sub
Private Sub PrintHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
Dim ag As Graphics = args.Graphics
ag.PageUnit = GraphicsUnit.Pixel
Dim bounds = ag.VisibleClipBounds
Dim fnt As New Font("Arial", 10)
ag.DrawString("Text", fnt, Brushes.Black, bounds.Left, bounds.Top)
args.HasMorePages = False ' Change this if you need to print multiple labels at once
End Sub
End Class
Continue reading...
Here I am currently on the development of a label printing software under VB .NET. the printing is done well but does not take all the label. (it does this on standard printing software when I change the parameters which seem to correspond to the visibleClipBound of my program)
I think my problem is on the side of printableArea or visibleClipBound but I can't find how to edit it. PageBound.width returns me 300 and MarginBounds returns me 100. Could it come from there? How to do?
Or is it possible to create a custom picture dimension?
There is my code :
Public Class Form1
Private Sub PrintAction()
Dim PrintDoc As New Printing.PrintDocument
Dim paper As New Printing.PaperSize("Custom Paper Size", 500, 500)
PrintDoc.DefaultPageSettings.PaperSize = paper
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Left = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Right = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0
PrintDoc.PrinterSettings.DefaultPageSettings.Margins.Top = 0
Dim PrintDlg As New PrintDialog ' This allows you to choose a printer rather than to print on system default printer
PrintDlg.Document = PrintDoc
PrintDlg.PrinterSettings = PrintDoc.PrinterSettings
If PrintDlg.ShowDialog <> DialogResult.OK Then
Exit Sub
End If
AddHandler PrintDoc.PrintPage, AddressOf PrintHandler
PrintDoc.Print()
RemoveHandler PrintDoc.PrintPage, AddressOf PrintHandler
End Sub
Private Sub PrintHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
Dim ag As Graphics = args.Graphics
ag.PageUnit = GraphicsUnit.Pixel
Dim bounds = ag.VisibleClipBounds
Dim fnt As New Font("Arial", 10)
ag.DrawString("Text", fnt, Brushes.Black, bounds.Left, bounds.Top)
args.HasMorePages = False ' Change this if you need to print multiple labels at once
End Sub
End Class
Continue reading...