Hi Oso,
the following procedure is copied together from my really big library I'm using for different printers and a lot of functions, so I'm not sure if it really works now, but it should put you on the right path:
Code: Select all
Procedure printmemoryblock(prtname.s, docname.s, *printdata, printlen.l)
Protected.l ret
Protected.i hPrinter
Protected.s txtyp
Protected DocInfo.DOC_INFO_1
If OpenPrinter_(prtname, @hPrinter, #Null)
txtyp = "RAW"
DocInfo\pDocName = @docname
DocInfo\pOutputFile = #Null
DocInfo\pDatatype = @txtyp
If StartDocPrinter_(hPrinter, 1, @DocInfo)
If StartPagePrinter_(hPrinter)
WritePrinter_(hPrinter, *printdata, printlen, @ret)
EndPagePrinter_(hPrinter)
Else
Debug "PageError"
EndIf
EndDocPrinter_(hPrinter)
Else
Debug "DocError"
EndIf
ClosePrinter_(hPrinter)
Else
Debug "OpenError"
EndIf
EndProcedure
When you call the procedure the first parameter prtname should be the name of the printer shown in the control panel, the second parameter docname can be any name that you want to give the document, this name will be shown while printing in the print spooler. The memory block *printdata should contain the data that you want to print in the coding that the printer needs (for example Ascii, Utf8 or something else), and printlen is the size of the *printdata memory. If you know the specific codes for your printer, you can also integrate esc sequences in the print data, to switch between bold, underline, italic etc.
First the procedure tries to open the printer with its given name, then it tries to start a new document of the raw type with the given document name, and in this document it tries to start a new page, because the windows print spooler uses documents with pages. If all this has worked, you simply write out the memory block to the printer, close the page, close the document and close the printer.
Attention: This raw print works with a lot of (maybe older) printers, but not with every printer!
Normally the windows print spooler uses a graphical printing, where you have to build something like a big graphic of every page and then send this to the printer, instead of the WritePrinter function, but this would get to long here.
Greets, hoerbie