Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
AnswerRe: abstract classes Pin
PIEBALDconsult16-May-08 5:48
mvePIEBALDconsult16-May-08 5:48 
AnswerRe: abstract classes Pin
Hamid_RT17-May-08 7:22
Hamid_RT17-May-08 7:22 
Questionnotification Pin
ellllllllie16-May-08 1:38
ellllllllie16-May-08 1:38 
AnswerRe: notification Pin
originSH16-May-08 1:39
originSH16-May-08 1:39 
AnswerRe: notification Pin
Pete O'Hanlon16-May-08 2:06
mvePete O'Hanlon16-May-08 2:06 
Questionproblems in checklistbox Pin
Amitava Dutta16-May-08 1:05
Amitava Dutta16-May-08 1:05 
AnswerRe: problems in checklistbox Pin
Christian Wikander16-May-08 2:25
Christian Wikander16-May-08 2:25 
QuestionHow can i read print content (print document data) from a Job using PrintQueueStream [modified] Pin
Krishna Prasad RVS16-May-08 0:38
Krishna Prasad RVS16-May-08 0:38 
Hi right now i am using the following code, every thing is fine, but i am not getting the print content from the jobs in PrintQueue. Any one can help me or suggest me how can i read the content (print document data).

Always the "bPrintData" shows ZERO bytes length

Thanks in advance. This is very very urgent to me..

--Krishna


using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Net;
using System.IO;
using System.Printing;
using System.Collections;
namespace ManagingPrinterJobs

{

public partial class Form1 : Form
{

private PrintServer localPrintServer;
private PrintQueue defaultPrintQueue;
private Hashtable printJobsList1;
private Hashtable printJobsList2;
private PrintJobInfoCollection jobs;
delegate void ScheduleJobs_Delegate(object sender, System.Timers.ElapsedEventArgs e);
private System.Timers.Timer JobScheduleTimer = new System.Timers.Timer(1);
private PrintQueueStream prtQueStream;
private String sPrintJob = String.Empty;
private byte[] bPrintData;


private void Form1_Load(object sender, EventArgs e)

{

//localPrintServer = new LocalPrintServer();
PrintServer localPrintServer = new PrintServer("HP LaserJet 5000");
defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();
printJobsList1=new Hashtable();
printJobsList2=new Hashtable();
JobScheduleTimer.Elapsed += new System.Timers.ElapsedEventHandler(ScheduleJobs);
JobScheduleTimer.Start();
jobs = defaultPrintQueue.GetPrintJobInfoCollection();

foreach (PrintSystemJobInfo job in jobs)
{ printJobsList2.Add(job.JobIdentifier, job.Name); }

}

private void ScheduleJobs(object sender, System.Timers.ElapsedEventArgs e)

{

try

{

//if (textBox1.InvokeRequired)

//{

// ScheduleJobs_Delegate Delegate = new ScheduleJobs_Delegate(ScheduleJobs);

// textBox1.Invoke(Delegate);

//}

//else

//{

defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();

jobs = defaultPrintQueue.GetPrintJobInfoCollection();

foreach (PrintSystemJobInfo job in jobs)

{

if (!printJobsList2.Contains(job.JobIdentifier))

{

if (!printJobsList1.Contains(job.JobIdentifier))

{

job.Pause();

printJobsList1.Add(job.JobIdentifier, job.Name);

PrintQueueStream prtQueStream = new PrintQueueStream(defaultPrintQueue, job.Name, false);

bPrintData = new byte[prtQueStream.Length];

int qty = prtQueStream.Read(bPrintData, 0, Convert.ToInt32(prtQueStream.Length));

if (bPrintData.Length >= 1)

{

for (int i = 0; i <= bPrintData.Length; i++)

{

sPrintJob += Convert.ToChar(bPrintData);

}

}

job.Cancel();

}

}

}

if (sPrintJob != String.Empty)

{ MessageBox.Show(sPrintJob); }



}

}

Krishna Prasad RVS
Microsoft Certified Application Developer (MCAD)

modified on Friday, May 16, 2008 6:50 AM

QuestionXML encoding issue Pin
George_George16-May-08 0:11
George_George16-May-08 0:11 
AnswerRe: XML encoding issue Pin
mlsteeves16-May-08 3:48
mlsteeves16-May-08 3:48 
GeneralRe: XML encoding issue Pin
George_George16-May-08 4:49
George_George16-May-08 4:49 
GeneralRe: XML encoding issue Pin
mlsteeves16-May-08 5:22
mlsteeves16-May-08 5:22 
GeneralRe: XML encoding issue Pin
George_George16-May-08 20:37
George_George16-May-08 20:37 
GeneralRe: XML encoding issue Pin
mlsteeves20-May-08 1:55
mlsteeves20-May-08 1:55 
GeneralRe: XML encoding issue Pin
George_George20-May-08 3:55
George_George20-May-08 3:55 
GeneralRe: XML encoding issue Pin
PIEBALDconsult16-May-08 5:52
mvePIEBALDconsult16-May-08 5:52 
GeneralRe: XML encoding issue Pin
George_George16-May-08 20:39
George_George16-May-08 20:39 
GeneralRe: XML encoding issue Pin
PIEBALDconsult17-May-08 4:01
mvePIEBALDconsult17-May-08 4:01 
GeneralRe: XML encoding issue Pin
George_George17-May-08 4:13
George_George17-May-08 4:13 
GeneralRe: XML encoding issue Pin
PIEBALDconsult17-May-08 7:58
mvePIEBALDconsult17-May-08 7:58 
GeneralRe: XML encoding issue Pin
George_George17-May-08 21:33
George_George17-May-08 21:33 
GeneralRe: XML encoding issue Pin
PIEBALDconsult18-May-08 4:48
mvePIEBALDconsult18-May-08 4:48 
GeneralRe: XML encoding issue Pin
George_George20-May-08 3:51
George_George20-May-08 3:51 
GeneralRe: XML encoding issue Pin
PIEBALDconsult20-May-08 14:16
mvePIEBALDconsult20-May-08 14:16 
GeneralRe: XML encoding issue Pin
George_George20-May-08 22:53
George_George20-May-08 22:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.