Solved

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

Posted on 2009-04-03
2
997 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now