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,001 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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