I am working on an application where I have to put an extra line of text after original printed text.
For this, I am using FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification methods of Print Spooler API which works fine.
I am able to get Print Queue which shows number of job count 1.
I am using following code to add a new job in Print Queue:
// Create the printer server and print queue objects
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();
// Call AddJob
PrintSystemJobInfo myPrintJob = defaultPrintQueue.AddJob();
// Write a Byte buffer to the JobStream and close the stream
Stream myStream = myPrintJob.JobStream;
Byte[] myByteBuffer = UnicodeEncoding.Unicode.GetBytes("This is a test string for the print job stream.");
myStream.Write(myByteBuffer, 0, myByteBuffer.Length);
myStream.Close();
My code execute successfully without any exception but the new job doesn't get printed along with original text.