1

i'm trying to pause a print job once i print a document. but the problem is the printer will still continue even it says Paused.

i have an event log listener that would check for Microsoft-Windows-PrintService/Operational logs and my code would trigger once it detects event id 800 or Spooling Job id#.

here's my code for pausing the job, it pauses but still the document is being printed even it says paused.

private void EventWritten(Object obj, EventRecordWrittenEventArgs arg)
        {
            PrintQueue myPrintQueue = new PrintQueue(ps, printer, PrintSystemDesiredAccess.AdministratePrinter);
            foreach (var job in myPrintQueue.GetPrintJobInfoCollection())
            {
                job.Pause();
            }
        }

on EventID 308, it says i successfully paused

Document 29, Print Document owned by --- was paused on HP DeskJet 1110 series. This document will not print until the document owner resumes the print job. No user action is required.

can anyone help on how i can prevent printer to start printing?

EDIT: it pauses jobs that are heavy in size or multi-paged, else it will go straight to printing even if paused. screenshot

Fildor
  • 14,510
  • 4
  • 35
  • 67
Ezz Redfox
  • 89
  • 1
  • 9
  • Smells like XY. What are you trying to achieve? Why do you enqueue a printjob if you don't want it to be executed? – Fildor Mar 07 '18 at 12:21
  • it's some sort of security measure, when someone prints, the job must be paused first and will ask for a password or some sort. when the user is authorized then the job will resume, otherwise he will be forced to cancel and the print job canceled also. – Ezz Redfox Mar 07 '18 at 12:26
  • 2
    Hmm, from my POV it would be better to check that _before_ you enqueue the job in the first place. Or can jobs be enqueued from outside your app, too? (Or even from outside your app, _only_ ?) – Fildor Mar 07 '18 at 12:30
  • jobs are only enqueued outside of the app only (browser, ms word, etc) – Ezz Redfox Mar 07 '18 at 12:35
  • Ah, ok. That was not really clear from the question (at least for me). – Fildor Mar 07 '18 at 12:58

0 Answers0