Create your own port for printing in .NET.

I am trying to figure out if it is possible to create a custom print port in .NET. The functionality I'm trying to achieve is to intercept the data created by the printer driver and send it to a remote server instead of the device.

+3
source share
3 answers

Not really. Creating a virtual port driver or network redirector requires native code. However...

You can capture data by setting up a network print port and implementing the server side in .NET. For example, LPR will require you to create a TCP socket server, and this is entirely possible in C #.

I don't know any existing C # implementation, but you could learn a lot from the p910nd source code .

+1

, . #, PDF, .

:

:

   string fname = Environment.GetEnvironmentVariable("TEMP") + @"\";
    fname += DateTime.Now.ToString("yyyyMMdd-hhmmss-fffff") + ".ps";
    FileStream fs = new FileStream(fname, FileMode.Create);
    StreamWriter sw = new StreamWriter(fs);
    StreamReader sr = new StreamReader(Console.OpenStandardInput());
    sw.Write(sr.ReadToEnd());
    sw.Flush();
    sw.Close();
    sr.Close();

, :

  • Redmon Windows7. - , , Windows 2008. , redmon , PDFCreator. , , , #, , , .
  • Redmon , ; , Redmon, , ..., , .
+5

, mfilemon, . , .

0

Source: https://habr.com/ru/post/1790111/


All Articles