I'm looking to create a .NET virtual printer that I can install on client's machines and have them print to it so that I can do some custom print job events such as:

  • Parse the printjob for specific keywords and save the print out as PDF to specific folders depending on the keyword
  • OCR the printjob if needed to detect the keywords

Anyone know of a library or software that can help me achieve this functionality?


1 Answer 1


There’s a customizable printer driver in the LEADTOOLS Virtual Printer SDK. (Disclosure: I work for LEADTOOLS vendor).

This forum post contains a C# demo project that uses the printer driver events to intercept print jobs and save them as PDF.

To parse the printed page text, I modified that project’s EMF event, which is triggered for every page in the print job, and obtained plain text from the page using the following code:

// Printed pages event
private static void Printer_EmfEvent(object sender, EmfEventArgs e)
   DocumentWriter tempDocWriter = new DocumentWriter();
   MemoryStream memoryStream = new MemoryStream();
   tempDocWriter.BeginDocument(memoryStream, DocumentFormat.Text);
   using (Metafile metaFile = new Metafile(e.Stream))
      tempDocWriter.AddPage(new DocumentWriterEmfPage()
         EmfHandle = metaFile.GetHenhmetafile()
   tempDocWriter.EndDocument(); // Save the page as TEXT format into the stream
   memoryStream.Position = 0;
   StreamReader streamReader = new StreamReader(memoryStream);
   string pageText = streamReader.ReadToEnd();
   //Now the string can be parsed

Regarding OCR, the toolkit also contains an OCR engine that can be used to convert image-based print jobs to text.

If you would like to try the SDK, there’s a free evaluation edition on this page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.