Wahyu Hidayat

Wahyu Hidayat

  • NA
  • 1
  • 8.1k

C#-APP How to get byte/stream of printed file

Dec 2 2008 1:16 AM
I write the code to get stream/bytes of printed file as follow:

private PrintSystemJobInfo GetInfo()
{
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue q = LocalPrintServer.GetDefaultPrintQueue();
q.Refresh();
foreach (PrintSystemJobInfo pj in q.GetPrintJobInfoCollection())
{
return pj;
}
return null;
}
PrintSystemJobInfo pj = GetInfo();
int len = pj.JobStream.Length;

I use Windows XP Sp2
When executing len = pj.JobStream.Length an error occur "Object reference not set to an instance of an object."

Is JobStream works in XP? Because I read that it works on vista only. Is there any other solution?

Answers (1)