使用PrintForm组件 [英] Work with PrintForm component
本文介绍了使用PrintForm组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好!
我使用PrintForm组件打印我的winform。
属性myForm。 FormBorderStyle设置为无。
如何计算表格大小以使其适合A4?
谢谢!!!
Hello!
I use PrintForm component for printing my winform.
The property myForm.FormBorderStyle is set None.
How to calculate the size of the form to make it fit on A4?
Thanks!!!
推荐答案
昏暗宽度为整数
Dim Height As Integer
宽度= Me.width
高度= Me.Height
如果宽度*高度== 500990
MsgBox(这是A4 72 PPI)
参见纸张尺寸A4
http:// www .a4papersize.org / a4-paper-size-in-pixels.php [ ^ ]
Dim Width As Integer
Dim Height As Integer
Width =Me.width
Height=Me.Height
if Width*Height==500990
MsgBox("This is A4 72 PPI")
See paper size of A4
http://www.a4papersize.org/a4-paper-size-in-pixels.php[^]
Dim PrintForm1 As New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm()
PrintForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview
PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Left = 0
PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Top = 0
PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Right = 0
PrintForm1.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0
Dim g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
frm.Size = New Size(CInt(21 / 2.54 * g.DpiX), CInt(29.7 / 2.54 * g.DpiY))
PrintForm1.Print(frm, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
这篇关于使用PrintForm组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文