编辑 我试图重建我不再拥有的代码来展示。我认为这只是打印设置类的限制,不能通过使用对话框选择功能。看起来我应该能够配置和分配一个printerSettings对象到PrintDocument,然后打印那个PrintDocument...??? 我想错了吗?
再次编辑 我认为所有的setter都在'printerSettings.DefaultPageSettings'. 这将允许我修改打印设置。我还没有证明,但以后会。
PrintDocument pd = new PrintDocument();
pd.DocumentName = "test.doc";
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.?? <- I want to set the printer setting here e.g. DL, A4, etc
pd.PrinterSettings = printerSettings;
pd.Print();
我已经在C#中生成了Word邮件合并文档(支票、信函、文件),但所有这些文档都需要不同的打印机设置(支票=自定义设置,信函=DL信封,文件=A4)。
我已经保存了这些设置,并且可以在加载打印机首选项对话框时访问它们,但我希望能够将其构建到代码中,而不是手动更改打印机设置。我已经查看了一些资料,似乎打印机设置类应该是解决方案,但我无法使其正常工作。
以下是我尝试实现的伪代码示例。
//create the mail merge
IList<Letter> letters = MailMerge.Create(enum.letters)
Printer.Print(letters) //<-- in here I am trying set the printing preferences to DL Env
//create the mail merge
IList<Document> docs = MailMerge.Create(enum.documents)
Printer.Print(docs) //<-- in here I am trying set the printing preferences to A4
任何帮助都会受到欢迎。
谢谢。