我要做一个套打.... 欢迎来顶·

lk_cool 2004-06-08 08:44:19
我要做一个套打....

1、
==============================================
我的程序只有一套,不可以为每个用户都单做一份。

每个用户的打印机各不相同。

怎样才能做到在不同的打印机上打印的位置相同。

2、
===========================
'页边距
Dim margins As New Printing.Margins(0, 0, 0, 0)
printdoc.DefaultPageSettings.Margins = margins
这样做为什么不能从页边为0的地方打印?

'自定义页大小
Dim pkCustomSize1 As New Printing.PaperSize("p", 400, 200)
printdoc.DefaultPageSettings.PaperSize = pkCustomSize1
这样自定义页大小也没有作用


3、
=============================

Dim printviewer As New System.Windows.Forms.PrintPreviewDialog
printviewer.Document = printdoc
printviewer.ShowDialog()

这样的打印提示总是出现 : 第1页共(document)页 为什么?

怎样才能把这个打印页码提示去掉?
...全文
311 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangzai6640459 2004-08-29
  • 打赏
  • 举报
回复
关注
ruoyasoftware 2004-08-29
  • 打赏
  • 举报
回复
可以先设置好格式啊,对什么打印机都是一样!!
下面的可以参考一下!!
Private Sub PrintDocument2_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
Static currentchar As Integer
Dim txtfont As New Font("Arial", 16)
Dim txtH, txtW, pageheight, pagewidth As Integer
Dim LMargin, TMargin, RMargin, BMargin As Integer
With PrintDocument2.DefaultPageSettings
txtH = .PaperSize.Height - .Margins.Top - .Margins.Bottom
txtW = .PaperSize.Width - .Margins.Left - .Margins.Right
LMargin = .Margins.Left
TMargin = .Margins.Top
RMargin = .Margins.Right
BMargin = .Margins.Bottom
pagewidth = .PaperSize.Width
pageheight = .PaperSize.Height
End With
If PrintDocument2.DefaultPageSettings.Landscape Then
Dim tmp As Integer
tmp = pagewidth
pagewidth = pageheight
pageheight = tmp
End If
Dim at As New Rectangle(PrintDocument2.DefaultPageSettings.Margins.Left, PrintDocument2.DefaultPageSettings.Margins.Top, pagewidth - LMargin - RMargin, pageheight - TMargin - BMargin)
e.Graphics.DrawRectangle(Pens.Black, at)
Dim i, count As Integer
i = 1
Do While ((TMargin + 2 + txtfont.Height * i) < (pageheight - TMargin - BMargin))
e.Graphics.DrawLine(Pens.Black, LMargin, (TMargin + 2 + txtfont.Height * i), pagewidth - LMargin, (TMargin + 2 + txtfont.Height * i))
i = i + 1
Loop
e.Graphics.DrawLine(Pens.Black, LMargin, (TMargin + 2 + txtfont.Height * i), pagewidth - LMargin, (TMargin + 2 + txtfont.Height * i))
For i = 1 To 3
e.Graphics.DrawLine(Pens.Black, CSng(e.MarginBounds.Width / 4) * i, (TMargin + 2 + txtfont.Height), CSng(e.MarginBounds.Width / 4) * i, (e.MarginBounds.Top + pageheight - TMargin - BMargin))
Next
Dim txt As String
txt = "爱你一万年"
e.Graphics.DrawString(txt, txtfont, Brushes.Blue, Fix(e.MarginBounds.Width / 2.4), TMargin + 2)

End Sub
terryxin 2004-07-02
  • 打赏
  • 举报
回复
直接往打印机端口写数据,应该可以行的

Const GENERIC_READ = &H80000000
Const GENERIC_WRITE = &H40000000
Const OPEN_EXISTING = 3
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As IntPtr
=================
Dim iHandle As IntPtr
iHandle = CreateFile("LPT1", GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
If (iHandle.ToInt32 = -1) Then
MsgBox("没有连接打印机或者打印机端口不是LPT1")
Exit Sub
Else
If i = 0 Then MsgBox("打印机连接成功!")

Dim fs As New FileStream(iHandle, FileAccess.ReadWrite)
Dim sr As New StreamReader(fs) '读数据
Dim sw As New StreamWriter(fs, System.Text.Encoding.Default) '写数据

Dim j1 As Integer = 0
For j = 0 To dt1.Rows.Count - 1 Step 2
If j1 >= dt.Columns.Count Then
j1 = 0
End If
If j + 1 <= dt1.Rows.Count - 1 Then
sw.WriteLine(space(s1, dt.Rows(i).Item("makebill")) & space(s2, dt1.Rows(j).Item("orderid") & dt1.Rows(j).Item("workorder")) & _
space(s3, dt.Rows(i).Item("DozenID")) & space(s4, dt.Rows(i).Item("PackNum")) & space(s5, dt.Rows(i).Item("Sizes")) & space(s6, dt1.Rows(j).Item("orderid")) & Chr(27) & Chr(14) & dspace(s7, dt.Rows(i).Item(j1)) & Chr(20) & _
space(rs6, dt1.Rows(j + 1).Item("orderid")) & space(rs1, dt.Rows(i).Item("makebill")) & space(s2, dt1.Rows(j + 1).Item("orderid") & dt1.Rows(j + 1).Item("workorder")) & _
space(rs3, dt.Rows(i).Item("DozenID")) & space(rs4, dt.Rows(i).Item("PackNum")) & dt.Rows(i).Item("Sizes"))
Else
sw.WriteLine(space(s1, dt.Rows(i).Item("makebill")) & space(s2, dt1.Rows(j).Item("orderid") & dt1.Rows(j).Item("workorder")) & _
space(s3, dt.Rows(i).Item("DozenID")) & space(s4, dt.Rows(i).Item("PackNum")) & space(s5, dt.Rows(i).Item("Sizes")) & space(s6, dt1.Rows(j).Item("orderid")) & Chr(27) & Chr(14) & dspace(s7, dt.Rows(i).Item(j1)) & Chr(20) & _
space(rs6, " ") & space(rs1, " ") & space(s2, " ") & _
space(rs3, " ") & space(rs4, " "))
End If
j1 = j1 + 1
sw.WriteLine()
sw.WriteLine()
Next


webmasterss 2004-07-02
  • 打赏
  • 举报
回复
调API,但不是对所有型号打印机都管用,你试试吧!
whizstorm 2004-06-11
  • 打赏
  • 举报
回复
ding
GERY2003 2004-06-11
  • 打赏
  • 举报
回复
UP,没做过帮你顶

顶就一个字
我要说N 次
只希望楼主的问题能尽快消失
Lmovie 2004-06-11
  • 打赏
  • 举报
回复
关注中...
企业通用软件 2004-06-11
  • 打赏
  • 举报
回复
可不可以获得每个打印机的分辨率,然后,将打印机的【dpi】换算成窗体中的【缇】,试试看行不行
AntingZ 2004-06-09
  • 打赏
  • 举报
回复
关注
AKillGodKillBuddha 2004-06-09
  • 打赏
  • 举报
回复
偶也做过一个 很麻烦的
超过1000页之后就出现错位
loveerror 2004-06-09
  • 打赏
  • 举报
回复
学习中...
houxw 2004-06-09
  • 打赏
  • 举报
回复
用水晶报表吧
lk_cool 2004-06-09
  • 打赏
  • 举报
回复
帮我顶一下了。
liuyi3000 2004-06-09
  • 打赏
  • 举报
回复
up
lk_cool 2004-06-08
  • 打赏
  • 举报
回复
还有,我想在打印预览的时候把内容按100%显示,
可是总是按照自动显示,为什么该怎样设定?
CtrlT 2004-06-08
  • 打赏
  • 举报
回复


要做到在不同的打印机上打印的位置相同是很難的。

我看到我們同事以前在做報表時.
天天去幫她們調打印機。。。

可不是調代碼喔!!!!
lk_cool 2004-06-08
  • 打赏
  • 举报
回复
呵呵,谢谢,页面上有N多条数据,且要打印N次。
ypdff 2004-06-08
  • 打赏
  • 举报
回复
做一个摸板撒!
用户在打印的时候可以随便的改变控件在叶面上的位置!!

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧