; German forum: http://www.purebasic.fr/german/viewtopic.php?t=1153&highlight= ; Author: Hroudtwolf (updated for PB 4.00 by Andre) ; Date: 08. December 2004 ; OS: Windows ; Demo: No ; Problem: ... nun es druckt nicht :-( ; ++++++ ; RawDataToPrinter - sends binary Data directly To a printer ; ********************************************************** ; Sending Data Directly to a Printer ; It is sometimes necessary to bypass the driver and send printer-specific ; data directly to a printer. The following code shows how this can be done ; for both local and networked printers. This method can be used to replace ; the PASSTHROUGH escape and SpoolFile methods. ; Portiert von C nach Purebasic aus der MSDN von Falko ; ; ; szPrinterName: NULL-terminated string specifying printer name ; lpData: Pointer To raw Data bytes ; dwCount Length of lpData in bytes ; ; Returns: TRUE For success, FALSE For failure. ; Procedure.b RawDataToPrinter(szPrinterName.s,lpData.l,dwCount.l) hPrinter.l DocInfo.DOC_INFO_1 dwJob.l dwBytesWritten.l ; Need a handle To the printer. If OpenPrinter_( szPrinterName, @hPrinter, #Null)=0 ProcedureReturn #False EndIf RAW.s="RAW" MyDocument.s="My Document" ; Fill in the Structure with info about this "document." DocInfo\pDocName = @MyDocument DocInfo\pOutputFile = 0 DocInfo\pDatatype = @RAW ; Inform the spooler the document is beginning. dwJob=StartDocPrinter_(hPrinter, 1, @DocInfo) If dwJob=0 ClosePrinter_(hPrinter) Result=#False EndIf ; Start a page. If StartPagePrinter_( hPrinter ) = 0 EndDocPrinter_(hPrinter); ClosePrinter_(hPrinter); Result=#False EndIf ; Send the Data To the printer. If WritePrinter_( hPrinter, lpData, dwCount,@dwBytesWritten)=0 EndPagePrinter_(hPrinter) EndDocPrinter_(hPrinter) ClosePrinter_(hPrinter) Result=#False EndIf ; End the page. If EndPagePrinter_(hPrinter) = 0 EndDocPrinter_(hPrinter) ClosePrinter_(hPrinter) Result=#False EndIf ; Inform the spooler that the document is ending. If EndDocPrinter_(hPrinter) = 0 ClosePrinter_(hPrinter) Result=#False EndIf ; Tidy up the printer handle. ClosePrinter_(hPrinter); ; Check To see If correct number of bytes were written. If dwBytesWritten = dwCount Result=#False EndIf Result=#True ProcedureReturn Result EndProcedure ;Ab Hier Datei angeben, die gedruckt werden soll ; ;Drucker.s="PDF Professionell" Drucker.s="EPSON Stylus COLOR 680" If ReadFile(0,"..\ReadMe.txt") Anz.l=Lof(0) *Mem=AllocateMemory(Anz) laenge.l=ReadData(0, *Mem,Anz) Debug RawDataToPrinter(Drucker, *Mem ,laenge) CloseFile(0) FreeMemory(*Mem) Else Debug "File couldn't be opened." EndIf ; IDE Options = PureBasic v4.02 (Windows - x86) ; Folding = -