it's not printing

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

Hello i wrote the following code which should print on a GDI-Printer
(Lexmark Z11), but the only thing i got is an empty sheet. When i
use this code without the new Printer-Functions (PrintRequester(), StartPrinting(), etc.) i can print on an non-GDI-Printer like EPSON. Who can help me ?

print_data:
PrintRequester() ;print requester gestartet
If CreateFile(1,"LPT1:")
For tmp=idxstart To idxend
WriteStringN ("")
WriteStringN (" ------------------------------------------------------")
;WriteStringN (" "+dateiart$)
WriteStringN (" Dateiname : "+GetFilePart(file$) + " - " + dateiart$)
WriteStringN (" ------------------------------------------------------")
WriteStringN (" GesamtBetrag: " + Right(line2$,15))
WriteStringN ("")
WriteStringN (" Auftraggeber BLZ : " + AuftraggeberBLZ$)
WriteStringN (" Auftraggeber Konto Nr.: " + AuftraggeberKontoNr$)
WriteStringN (" Auftraggeber Name : " + AuftraggeberName$)
WriteStringN ("")
WriteStringN (" Empfaenger : "+info(tmp)\emp)
WriteStringN (" Empf.-Bankleitzahl : "+info(tmp)\bank)
WriteStringN (" Empf.-Bank : "+info(tmp)\bankverb)
WriteStringN (" Empf.-Konto : "+info(tmp)\konto)
WriteStringN ("")
WriteStringN (" Betrag : "+info(tmp)\betrag)
WriteStringN ("")
WriteString (" Verwendungszweck : ")
For row=1 To info(tmp)\stringcount
If row=1:sp$="":Else:sp$=Space(34):EndIf
WriteStringN(sp$+stringdat(tmp,row) )
Next
WriteStringN ("")
WriteString (Chr(12))
Next
StartPrinting("LPT1:") ; Ausdruck starten
MessageRequester("Done","Daten wurden an Drucker geschickt ! ",#MB_ICONINFORMATION)
Else
MessageRequester("Error","Konnte Daten nicht an Drucker schicken ...",#MB_ICONERROR)
CloseFile(1)
EndIf
StopPrinting() ; Ausdruck stoppen
Return
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

You might want to look over the docs again to see what you are allowed to use with the StartDrawing() command. (LPT1 is not one of them)

Printer.pb in the PureBasic\Examples\Sources folder shows you exactly how to use these new printer commands.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

even with StartPrinting("C:\TEST.TXT") it won't work.
Maybe the position of the PRINTING Functions in the
code is wrong.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Ralf, look at the Printer.pb example
You are doing it completely wrong.
Your code would have to be something like this:

Code: Select all

xpos=100
ypos=100
If PrintRequester()
  If StartPrinting("Ralfs Print Job")
    If StartDrawing(PrinterOutput())
      For tmp=idxstart to idxend
        Locate(xpos,ypos):DrawText("Line1"):ypos+50
        Locate(xpos,ypos):DrawText("Line2"):ypos+50
        .
        .other stuff to print
        .
        NewPrinterPage()
      Next
      StopDrawing()
    Endif
    StopPrinting()
  Endif
Endif

Edited by - paul on 10 April 2002 16:58:35
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

thanks a lot it works, only the load font function
is not working.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Code: Select all

Lucida16  = LoadFont(0,"Lucida Console",16)
CourierNew30 = LoadFont(1,"Courier New",30)


  OpenWindow(0,10,10,400,400,0,"")

    StartDrawing(WindowOutput()):DrawingMode(1)

      DrawingFont(Lucida16)
      DrawText("Hello ")

      DrawingFont(CourierNew30)
      DrawText("PureBasic")

    StopDrawing()

  Delay(4000)
Does this work, when you translate it to use
the PrinterOutput() instead ??

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Ralf.

I have to try that tonight.
But in the meantime it work's like the following code snippet.
I would be great if the FontRequester would work (does it ?) so
that i can choose the Fonts from windows like i can choose now
the printer which is great.

If PrintRequester()
printerwidth=PrinterPageWidth()
printerheight=PrinterPageHeight()
px.f=printerwidth/#pagex
py.f=printerheight/#pagey
row=20
If StartPrinting("Einzel-Beleg-Druck")
If StartDrawing(PrinterOutput())
; FontRequester (" ",0,0) ;it tried this
; FontRequester ("Arial",50,0) ;and i tried that
DrawingFont(LoadFont(0, "Arial",50 ))
UseFont(0)
...
CLoseFont(0)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

I have mentioned the font thing to Fred, there seems to be a bug in it.

I can load an ARIAL font and it prints fine to an InkJet or BubbleJet printer but if I print to a Laser printer, it does not print the selected font (it chooses Times instead)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
I can load an ARIAL font and it prints fine to an InkJet or BubbleJet printer but if I print to a Laser printer, it does not print the selected font (it chooses Times instead)
Perhaps it's due to your printer settings? I was playing around with a postscript printer driver yesterday and there are settings for the font substitutions (by table, none, use printer fonts only). Unless of course all PB printing output is supposed to be graphics, in which case, ignore me :)

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Post Reply