Printer question

Just starting out? Need help? Post your questions and find answers here.
wh1sp3r
User
User
Posts: 11
Joined: Mon Apr 17, 2006 9:08 pm

Printer question

Post 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)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
wh1sp3r
User
User
Posts: 11
Joined: Mon Apr 17, 2006 9:08 pm

Post by wh1sp3r »

Excellent ! Thank you very much :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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
I may look like a mule, but I'm not a complete ass.
wh1sp3r
User
User
Posts: 11
Joined: Mon Apr 17, 2006 9:08 pm

Post 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 ? :)
Post Reply