当我在c#中使用PrintServer类时,我会得到打印队列和打印作业,但是对于iR-ADVC 3525或其他物理打印机,printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize.PageMediaSizeName.ToString()
的结果总是ISOA4
。即使我定义了ISOA3
或其他格式。
我尝试将物理打印机首选项设置为A3。所以printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize.PageMediaSizeName.ToString()
是ISOA3
。
但是,我希望从打印spokesman而不是从首选项中检索信息
我试过使用Microsoft Print to PDF
(用于创建PDF的虚拟打印机),当我定义它时,我得到了ISOA 3格式。
下面是我迭代打印作业的代码:
public void CatchJobs()
{
PrintServer printServer = new PrintServer();
PrintQueueCollection printQueues = printServer.GetPrintQueues();
foreach (PrintQueue printQueue in printQueues)
{
printQueue.Refresh();
if (printQueue.GetPrintJobInfoCollection() != null)
{
PrintJobInfoCollection printJobs = printQueue.GetPrintJobInfoCollection();
foreach (PrintSystemJobInfo printJob in printJobs)
{
Job job = new Job(printJob);
if (printJob.JobStatus.HasFlag(PrintJobStatus.Printed) && !Jobs.Contains(job))
{
lock (Jobs)
{
Jobs.Add(job);
}
}
}
}
}
}
下面是我的Job类的构造函数:
public Job(PrintSystemJobInfo printJob)
{
Name = printJob.Name;
Status = printJob.JobStatus.ToString();
Owner = Environment.UserName;
Priority = printJob.Priority.ToString();
TimeSubmitted = printJob.TimeJobSubmitted;
Color = printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.OutputColor.Value.ToString();
DriverName = printJob.HostingPrintQueue.FullName;
JobId = printJob.JobIdentifier;
// Problem HERE
string? paperSize = printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize.PageMediaSizeName.ToString();
// End problem
PaperSize = paperSize is null ? "format inconnu" : paperSize;
double? paperLenght = printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize.Height;
double? paperWidth = printJob.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.PageMediaSize.Width;
PaperLength = paperLenght is null ? 0 : Math.Round((double)paperLenght * _pixelSize);
PaperWidth = paperWidth is null ? 0 : Math.Round((double)paperWidth * _pixelSize);
TotalPages = printJob.NumberOfPages;
}
能帮我吗?
1条答案
按热度按时间8dtrkrch1#
我希望这个解决方案能与
iR-ADVC3525
或其他物理打印机一起工作。用
Brother MFC-L8690CDW
系列打印机,用managementObject
从System.Management
。我用这个构造函数得到正确的信息:为了得到ManagementObject,我这样做: