关于 PrintDocument 在线等!!

blue_apple 2004-05-03 03:18:50
现在有一张 100 X 50 大小的纸,我用 PrintDocument 打印时如何去定义呢?

...全文
134 7 点赞 打赏 收藏 举报
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
blue_apple 2004-06-10
up
  • 打赏
  • 举报
回复
blue_apple 2004-05-04
我用下面的方法设置了自定义纸张,但打印时,打印机不能按 高度 300 的来分页,为了这

个我已两晚没睡好了,希望高手帮帮啦,,,

PrintDocument1.DefaultPageSettings.PaperSize = New PaperSize("Custom Paper Size", 433, 300)
  • 打赏
  • 举报
回复
lk_cool 2004-05-04
两种方法结合一下。

设定每一页的大小,再用坐标定位打到某个地方。
  • 打赏
  • 举报
回复
blue_apple 2004-05-03
我用的是连打纸,打完第一张后,第二张就移位了,,怎样解决呀,??
  • 打赏
  • 举报
回复
lk_cool 2004-05-03
可以会有帮助.
不管纸的大小,只控制打到什么地方行不行?

'[函数功能:][设定考生考试成绩的打印格式]
'[输入参数:][无]
'[输出参数:][无]
'[函数用法:][在打印时设计打印的格式]
'[完成时间:][2004-4-27]
'[函数作者:][LK]
'[应用范围:][本模块使用]
'[重要算法:]
'[函数注解:]
Private WithEvents printdoc As New Printing.PrintDocument
Private Sub printdoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printdoc.PrintPage

Dim g As Graphics = e.Graphics
Dim pen As New Drawing.Pen(Color.Black, 3)
Dim strfont1 As String = "黑体" 'arial
Dim strfont2 As String = "宋体"
Dim font As New Font(strfont1, 16, FontStyle.Bold)
Dim font1 As New Font(strfont2, 12)
Dim font2 As New Font(strfont2, 12)
g = e.Graphics
'draw page title
g.DrawString("山东省营运汽车驾驶员从业资格", font, Brushes.Black, 250, 100)
g.DrawString("理论考试成绩单", font, Brushes.Black, 330, 140)

'[第一行][包括姓名、性别、分数]
g.DrawString("姓名:", font2, Brushes.Black, 160, 200)
g.DrawString(sExamName, font2, Brushes.Black, 210, 200)
g.DrawString("性别:", font2, Brushes.Black, 300, 200)
g.DrawString(sSex, font2, Brushes.Black, 350, 200)
g.DrawString("分数:", font2, Brushes.Black, 400, 200)
g.DrawString(sScore, font2, Brushes.Black, 450, 200)

'[第二行准考证号]
g.DrawString("准考证号:", font2, Brushes.Black, 160, 240)
g.DrawString(sExamWarrant, font2, Brushes.Black, 240, 240)

'[第三行身份证]
g.DrawString("身份证号:", font2, Brushes.Black, 160, 280)
g.DrawString(sExamneeID, font2, Brushes.Black, 240, 280)

'[第四行考试时间]
g.DrawString("考试时间:", font2, Brushes.Black, 160, 320)
g.DrawString(dDateTime, font2, Brushes.Black, 240, 320)

'[资格类别][资格性质][考试性质]
g.DrawString("资格类别:", font2, Brushes.Black, 160, 360)
g.DrawString(sSort, font2, Brushes.Black, 240, 360)
g.DrawString("资格性质:", font2, Brushes.Black, 320, 360)
g.DrawString(sSpeciality, font2, Brushes.Black, 400, 360)
g.DrawString("考试性质:", font2, Brushes.Black, 540, 360)
g.DrawString(sExamSort, font2, Brushes.Black, 620, 360)

'[考点名称][考场编号]
g.DrawString("考点名称:", font2, Brushes.Black, 160, 400)
g.DrawString(sSpotName, font2, Brushes.Black, 240, 400)
g.DrawString("考场编号:", font2, Brushes.Black, 540, 400)
g.DrawString(sFieldNum, font2, Brushes.Black, 620, 400)


Dim ulCorner As New Point(560, 200) '[左上角]
Dim urCorner As New Point(650, 200) '[右上角]
Dim llCorner As New Point(560, 320) '[左下角]
Dim destPara As Point() = {ulCorner, urCorner, llCorner}

If File.Exists("c:\picwartmp\aa.jpg") Then
e.Graphics.DrawImage(Image.FromFile("c:\picwartmp\aa.jpg"), destPara)
End If
Application.DoEvents()

e.Graphics.Dispose()

End Sub
  • 打赏
  • 举报
回复
wangsaokui 2004-05-03
在System.Drawing.Printing 命名空间
  • 打赏
  • 举报
回复
wangsaokui 2004-05-03
PaperSize 类

指定纸张大小。

示例
[Visual Basic, C#, C++] 下面的示例使用打印机支持的纸张大小来填充 comboPaperSize 组合框。此外,将创建自定义的纸张大小并将其添加到组合框中。PaperName 被标识为一个属性,该属性将为通过组合框的 DisplayMember 属性添加的项提供显示字符串。该示例假定存在名为 printDoc 的 PrintDocument 变量,并且存在特定的组合框。
[Visual Basic]
' Add list of supported paper sizes found on the printer.
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName"

Dim pkSize As PaperSize
For i = 0 to printDoc.PrinterSettings.PaperSizes.Count - 1
pkSize = printDoc.PrinterSettings.PaperSizes.Item(i)
comboPaperSize.Items.Add(pkSize)
Next

' Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
Dim pkCustomSize1 As New PaperSize("Custom Paper Size", 100, 200)

comboPaperSize.Items.Add(pkCustomSize1)
  • 打赏
  • 举报
回复
相关推荐
发帖
VB
加入

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2004-05-03 03:18
社区公告
暂无公告