A few more printer commands?
A few more printer commands?
Hey all, I'm considering adding a printing feature to a program of mine, so I've been experimenting with PB's printer library for the first time. It seems to have enough for this project, but I'd love to see the following:
ExaminePrinters()/NextAvailablePrinter() - returns a sort of printer ID ?
SetSelectedPrinter(ID)/GetSelectedPrinter() - to choose one programatically
GetPrinterName(ID) - self explanatory, for example to fill a combobox
GetPrinterDPI() - probably would have to happen after StartDrawing() (I'm aware of the winAPI method, don't know about cross platform)
PrinterPreferences() - Opens a printers specific preferences dialog, perhaps takes an ID, or simply uses the current selected one
DefaultPrinter() - not necessary if say, the default is always the first after Examine()
I know PB currently doesnt use a printer ID system, and its not an urgent request at all, but it'd be nice to see.
ExaminePrinters()/NextAvailablePrinter() - returns a sort of printer ID ?
SetSelectedPrinter(ID)/GetSelectedPrinter() - to choose one programatically
GetPrinterName(ID) - self explanatory, for example to fill a combobox
GetPrinterDPI() - probably would have to happen after StartDrawing() (I'm aware of the winAPI method, don't know about cross platform)
PrinterPreferences() - Opens a printers specific preferences dialog, perhaps takes an ID, or simply uses the current selected one
DefaultPrinter() - not necessary if say, the default is always the first after Examine()
I know PB currently doesnt use a printer ID system, and its not an urgent request at all, but it'd be nice to see.
Last edited by kenmo on Wed Jan 21, 2009 4:02 pm, edited 1 time in total.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
+1
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
To elaborate a little, I'd really like to get/set printer settings via code, rather than always using the OS printer requester.
Pseudocode of what I'm thinking:
Where MyPrintProcedure() uses the page dimensions/DPI to print accordingly.
Also: the current PrintRequester() has fields for page range and number of copies - there's no way to read these in PB correct?
Also also: added PrinterPreferences() to suggestions in first post.
Pseudocode of what I'm thinking:
Code: Select all
While ExaminePrinters()
ID = NextPrinter()
AddGadgetItem(ComboBox, LastPos, PrinterName(ID))
SetGadgetItemData(ComboBox, LastPos, ID)
Wend
While Event
If Event = ComboBoxChange
SetSelectedPrinter(GetGadgetItemData(ComboBox, Selected))
ElseIf Event = PreferencesButton
PrinterPreferences(GetSelectedPrinter())
ElseIf Event = PrintButton
MyPrintProcedure()
Endif
Wend
Also: the current PrintRequester() has fields for page range and number of copies - there's no way to read these in PB correct?
Also also: added PrinterPreferences() to suggestions in first post.
Re: A few more printer commands?
I know this is an old request, but still, I have GOT to +1 it. PB's printing is woefully weak. Heck, PrintRequester gives you a window with options you aren't even allowed to use!!! (Range, Number of Copies...)kenmo wrote:Hey all, I'm considering adding a printing feature to a program of mine, so I've been experimenting with PB's printer library for the first time. It seems to have enough for this project, but I'd love to see the following:
ExaminePrinters()/NextAvailablePrinter() - returns a sort of printer ID ?
SetSelectedPrinter(ID)/GetSelectedPrinter() - to choose one programatically
GetPrinterName(ID) - self explanatory, for example to fill a combobox
GetPrinterDPI() - probably would have to happen after StartDrawing() (I'm aware of the winAPI method, don't know about cross platform)
PrinterPreferences() - Opens a printers specific preferences dialog, perhaps takes an ID, or simply uses the current selected one
DefaultPrinter() - not necessary if say, the default is always the first after Examine()
I know PB currently doesnt use a printer ID system, and its not an urgent request at all, but it'd be nice to see.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: A few more printer commands?
Well, I'm sure the Printer commands desperately need to be expanded for devs on Linux/Mac. On Windows, there is the truly excellent Printer_Lib http://www.purebasicpower.de/?PrinterLib, which PB should aspire to for all platforms.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: A few more printer commands?
Agreed, the printerlib is rather weak when compared to many of PB's other libraries.
I'm sure it will be revamped some day.
I'm sure it will be revamped some day.
I may look like a mule, but I'm not a complete ass.
Re: A few more printer commands?
Primary reason for request -->>
IdeasVacuum wrote:the Printer commands desperately need to be expanded for devs on Linux/Mac
-
- Enthusiast
- Posts: 542
- Joined: Tue Apr 24, 2012 5:08 pm
- Location: Ontario, Canada
Re: A few more printer commands?
I agree --- the printer library needs to be improved. This is especially important for those who wish to use only the cross-platform features of PB.
We are a Ubuntu shop, but we still have many Windows apps running under Wine. Our reason for choosing PB is to be able to provide true cross-platform applications to our Linux and Windows customers, without having to maintain code that contains OS specific features. Been there, done that - and it's a mess when millions of lines of code are involved.
Briefly, here's how our current Windows applications use printers:
1) Documents are not printed directly to the printers, but are written in coded form to a print queue.
2) When a suitable printer becomes available, the document is formatted and printed.
3) Printers are selected based on the type and size of paper they contain: plain paper, labels, cheques, etc.
4) The printer control program auto-detects all available local and network printers, but the paper types are entered manually to reflect what is actually loaded in the printer.
5) Users never have to manually select a printer or paper orientation, etc.
Something close to this can be achieved using the current printer library, but all the printer characteristics must be set up manually in a reference file. Also, the user has to be sure to select the correct printer, otherwise garbage is printed.
The following functions would allow our program to enumerate the printers and select them as required:
PrinterCount = GetPrinterCount()
PrinterName = GetPrinterName(PrinterNumber)
PrinterName = GetDefaultPrinterName()
Return = SetDefaultPrinter(PrinterName)
Return = OpenPrinter(PrinterName) ------- used in place of PrintRequester()
Return = ClosePrinter() ------- might not be necessary
Printers do not all have the same dot-pitch, margins, etc. So this makes life very difficult when formatting a document, particularly one that must be printed on a pre-printed form.
The following functions, used once a printer has been opened, would allow a document to be formatted correctly:
MarginSize = GetPrinterMargin( {#left | #right | #top | #bottom} )
DotPitch = GetPrinterResolution()
Orientation = GetPrinterOrientation()
Return = SetPrinterOrientation( {#portrait | #landscape} )
These additional functions, used in conjunction with the current printer functions, would greatly enhance the printer library. Other printer options might also be included, such as print quality or number of copies, but the above list is what we would find most useful.
Thanks
Rod
We are a Ubuntu shop, but we still have many Windows apps running under Wine. Our reason for choosing PB is to be able to provide true cross-platform applications to our Linux and Windows customers, without having to maintain code that contains OS specific features. Been there, done that - and it's a mess when millions of lines of code are involved.
Briefly, here's how our current Windows applications use printers:
1) Documents are not printed directly to the printers, but are written in coded form to a print queue.
2) When a suitable printer becomes available, the document is formatted and printed.
3) Printers are selected based on the type and size of paper they contain: plain paper, labels, cheques, etc.
4) The printer control program auto-detects all available local and network printers, but the paper types are entered manually to reflect what is actually loaded in the printer.
5) Users never have to manually select a printer or paper orientation, etc.
Something close to this can be achieved using the current printer library, but all the printer characteristics must be set up manually in a reference file. Also, the user has to be sure to select the correct printer, otherwise garbage is printed.
The following functions would allow our program to enumerate the printers and select them as required:
PrinterCount = GetPrinterCount()
PrinterName = GetPrinterName(PrinterNumber)
PrinterName = GetDefaultPrinterName()
Return = SetDefaultPrinter(PrinterName)
Return = OpenPrinter(PrinterName) ------- used in place of PrintRequester()
Return = ClosePrinter() ------- might not be necessary
Printers do not all have the same dot-pitch, margins, etc. So this makes life very difficult when formatting a document, particularly one that must be printed on a pre-printed form.
The following functions, used once a printer has been opened, would allow a document to be formatted correctly:
MarginSize = GetPrinterMargin( {#left | #right | #top | #bottom} )
DotPitch = GetPrinterResolution()
Orientation = GetPrinterOrientation()
Return = SetPrinterOrientation( {#portrait | #landscape} )
These additional functions, used in conjunction with the current printer functions, would greatly enhance the printer library. Other printer options might also be included, such as print quality or number of copies, but the above list is what we would find most useful.
Thanks
Rod
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
~ Spike Milligan
Re: A few more printer commands?
Boris... that is the exact reason I, too, chose PB. Unfortunately, I did all of the non-library stuff first (the hard part) and then when I went to add the fluff I found out that we are seriously lacking. There are all of 8 commands in the printer library, and you can't even use the features that are displayed when you use the PrintRequester(). I think I might look for a Qt or GTK (or other similar system) so I can hack together something that works and is not a total loss in the learning curve.BorisTheOld wrote:... Our reason for choosing PB is to be able to provide true cross-platform applications to our Linux and Windows customers, without having to maintain code that contains OS specific features. Been there, done that - and it's a mess when millions of lines of code are involved.
...
Unless Fred chimes in and gives us an ETA on useable cross-platform printing tools, I would recommend you look elsewhere for a system that has printer support (since you are just starting out with PB).
-
- Enthusiast
- Posts: 542
- Joined: Tue Apr 24, 2012 5:08 pm
- Location: Ontario, Canada
Re: A few more printer commands?
We've actually been using PB for 2 years, and I've mandated that we use it for all our systems. Of all the BASIC-based languages it's the best one for cross-platform applications. PB's benefits outweigh any shortcomings in its printer support.Tenaja wrote: Unless Fred chimes in and gives us an ETA on useable cross-platform printing tools, I would recommend you look elsewhere for a system that has printer support (since you are just starting out with PB).
For now, Windows versions of our apps are using our Printer DLL, and the Linux versions are using a library that contains hard coded printer characteristics. This is only a small part of the code that relates to document creation and printing, so it's not a major issue.
However, should some more printer functionality become available, we'll certainly make use of it.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
~ Spike Milligan
Re: A few more printer commands?
Would be finesrod wrote:Agreed, the printerlib is rather weak when compared to many of PB's other libraries.
I'm sure it will be revamped some day.

Re: A few more printer commands?
Meanwhile I am playing around with the printer commands for some weeks and have collected some personal wishes for improve the printing experience 
Generic functions:
- Get/Set paper orientation
- Get paper size (allows to calc the dpi)
- Get/Set paper border
2D Drawing functions:
- FatLineXY
- FillPolygon
I would ask for 2D functions, because the output on high resolution printers won't allow to recognize lines thin like a hair. My selfmade Line and Fill functions need a lot of memory in the printer spooler and execution time, and when using printer driver for creating PDF files, the resulting files are really huge...

Generic functions:
- Get/Set paper orientation
- Get paper size (allows to calc the dpi)
- Get/Set paper border
2D Drawing functions:
- FatLineXY
- FillPolygon
I would ask for 2D functions, because the output on high resolution printers won't allow to recognize lines thin like a hair. My selfmade Line and Fill functions need a lot of memory in the printer spooler and execution time, and when using printer driver for creating PDF files, the resulting files are really huge...