Printer settings questions

Just starting out? Need help? Post your questions and find answers here.
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Printer settings questions

Post by VB6_to_PBx »

Printer settings questions :

in Visual Basic 6.0 you can set Printer "Quality"
example
Print Quality

Code: Select all

VB6.0 Constant Value Description 
vbPRPQDraft -1 Draft print quality 
vbPRPQLow -2 Low print quality 
vbPRPQMedium -3 Medium print quality 
vbPRPQHigh -4 High print quality 
can this also be done in PureBasic ??


and one more Question :
in PureBasic ... how to set Printing "Orientation"
like in VB6.0 =>

Code: Select all

VB6.0 Printer Orientation
Constant Value Description 
vbPRORPortrait 1 Documents print with the top at the narrow side of the paper 
vbPRORLandscape 2 Documents print with the top at the wide side of the paper 
* it would be great if PureBasic had all the above readily "built-in" or added into PureBasic Printer code :

PureBasic Printer Command Index

DefaultPrinter
NewPrinterPage
PrintRequester
PrinterOutput
PrinterPageHeight
PrinterPageWidth
StartPrinting
StopPrinting

PrintPortrait
PrintLandscape
PrintDraftQuality
PrintLowQuality
PrintMediumQuality
PrintHighQuality

 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Printer settings questions

Post by IdeasVacuum »

PB's print lib is very basic at the moment, certainly in need of an upgrade (though no doubt being cross-platform makes it difficult to achieve).

If you are working on Windows only, then you have the luxury of using the API.
ABBKlaus (PureBasicPower) has a very comprehensive wrapper:
Printer Lib
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: Printer settings questions

Post by VB6_to_PBx »

hi IdeasVacuum ,

i found this PB Code , i think it was from SROD ?
its nice and short amount of Code !

it will Print Portrait then Landscape

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 hdc, CurrentX, CurrentY, Txt, Len(Txt)
      TextOut_(PrinterDC,300,0,"Tally bally ho (landscape!)",27)
      EndPage_(PrinterDC)
    EndIf
    EndDoc_(PrinterDC)
  EndIf
  FreeMemory(*dm)
Else
  ClosePrinter_(PrinterHandle)
EndIf

here's 1 problem i found out with the above Code :

suppose i have "previously" set Printer to Landscape with another Program
then both Pages will Print out as Landscape (instead of first one at Portrait and second one at Landscape) :(

How can i reset or set Printer to initially Print in Portrait mode
regardless if any other Program or any other part of my Program has let the User Print something in Landscape ??? :?:

or how can i set the Printer back to Portrait mode when User exits my Program ??
.... preferbly without calling or showing the PrintRequester Window's Dialog .
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
Ferdinand
New User
New User
Posts: 9
Joined: Tue Mar 10, 2015 1:43 pm
Location: Netherlands
Contact:

Re: Printer settings questions

Post by Ferdinand »

Maybe the code in this thread could be of use to you ?
http://www.purebasic.fr/english/viewtop ... 3&start=23
(especially Procedure.I ChangePrinterDefaultSettings(PrinterName.S))
Post Reply