Hi,
So, My program is almost completed. Its diagnostic tool for measuring pressures in sensors. It calculates everything, what mechanic need.
Now, I have problem with printer. Everytime, I must set orientation of paper. How can I set it from program ? Its really important, urgent.
There is just Printrequester() command, but without any input data. Please help me, Its really annoying. Thank you
http://forum.thegamecreators.com/xt/xt_ ... ?i=1616244
(this is image from darkbasic, I have rewriten it, darkbasic isnt too stable as purebasic, I think, purebasic is good choice to make this program)
Printer question
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
I use the printer LIB from www.purearea.net and init the printer with this string:
So you can set it however you want!
{{EDIT}} DANG SRod beat me! Slow down SRod!!!
Code: Select all
Print_OpenPrinter(whichprn$,"PAPERSIZE="+Str(#DMPAPER_LETTER)+",ORIENTATION="+Str(#DMORIENT_PORTRAIT))
{{EDIT}} DANG SRod beat me! Slow down SRod!!!

Sorry, the link I posted has some old code in it which I subsequently realised had a bug. Use the following instead, though I will warn you that there needs to be more error checking thrown in :
Code: Select all
STDPrinterName$ = Space(260)
GetPrivateProfileString_("WINDOWS","DEVICE","", @STDPrintername$, 260, "Win.Ini")
STDPrintername$ = StringField(STDPrintername$, 1,",")
PrinterHandle.l = 0
OpenPrinter_(StdPrintername$,@PrinterHandle.l,0)
t1 = DocumentProperties_(0,printerHandle, printerName$, 0,0, 0)
*dm.DEVMODE = AllocateMemory(t1)
If *dm
DocumentProperties_(0,printerHandle, StdPrintername$, *dm, 0, #DM_OUT_BUFFER)
ClosePrinter_(PrinterHandle)
*dm\dmOrientation = 2; Landscape.
PrinterDC.l = CreateDC_("WINSPOOL",StdPrintername$,0,0)
DocInf.DOCINFO
DocInf\cbSize = SizeOf(DOCINFO)
DocInf\lpszDocName = @"Portrait to Landcsape"
DocInf\lpszOutput = #Null
If StartDoc_(PrinterDC,@DocInf) > 0
If StartPage_(PrinterDC) > 0
TextOut_(PrinterDC,300,0,"Tally bally ho (portrait!)",26)
EndPage_(PrinterDC)
EndIf
ResetDC_(PrinterDC, *dm) ;Switch to landscape.
If StartPage_(PrinterDC) > 0
TextOut_(PrinterDC,300,0,"Tally bally ho (landscape!)",27)
EndPage_(PrinterDC)
EndIf
EndDoc_(PrinterDC)
EndIf
FreeMemory(*dm)
Else
ClosePrinter_(PrinterHandle)
EndIf
I may look like a mule, but I'm not a complete ass.