More Printer functions please [:)]

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
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 gnozal.

I'd like more printer functions :

Some ideas :

1. Start to print _without_ a PrinterRequester waiting for an user input.
If PrintBegin(PrinterName$) ; if PrinterName$ = "" then default printer
... printing stuff
EndIf

2. Get the name of windows default printer
PrinterName$ = GetDefaultPrinter()

3. And of all defined printers
If ExaminePrinters()
While NextPrinter()
PrinterName$ = GetPrinterName()
Wend
EndIf
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 fred.

Ok, thanks for your suggestions !

Fred - AlphaSND
schamu
New User
New User
Posts: 1
Joined: Sat Jul 05, 2003 8:16 pm

Post by schamu »

I´d like to have a function to set the printer to the landscape mode.
Bernard
User
User
Posts: 23
Joined: Sun Apr 27, 2003 4:49 pm
Location: France

Post by Bernard »

It's very difficult to set the printer orientation.

I´d like to have a function to set it.

Many thanks
Bernard
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

Try this:

Code: Select all

; ------------------------------------------------
; Print sideways (Landscape mode)
; Author unknown (Kanati??) - from the German forum 
; ------------------------------------------------


;What to print

Printoutt.s = "Kanati is a nice guy and such a pleasure to talk to."
x.l = Len(Printoutt)

;Standard printer information
STDPrinterName$ = Space(260) 
GetPrivateProfileString_("WINDOWS","DEVICE","", @STDPrintername$, 260, "Win.Ini") 
STDPrintername$ = StringField(STDPrintername$, 1,",") 

PrinterHandle.l = 0 
OpenPrinter_(StdPrintername$,@PrinterHandle.l,0) 
;MessageRequester("",Str(PrinterHandle),0) 

Dim DevIn.DEVMODE(0) 
Dim DevOut.DEVMODE(0)
 
DocumentProperties_(0,Printerhandle,StdPrintername$,DevIn(0),DevOut(0),#DM_OUT_BUFFER|#DM_IN_BUFFER) 
ClosePrinter_(PrinterHandle) 

If DevIn(0)\dmOrientation = 1 
  MessageRequester("Printer Orientation","Landscape Mode",0) 
ElseIf DevIn(0)\dmOrientation = 2 
  MessageRequester("Printer Orientation","Portrait Mode",0) 
EndIf 

DevIn(0)\dmOrientation = 2; Set to Landscape mode and print results 
PrinterDC.l = CreateDC_("WINSPOOL",StdPrintername$,0,DevIn(0)) 

DocInf.DOCINFO 
DocInf\cbSize = SizeOf(DOCINFO) 
DocInf\lpszDocName = @"Mein Dok"
DocInf\lpszOutput = #NULL 

If StartDoc_(PrinterDC,@DocInf) > 0 
    If StartPage_(PrinterDC) > 0
      TextOut_(PrinterDC,60,70,@Printoutt,x)
      EndPage_(PrinterDC) 
      EndDoc_(PrinterDC) 
    EndIf 
EndIf 
Bernard
User
User
Posts: 23
Joined: Sun Apr 27, 2003 4:49 pm
Location: France

Post by Bernard »

I Tried this code but I can't use the standards commands like Locate, Drawtext.

I think we can use API GetPrinter and SetPrinter but I don't find some samples on the forum and I don't know enough the API to use them.

If someone have a sample I will be Happy.
Bernard
Post Reply