如何将我的自定义纸张设置为默认纸张尺寸? [英] How to set my custom paper to defualt paper size??

查看:434
本文介绍了如何将我的自定义纸张设置为默认纸张尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正面临一个问题.我已经从服务器属性"中创建了一个新表单以进行打印.我在Windows打印机中将该自定义设置设置为默认设置,但是当我想在C#中打印水晶报表并检查那里的默认打印机纸张时,它会显示字母大小.在报表打印机默认设置"中,未选择我的自定义纸张作为默认纸张尺寸.每次打印时我都必须手动设置它.
我已在连接到PC的打印机中填充了所有纸张的列表.它显示总共19条记录.我的自定义论文名为"Receipt",索引号为17.当我在下面的代码中输入17时:

Hi All,
I am facing a problem. I have Created a new form from Server Properties for printing. I set that custom settings to default in windows printer but when i want to print crystal report in C# and check there default printer paper then it shows letter size. In Report printer default settings my custom paper not selected as default paper size. I have to set it manually every time when print.
I have populated a list of all papers in my printer attached to my PC. It display total 19 records. My custom paper named "Receipt" index number is 17. When i put that 17 in the following code:

PrintDocument pd;
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes[17];

I have tried this also
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes[ListBox1.SelectedIndex];


它给出错误对象引用未设置为对象的实例"
即使我放置了不同的索引,但错误是相同的.
如何将自定义纸张设置为默认纸张尺寸.
请帮助解决这个问题.我想根据我的自定义设置打印收据.请大家帮帮我!


it gives error "Object reference not set to an instance of an object"
Even i put different indexes but the error is same.
How to set my custom paper to defualt paper size.
Please help in this issue. I want to print Receipt according to my custom settings. Please Guys help me!

推荐答案

PrintDocument pd;
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes[17];

pd中的值是什么?

有什么想法可以解决此处的空引用?
可能是new关键字?

What value is in pd?

Anything spring to mind that might cure a null reference here?
The new keyword perhaps?


这篇关于如何将我的自定义纸张设置为默认纸张尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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