纸张的大小由DevMode结构的四个属性决定:
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmFormName As String * CCHFORMNAME
其中dmFormName用于NT系统中指定打印纸张大小为预定义的某个纸张(Form),但是VB的 printer object不支持FormName属性,您可以通过API函数DocumentProperties修改DevMode结构的dmFormName属性实现自定义打印。
分两步做:
1. 先在打印机目录下,从File菜单下进入Server Properties对话框,在这里您可以手工添加自定义纸张,您也可以用API函数AddForm在程序中添加自定义纸张。
2. 在您的程序中,用API函数DocumentProperties获得当前打印机的设置并修改dmFormName为前面添加的自定义纸张。关于DevMode结构和DocumentProperties的使用可参考下面的例子。
Q282474 HOWTO: Print Using Custom Page Sizes on Windows NT/2000
http://support.microsoft.com/support/kb/articles/q282/4/74.asp
Q180645 FIX: Cannot Change Page Settings During Print Job
http://support.microsoft.com/support/kb/articles/q180/6/45.aspAPI函数的相关信息请参考:
AddForm
http://msdn.microsoft.com/library/en-us/gdi/prntspol_0prh.asp
DocumentProperties
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_7k1f.asp
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmFormName As String * CCHFORMNAME
其中dmFormName用于NT系统中指定打印纸张大小为预定义的某个纸张(Form),但是VB的 printer object不支持FormName属性,您可以通过API函数DocumentProperties修改DevMode结构的dmFormName属性实现自定义打印。
分两步做:
1. 先在打印机目录下,从File菜单下进入Server Properties对话框,在这里您可以手工添加自定义纸张,您也可以用API函数AddForm在程序中添加自定义纸张。
2. 在您的程序中,用API函数DocumentProperties获得当前打印机的设置并修改dmFormName为前面添加的自定义纸张。关于DevMode结构和DocumentProperties的使用可参考下面的例子。
Q282474 HOWTO: Print Using Custom Page Sizes on Windows NT/2000
http://support.microsoft.com/support/kb/articles/q282/4/74.asp
Q180645 FIX: Cannot Change Page Settings During Print Job
http://support.microsoft.com/support/kb/articles/q180/6/45.aspAPI函数的相关信息请参考:
AddForm
http://msdn.microsoft.com/library/en-us/gdi/prntspol_0prh.asp
DocumentProperties
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_7k1f.asp
上面msdn上的例子可以解决你的问题
因为对单一对象的纸张设定的改变并没有传递给datareport对象中打印纸张的改变!!惨!