【问题标题】:Print Job Exception when adding job in PrintQueue在 PrintQueue 中添加作业时出现打印作业异常
【发布时间】:2015-02-10 15:41:23
【问题描述】:

使用此代码:

PrintQueue pq;
using (var PS = new LocalPrintServer())
{
    pq = PS.GetPrinterQueue("HP Printer");
}

pq.AddJob("JobName 1", "C:\\Resources\\basic.xps", true, pq.DefaultPrintTicket.Clone());

我可以使用某些打印机队列成功打印文件,但不能使用我的所有打印机队列并且我得到 System.PrintJobException--Specified method is not supported(这里的参数PrintTicket是默认的,但是我需要这个重载方法才能改变这个值)。

还有PrintQueue.AddJob(string jobName, string filePath, bool fastCopy) 抛出 System.PrintJobException。

但是使用PrintQueue.AddJob(string jobName) 而不是PrintQueue.AddJob(string jobName, string filePath, bool fastCopy, PrintTicket printTicket) 不会引发异常,但无法指定要打印的文件。

是否每个驱动程序都支持 PrintQueue.AddJob()?有什么遗漏吗?

非常感谢。

我终于解决了用这个代替pq.AddJob()

pq.UserPrintTicket = pq.DefaultPrintTicket.Clone(); // Whatever PrintTicket we need
pq.Commit();
string s;
using (StreamReader strReader = new StreamReader("C:\\Resources\\basic.xps")){
s = strReader.ReadToEnd();
}
 PrintDocument p = new PrintDocument();
 p.PrintPage += delegate(object sender1, PrintPageEventArgs e1)
 {
       e1.Graphics.DrawString(s, new Font("Times New Roman", 12), new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));

};
p.Print();

【问题讨论】:

    标签: c# printing xps printqueue


    【解决方案1】:

    只需将fastCopy = false 设置为PrintQueue.AddJob(string jobName, string filePath, bool fastCopy)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-07
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多