Easy way to set printer output to landscape?
Easy way to set printer output to landscape?
Is there a straight forward way to set the printer output to landscape without having to use loads of code to achieve it, just a simple api call or do you have to set up the printer using api calls etc and bypass the PB printer routines.
If not then perhaps it could be added to the command set, maybe a setprinteroutput() to change the rotation.
If not then perhaps it could be added to the command set, maybe a setprinteroutput() to change the rotation.
Easy enough, though it can be a little fiddly at times.
The following code will print two pages to your default printer; the first in portrait and the second in landscape. Ideally this code should be combined with the use of a Windows print dialogue etc. (that's where it gets fiddly!)
The code is based on some from Andreas.
The following code will print two pages to your default printer; the first in portrait and the second in landscape. Ideally this code should be combined with the use of a Windows print dialogue etc. (that's where it gets fiddly!)
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)
Dim DevIn.DEVMODE(0)
Dim DevOut.DEVMODE(0)
DocumentProperties_(0,Printerhandle,StdPrintername$,DevIn(0),DevOut(0),#DM_OUT_BUFFER|#DM_IN_BUFFER)
ClosePrinter_(PrinterHandle)
DevIn(0)\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, DevIn(0)) ;Switch to landscape.
If StartPage_(PrinterDC) > 0
TextOut_(PrinterDC,300,0,"Tally bally ho (landscape!)",27)
EndPage_(PrinterDC)
EndIf
EndDoc_(PrinterDC)
EndIf
I may look like a mule, but I'm not a complete ass.
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re: Easy way to set printer output to landscape?
Nice work,
But how could you apply this code to print a Picture ?
For xample in here
thanks for help
But how could you apply this code to print a Picture ?
For xample in here
Code: Select all
;PB 4.30
#Image=10
;(...) my code
;Loop Event (..)
Case #Imprim
CatchImage(#Image,img)
LargImage = ImageWidth(#Image) : HautImage = ImageHeight(#Image)
If LargImage>HautImage
FormatImage$="landscape"
ResizeImage(#Image,3189,2244,#PB_Image_Smooth)
Else
FormatImage$="portrait"
ResizeImage(#Image,2244,3189,#PB_Image_Smooth)
EndIf
DetectImprim=DefaultPrinter()
If DetectImprim=0
MessageRequester ("Erreur","No Printer !",#MB_ICONEXCLAMATION)
Else
If StartPrinting("LDVM Printer")
If StartDrawing(PrinterOutput())
If FormatImage$="portrait"
DrawImage(ImageID(#Image), 50, 50)
ElseIf FormatImage$="landscape"
; How could i adapt your code in here ?
DrawImage(ImageID(#Image), 50, 50)
EndIf
StopDrawing()
Else
MessageRequester ("Erreur","Error !",#MB_ICONEXCLAMATION)
EndIf
StopPrinting()
EndIf
EndIf
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1
Re: Easy way to set printer output to landscape?
If you are using a PB Print requester then you are pretty much out of luck because there is no way of retrieving the resulting DEVMODE structure in order to determine the user's selections etc.
You're better off using api and then adapting the code given above.
Note though that my code above is flawed. I can post a corrected version if you need, but I haven't time to convert your code to api.
You're better off using api and then adapting the code given above.
Note though that my code above is flawed. I can post a corrected version if you need, but I haven't time to convert your code to api.
I may look like a mule, but I'm not a complete ass.
Re: Easy way to set printer output to landscape?
I absolutly don't want to use a printrequester(), because the software have to work in different places with differents people, so i don't want people get acces to printer parameters.
thanks.
Soon PB in 4.40 and no printer mode to choose landscape or portrait ! it's to bad !!!
When you'll have the time, i'll be very happy to see your new code.I can post a corrected version if you need, but I haven't time to convert your code to api.
thanks.
Soon PB in 4.40 and no printer mode to choose landscape or portrait ! it's to bad !!!
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1
Re: Easy way to set printer output to landscape?
my recommendation would be to use the printer lib
http://www.purebasicpower.de/?PrinterLib
It just makes things easier.
http://www.purebasicpower.de/?PrinterLib
It just makes things easier.
Missed it by that much!!
HK
HK
Re: Easy way to set printer output to landscape?
Agreed, that is a nice lib.
I may look like a mule, but I'm not a complete ass.
Re: Easy way to set printer output to landscape?
Nice lib, i have try it and it's very usefull !
I can now print in both portrait and landscape, i just have some problems to resize "on the fly" with good ratio the pictures.
they have to be print in almost all the paper.
I can now print in both portrait and landscape, i just have some problems to resize "on the fly" with good ratio the pictures.
they have to be print in almost all the paper.
~Ar-S~
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
My Image Hoster for PB users
My webSite (french) with PB apps : LDVMULTIMEDIA
PB - 3.x / 5.7x / 6 - W11 x64 - Ryzen 7 3700x / #Rpi4
Code: Select all
r3p347 : 7ry : un71l d0n3 = 1