Hi. I try to Print Address Labels.
e.Graphics.PageUnit = GraphicsUnit.Millimeter
Label Margins in PrintDocument are :
Top Margin = 12.9 mm
Left Margin = 4.65 mm
Labels Gap = 2.5 mm
Label Height = 33.9 mm
Label Width = 99.1 mm
BUT when I Print on Paper Result :
Left Margin = 4.5 mm (on PrintDocument 4.65 mm)
Top Margin : 12.00 mm (on PrintDocument 12.9 mm)
Label Height = 33.00 mm (on PrintDocument 33.9 mm)
Label Width = 99.00 mm
Lagel Gap = 2.0 mm (on PrintDocument 2.5 mm)
all margins are Decimal... and I am not rounding any margin value. Used Math.Truncate(number) to disable Round.
Why all Margin Values are get lower rounded why I can not get the Real decimal Values after Printed on Paper ?
Code:Private Sub PrintDocument6_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument6.PrintPage e.Graphics.PageUnit = GraphicsUnit.Millimeter PrintDocument6.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize("Paper Size Name", 210, 297) PrintDocument6.DefaultPageSettings.Margins = New Margins(0, 0, 0, 0) Dim style As FontStyle = FontStyle.Regular Dim fonts As Font = New Font(New FontFamily("Monotype Corsiva"), 12, style) Dim pen As New System.Drawing.Pen(System.Drawing.Color.Black, 0.01F) Dim grpX As Graphics = e.Graphics Dim wdth As Decimal Dim hght As Decimal Dim horzGap As Decimal Dim HorLabel As Decimal Dim VerLabel As Decimal hght = Math.Truncate(((33.9) * 100) / 100) VerLabel = 8 wdth = Math.Truncate(((99.1) * 100) / 100) HorLabel = 2 horzGap = Math.Truncate(((2.5) * 100) / 100) For B = 12.9 To (hght * VerLabel) Step (hght) For A = 4.65 To (wdth * HorLabel) Step (wdth + horzGap) Dim rectX As Rectangle = New Rectangle((A), (B), (wdth), (hght)) grpX.DrawRectangle(pen, rectX) Next Next End Sub




Reply With Quote
