如何获得否.打印作业打印的页面数 [英] How to get no. of pages printed of a print job
本文介绍了如何获得否.打印作业打印的页面数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想拒绝.打印作业打印的页面数.
这是我正在使用的示例代码
Hi i want to get no. of pages printed of a print job.
Here is my sample code i am using
public PrintDocument prDocument = new PrintDocument();
prDocument.PrintController = new System.Drawing.Printing.StandardPrintController();
prDocument.PrinterSettings.PrinterName = selectedPrinter;
prDocument.Print();
int noOfPagesPrinted = GetNoOfPagesPrintedFromSpool(SelectedPrinter);
public int GetNoOfPagesPrintedFromSpool(string printer)
{
try
{
int pagesPrinted = 0, jobID;
string f_SearchQuery = "SELECT * FROM Win32_PrintJob";
ManagementObjectSearcher f_SearchPrintJobs = new
ManagementObjectSearcher(f_SearchQuery);
ManagementObjectCollection f_PrntJobCollection = f_SearchPrintJobs.Get();
foreach (ManagementObject f_PrntJob in f_PrntJobCollection)
{
jobID = Convert.ToInt32(f_PrntJob.Properties["JobId"].Value.ToString());
pagesPrinted = Convert.ToInt32(f_PrntJob.Properties["PagesPrinted"].Value.ToString());
}
return pagesPrinted;
}
catch (Exception ex)
{
return 0;
}
}
但是pagesPrinted始终为零.
问题是什么.任何帮助将不胜感激.
But pagesPrinted is always Zero.
What is the problem. Any help will be appreciated.
推荐答案
在这里,伙计.
对打印页面进行计数 [使用WMI询问打印机查询 [在Windows下使用C#计数打印的页面 [ ^ ]
Here you go man.
Count Printed pages[^]
Interrogating your Printer Queries with WMI[^]
Counting Printed Pages in Windows under C#[^]
添加此内容:
Hi Add this:
prntJob.Properties["TotalPages"].Value.ToString();
它将为您提供帮助.
It will Help you.
这篇关于如何获得否.打印作业打印的页面数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文