Search code examples
c#printingnetwork-printers

How to print a document file to a network printer in c#


I need to send files (txt, docs etc.) over network using printer driver. I'm able to send raw data to server but not files. I had already tried to Ehsan's Method for printing, but the data inside the document doesn't seems to appear in the document. What I need is a method, or cmd line to print a file over network.


Solution

  • First, could you please give me a clue which type of file you want to print if it is a text file. it's quite simple you drag two component from the tool box first the printDocument and a printDialog panel and use this link

    which is a reference for printDocument and then just simply do this for printing your document:

    prindDialog1.document = yourprintDocument;
    

    And everything will go fine.

    But, if you want to print something like pdf files you should use a pdfWriter in order to invoke the adobePdf process and print via that.

    And the other option is using the PrintPage event of printDocument component which will fire on every page and by using the Graphic library you can Draw everything on each page!