Solved

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

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

708 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

13 Experts available now in Live!

Get 1:1 Help Now