hab in Folge eines kleinen Projekts ein Include-File erstellt, mit welchem Rohdaten an den Drucker gesendet werden können. Drucker, die PostScript unterstützen, können so auch .ps-Dateien drucken.
Weiß nicht, vielleicht ist ja für jemanden hilfreich.
P.S.: RAW-Dateien sind Druckausgaben, die mit der Option "In Datei umleiten" erstellt werden. Standardmäßig haben diese Dateien die Extension prn.
Code: Alles auswählen
; Sending data directly to a printer (printing raw data).
; This code is a port of the following MSDN sample:
; http://msdn2.microsoft.com/en-us/library/ms535786(d=printer).aspx
;
; Author: A.R.
; Compiler: PureBasic 4.02
EnableExplicit
; PrinterName$ Name of the registered printer.
; DocName$ This name will be used for printer job description.
; *rawdata Pointer to a memory block containing the data to send.
; size.l The size of the memory block. Perhaps could be replaced by MemorySize(...).
; *written.l Amount of bytes written to the printer. Check this to see if all data was sent.
Procedure.l RawDataToPrinter(PrinterName$, DocName$, *rawdata, size.l, *written.l)
Protected hPrinter.l, DocInfo.DOC_INFO_1, Job.l
Protected DataType$ = "RAW"
; Need a handle to the printer.
If Not OpenPrinter_(PrinterName$, @hPrinter, #Null)
ProcedureReturn GetLastError_()
EndIf
; Fill in the structure with info about this "document".
DocInfo\pDocName = @DocName$
DocInfo\pOutputFile = #Null
DocInfo\pDataType = @DataType$
; Inform the spooler the document is beginning.
Job = StartDocPrinter_(hPrinter, 1, @DocInfo)
If Not Job
ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
; Start a page.
If Not StartPagePrinter_(hPrinter)
EndDocPrinter_(hPrinter)
ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
; Send the data to the printer.
If Not WritePrinter_(hPrinter, *rawdata, size, *written)
EndPagePrinter_(hPrinter)
EndDocPrinter_(hPrinter)
ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
; End the page.
If Not EndPagePrinter_(hPrinter)
EndDocPrinter_(hPrinter)
ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
; Inform the spooler that the document is ending.
If Not EndDocPrinter_(hPrinter)
ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
; Tidy up the printer handle.
If Not ClosePrinter_(hPrinter)
ProcedureReturn GetLastError_()
EndIf
ProcedureReturn #ERROR_SUCCESS
EndProcedure
;- for testing purpose
Define *rawdata, size.l, written.l
ReadFile(0, "c:\test.prn")
size = Lof(0)
*rawdata = AllocateMemory(size)
ReadData(0, *rawdata, size)
CloseFile(0)
If RawDataToPrinter("Brother HL-1030 series", "myDocument", *rawdata, size, @written) <> #ERROR_SUCCESS
MessageRequester("", "Error!", #MB_OK | #MB_ICONSTOP)
Else
MessageRequester("", "OK!", #MB_OK | #MB_ICONINFORMATION)
EndIf
FreeMemory(*rawdata)
End