How to read PrintQueueStream

Mar 3, 2013 at 11:40 PM
I am trying to read the PrintQueueStram, but it is "Nothing". How do I get at the spooled print job's data?
Apr 9, 2013 at 4:20 PM
See this example...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PrinterQueueWatch;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            Printer p = new Printer();
            p.StartWatching("Bullzip PDF Printer");

    class Printer
        private PrinterMonitorComponent mPr;

        public void StartWatching(string PrinterDeviceName)

            mPr = new PrinterMonitorComponent();

            mPr.MonitorPrinterChangeEvent = false;

            mPr.JobAdded += Addedtest;

                mPr.DeviceName = PrinterDeviceName;
            catch (Exception e)
                Console.WriteLine(e.Message + "\n==================" + e.StackTrace);

        public void Addedtest(object sender, PrintJobEventArgs e)
            Console.WriteLine("Impressora: " + e.PrintJob.PrinterName);
            Console.WriteLine("Usuário: " + e.PrintJob.UserName);
            Console.WriteLine("Documento: " + e.PrintJob.Document);
            Console.WriteLine("Páginas: " + e.PrintJob.TotalPages);
            Console.WriteLine("Data Impressão: " + e.PrintJob.Submitted);


Apr 10, 2013 at 10:52 PM
Do you want to get at the print job's actul data - i.e. the printer control language for each page in the job or just metadata about the job (such as what paper size and number of copied etc.)?

There is no code for the former in this library - although possibly the code in PrintJob.Transfer() might be a starting point....
   If OpenPrinter(Me.UniquePrinterObject, phPrinter, pDefault) Then
        If phPrinter.ToInt64 <> 0 Then
            'Read this print job into a bit of memory....
            Dim ptBuf As IntPtr
                ptBuf = Marshal.AllocHGlobal(Me.JobSize)
            Catch exMem As OutOfMemoryException
                Throw New PrintJobTransferException("Print job is too large", exMem)
                Exit Sub
            End Try

            '\\ Read the print job in to memory
            Dim pcbneeded As Integer
            If Not ReadPrinter(phPrinter, ptBuf, Me.JobSize, pcbneeded) Then
                Throw New PrintJobTransferException("Failed to read the print job", New Win32Exception)
                Exit Sub
            End If

            Dim DataFile As New PrinterDataFile(ptBuf, Me.DataType)

Apr 12, 2013 at 11:43 AM
I'll give this a tray today.
Apr 12, 2013 at 11:45 AM
Ideally I want the actual print job data and not metadata. The goal is to extract some of the text sent to the printer from another application.
Apr 15, 2013 at 10:05 PM
For that you would definitely need to use ReadPrinter (as above).

What makes it more tricky is that the print job data will be in one of many possible printer control languages such as EMF, PostScript, PCL-5, PCL-6 or HP-GL. You'd need to write a decoder plug-in for each printer language you encounter.