Page 1 of 1

Printer settings questions

Posted: Fri Mar 06, 2015 8:56 pm
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


Re: Printer settings questions

Posted: Sat Mar 07, 2015 2:11 pm
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

Re: Printer settings questions

Posted: Sun Mar 08, 2015 9:19 am
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 .

Re: Printer settings questions

Posted: Fri Mar 13, 2015 10:49 am
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))