Hello,
frist of all, sorry for my english
&
I use PDF Creator to avoid wasting paper and ink
I've found this code for printing:
and
Now I need to formatting the page...so I try to print a "X" at the top-right corner of the page:
e.Graphics.DrawString("X", Font, Brushes.Black, e.MarginBounds.Right, e.MarginBounds.Top)
or
e.Graphics.DrawString("X", Font, Brushes.Black, e.MarginBounds.Left + e.MarginBounds.Width , e.MarginBounds.Top)
But the X is not printed!
I've this value:
MarginBounds.Left: 100 , Right: 727, Top: 100, Bottom: 1069
PageSize (w x h): 827x1169
PrintableArea: 800x1137,5
Resolution: 600dpi
PaperSize.PaperName: A4
If I change e.Graphics.PageUnit from point to pixel, the X is printed near the left corner (about 2cm)
on a web site I've found that A4 size in point is 595x842 and with this value for margins the X is printed(in the top-right corner of the page, not the printable area):
e.Graphics.DrawString("X", Font, Brushes.Black, 595 - CharWidth, 0)
So, where am I wrong? why the margins are wrong?
Thank to all
frist of all, sorry for my english
&
I use PDF Creator to avoid wasting paper and ink
I've found this code for printing:
VB.NET:
Private Sub StampaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StampaToolStripMenuItem.Click
Try
If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
AddHandler PrintDocument1.PrintPage, AddressOf PrintDocument_PrintPage
PrintDocument1.Print()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
and
VB.NET:
Private Sub PrintDocument_PrintPage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
Try
e.Graphics.PageUnit = GraphicsUnit.Point
e.Graphics.RenderingOrigin = New Point(e.MarginBounds.Left, e.MarginBounds.Top)
Static Font As New Font("Trebuchet MS", 11, FontStyle.Regular, GraphicsUnit.Point)
Dim Y As Int16 = e.MarginBounds.Top
...
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Now I need to formatting the page...so I try to print a "X" at the top-right corner of the page:
e.Graphics.DrawString("X", Font, Brushes.Black, e.MarginBounds.Right, e.MarginBounds.Top)
or
e.Graphics.DrawString("X", Font, Brushes.Black, e.MarginBounds.Left + e.MarginBounds.Width , e.MarginBounds.Top)
But the X is not printed!
I've this value:
MarginBounds.Left: 100 , Right: 727, Top: 100, Bottom: 1069
PageSize (w x h): 827x1169
PrintableArea: 800x1137,5
Resolution: 600dpi
PaperSize.PaperName: A4
If I change e.Graphics.PageUnit from point to pixel, the X is printed near the left corner (about 2cm)
on a web site I've found that A4 size in point is 595x842 and with this value for margins the X is printed(in the top-right corner of the page, not the printable area):
e.Graphics.DrawString("X", Font, Brushes.Black, 595 - CharWidth, 0)
So, where am I wrong? why the margins are wrong?
Thank to all
Last edited: