tags:

views:

523

answers:

1

Hi,

I'm in the process of converting some VB6 code to c#. The code deals with taking pre-generated prn files and sending these to a printer.

However I'm a little confused as to how to do this using c#, I've looked at PrintDocument but I don't think thats doing what I want to do as I intend to send the PRN file straight to the printer (in some cases I need to modify the data before it gets sent to the printer).

In VB6 we used the following:

intPrinter = FreeFile
Open gstrPrinter For Output As #intPrinter

intFileChn = FreeFile
Open strOverlay For Binary As #intFileChn

Do Until EOF(intFileChn)
    Get #intFileChn, , strDatIn
    Print #intPrinter, strDatIn;
Loop

I'm looking at doing something similar where it either streams a file or loads it first then sends this to the printer.

I know I could possibly go down the route of using xps files using the new printing as part of WPF, but ideally I'd like to keep the input files as they are and just change the VB6 code over to C# which is doing the actual printing.

Thanks for any help :)

Rob

+1  A: 

Hi, It's not that straight forward as in VB 6.0 , the C# way is a bit lengthy , here's the link

http://www.c-sharpcorner.com/UploadFile/johnodonell/PrintingDirectlytothePrinter11222005001207AM/PrintingDirectlytothePrinter.aspx

HTH

Anand
Thanks Anand, I'll give that a go, your right it certainly doesn't look as straight forward as VB6!