Page 1 of 1

Printer question

Posted: Wed Dec 17, 2008 4:17 pm
by wh1sp3r
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)

Posted: Wed Dec 17, 2008 4:34 pm
by srod

Posted: Wed Dec 17, 2008 4:36 pm
by Rook Zimbabwe
I use the printer LIB from www.purearea.net and init the printer with this string:

Code: Select all

 Print_OpenPrinter(whichprn$,"PAPERSIZE="+Str(#DMPAPER_LETTER)+",ORIENTATION="+Str(#DMORIENT_PORTRAIT))
   
So you can set it however you want!

{{EDIT}} DANG SRod beat me! Slow down SRod!!! :wink:

Posted: Wed Dec 17, 2008 4:37 pm
by wh1sp3r
Excellent ! Thank you very much :)

Posted: Wed Dec 17, 2008 4:41 pm
by 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

Posted: Wed Dec 17, 2008 4:44 pm
by wh1sp3r
Rook Zimbabwe: Have you tried LINE function in this lib ? It has strange parameters :D Line(x,y, w,h) width, height ? lol ? what about start x,y and end x,y ? :)