打印不会以指定的偏移量打印 [英] Printing doesn't print at the specified offset

查看:74
本文介绍了打印不会以指定的偏移量打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在位置100,200(Point)打印文本A,但不在指定位置打印。

I use the following code to print text "A" at location 100,200 (Point), but is doesn't print at the specified location.

Imports System.IO
Imports System.Drawing.Printing


Public Class Form1
    Public egraphics As Graphics
    Public prnDocument As New System.Drawing.Printing.PrintDocument

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim psize As New Printing.PaperSize("A4", 842, 595)

        AddHandler prnDocument.PrintPage, AddressOf PrintPage

        prnDocument.DefaultPageSettings.PaperSize = psize
        prnDocument.DefaultPageSettings.Margins.Top = 0
        prnDocument.DefaultPageSettings.Margins.Left = 0
        prnDocument.DefaultPageSettings.Margins.Bottom = 0
        prnDocument.DefaultPageSettings.Margins.Right = 0
        prnDocument.OriginAtMargins = True


        prnDocument.Print()
    End Sub

    Private Sub PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
        Dim fReportFont As System.Drawing.Font

        egraphics = e.Graphics
        egraphics.PageUnit = GraphicsUnit.Point
        fReportFont = New System.Drawing.Font(Trim("Helvetica"), 60, FontStyle.Regular)
        egraphics.DrawString("A", fReportFont, New SolidBrush(Color.Black), 100, 200)

    End Sub

End Class





如果你想看到实际的印刷,请使用以下链接



http://social.msdn.microsoft.com/Forums/vstudio/ en-US / 7489fa8c-e50e-43b0-9491-17656cba789a / printing-doesnt-print-at-specified-points?forum = vbgeneral#aac3d27b-048e-4da7-9a43-fb60d9fefe04 [ ^ ]

推荐答案

x坐标差异是由DrawString方法应用的默认格式造成的。如果您应用System.Drawing.StringFormat.GenericTypographic作为格式,这将消失。至于你如何达到y坐标值小于要求的200点是我无法理解的。您引用的Adobe Acrobat屏幕截图显示大约210的字母顶部;然而正如Mike Meinz告诉你的那样,这首字母的顶部不是字符单元格的顶部。请参阅这个 [ ^ ],用于解释字符单元格布局。



The "x" coordinate discrepancy is due to the the default formatting applied by the DrawString Method. If you apply "System.Drawing.StringFormat.GenericTypographic" as the format this will disappear. As for how you arrived at the "y" coordinate value being less than the requested 200 pts is beyond my comprehension. The Adobe Acrobat screen shot you referenced show the top of the letter at approximately 210; however as Mike Meinz has told you, the top of the letter is not the top of character cell. See this[^], for an explanation of the character cell layout.

egraphics.DrawString("A", fReportFont, New SolidBrush(Color.Black), 100, 200, System.Drawing.StringFormat.GenericTypographic)





我建议您将绘制点更改为(72,72),以便您可以比在Adobe Acrobat中插入网格位置更好地查看布局。



I suggest that you change the draw point to (72, 72) so that you can see the layout better than trying to interpolate a grid position in Adobe Acrobat.


既然你完全忽略了关于这个话题的问题,我会在这里再次发布。



它可能因为PrintPreview没有考虑到非 - 大多数打印机具有的页面的可打印区域。
Since you completely ignored the questions ask on your other post about this topic, I'll post it again here.

It MAY be because the PrintPreview does not take into account the non-printable area of a page that most printers have.


这篇关于打印不会以指定的偏移量打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆