在AC#VSTO开关触发印刷之前,当前的打印机要颜色(打印机默认为黑色和白色)
我正在尝试说服一个VSTO Word加载程序,以设置打印机(将由Defult To Black-White设置)在调用WD.ActivedOcument.printout之前用颜色打印此文档。
printerSettings = new PrinterSettings();
try
{
printerSettings.PrinterName = wb.ActivePrinter;
}
catch
{
}
var pageSettings = new PageSettings(printerSettings);
//To Reset after printout
var printerColourDefaultSetting = printerSettings.DefaultPageSettings.Color;
var printColourSettings = pageSettings.Color;
if (PrinterSettings.SupportsColor) //I'd hope only one of these -but neither work
{
PrinterSettings.DefaultPageSettings.Color = true;
pageSettings.Color = true;
}
else
{
//doesn't support colour
}
object Background = true;
object Append = false;
object Range = PrintOutRange;
object To = missing;
object From = missing;
if (PrintOutRange == WdPrintOutRange.wdPrintFromTo)
{
To = LastPage.ToString(CultureInfo.InvariantCulture);
From = FirstPage.ToString(CultureInfo.InvariantCulture);
}
object Copies = NoCopies;
object PrintToFile = false;
object Collate = true;
wb.ActiveDocument.PrintOut(ref Background, ref Append, ref Range, ref missing, ref From, ref To,
ref missing,
ref Copies, ref missing, ref missing, ref PrintToFile, ref Collate,
ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
但是,使用此代码,我设置的PageSttings和DefaultPagesettings设置被忽略。有什么想法将其迫使文档的颜色变成颜色?
I'm trying to persuade a VSTO Word add-in to set the printer (which will be set by defult to black-and-white) to print this document in colour prior to calling wd.ActiveDocument.PrintOut
printerSettings = new PrinterSettings();
try
{
printerSettings.PrinterName = wb.ActivePrinter;
}
catch
{
}
var pageSettings = new PageSettings(printerSettings);
//To Reset after printout
var printerColourDefaultSetting = printerSettings.DefaultPageSettings.Color;
var printColourSettings = pageSettings.Color;
if (PrinterSettings.SupportsColor) //I'd hope only one of these -but neither work
{
PrinterSettings.DefaultPageSettings.Color = true;
pageSettings.Color = true;
}
else
{
//doesn't support colour
}
object Background = true;
object Append = false;
object Range = PrintOutRange;
object To = missing;
object From = missing;
if (PrintOutRange == WdPrintOutRange.wdPrintFromTo)
{
To = LastPage.ToString(CultureInfo.InvariantCulture);
From = FirstPage.ToString(CultureInfo.InvariantCulture);
}
object Copies = NoCopies;
object PrintToFile = false;
object Collate = true;
wb.ActiveDocument.PrintOut(ref Background, ref Append, ref Range, ref missing, ref From, ref To,
ref missing,
ref Copies, ref missing, ref missing, ref PrintToFile, ref Collate,
ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
However, with this code both the pageSettings and DefaultPageSettings settings I've set are being ignored. Any ideas how to force this into colour for a document?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“对象模型”一词不提供选择打印机的属性或方法。我想当您调用
打印输出
方法时,将使用默认一个。您可以使用Windows API设置默认打印机:
请参阅如何在C#中设置Windows默认打印机?以获取更多信息。
The Word object model doesn't provide property or method for choosing a printer. I guess the default one will be used when you call the
PrintOut
method.You can use the Windows API to set the default printer:
See How do I set the windows default printer in C#? for more information.