Solved

How to Get Printing Document name with the pages printing using Printer Job Language (PJL) in C#

Posted on 2009-04-03
2
1,027 Views
Last Modified: 2012-06-27
Hi
I need to get following informations from Network printer using Printer Job Language (PJL) in C#
1. Printing Document name.
2. Currently Printed Page count
3. Current Job Status
4. Toner Level
5. Printer Current Status
6. Queue Names
0
Comment
Question by:infoplus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 500 total points
ID: 24084257
Try querying the WMI to get that information, but I think that will not be quite in real time... Another option is you can create a printer hook, but I haven't managed that in C#, only in Delphi few years ago...


Hope this helps!

Regards,
Mishu
using System;
using System.Management;
namespace WMI4
{
class Class1
{
static void Main(string[] args)
{
Console.WriteLine("Retrieving printer queue information using WMI");
Console.WriteLine("==================================");
//Query printer queue
System.Management.ObjectQuery oq = new System.Management.ObjectQuery
"SELECT * FROM Win32_PrintJob");
ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq);
ManagementObjectCollection queryCollection1 = query1.Get();
foreach( ManagementObject mo in queryCollection1 )
{
Console.WriteLine("Printer Driver : " + mo["DriverName"].ToString());
Console.WriteLine("Document Name : " + mo["Document"].ToString());
Console.WriteLine("Document Owner : " + mo["Owner"].ToString());
Console.WriteLine("==================================");
}
}
}
}

Open in new window

0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question