Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Get a list of available Printers on client like printerinfo  (Read 14678 times)
ORGA-SOFT B.
Posts: 34


« on: June 16, 2017, 07:46:34 am »

Hello,

we are looking for a function that lists the local installed printers. so that we can show the printers in a genero Programm.

Is there any function in the genero BDL  or have anybody a suggestion to do this.

Thanks for your answers.
Alex G.
Four Js
Posts: 155


« Reply #1 on: June 16, 2017, 08:56:11 am »

Hi,
there is a printerinfo utility in the GDC bin directory that works similar to the, identically named, server side script. The printers listed by this utility can be used for client side direct printing via GDC/GRV. Client side direct printing to a named printer is invoked by selecting SVG output (fgl_report_selectDevice("SVG")), calling the function fgl_report_configureSVGPreview("PrintOnNamedPrinter") to configure named printing and finally by specifying the printer name in a call to fgl_report_setSVGPrinterName(printerName) where the printer names has to be one obtained by the mentioned utility $GDCDIR/bin/printerinfo.
The main documentation for this can be found here http://4js.com/online_documentation/fjs-gst-manual-html/#c_grw_outputoptions_004.html.
Please note that there is a bug in the documentation that falsely states "$GREDIR/bin" instead of "$GDCDIR/bin" as the location to the script. Sorry if you have been misled by this. It has been fixed in the latest documentation.

Kind regards,

Alex 
ORGA-SOFT B.
Posts: 34


« Reply #2 on: June 16, 2017, 12:36:52 pm »

Hello Alex,

thanks for your answer. That's exact what we want todo. And the printing works fine with the fgl_report_setSVGPrinterName function.
But we need the list of the printers so that the user can define a standard printer for each report that he can print.
So wee need to read the printers from the client and show it as a option in our print dialog.



Alex G.
Four Js
Posts: 155


« Reply #3 on: June 16, 2017, 02:19:04 pm »

Hi,

very good, so is invoking $GDCDIR/bin/printerinfo a workable solution for you? You could perhaps retrieve the output of the executable using a front call.

May I ask why you need the list of printers in the 4GL? I am guessing that you will then prompt the user with a 4GL dialog containing the list of choices based on that list. Should that be the case, why don't you use the option fgl_report_configureSVGPreview("ShowPrintDialog") which prompts the user for the printer showing the standard print dialog? That way the 4GL application would never have to know the local printer names.

Kind regards,

A. Geller
ORGA-SOFT B.
Posts: 34


« Reply #4 on: June 16, 2017, 05:22:28 pm »

Hello Alex,

invoking the printerinfo isn't a good solution. Because the printerinfo get a lot of information about the printers that i didn't want to know and retrieving all the
Informations of the printers is very slow.

The Business case for showing up the printers in 4gl is that a user can make a different printer to a default printer in genero.
so first time the user starts a report. The application ask which printer of the listed items do you want as default.
The user chooses the printer and we will save it in the database. So next time the user prints this report we know the printer that he prefer and we use the printonnamedprinter function and everything is fine.

The Next report the same thing ...

Reuben B.
Four Js
Posts: 1119


« Reply #5 on: June 18, 2017, 09:57:41 am »

Quote
invoking the printerinfo isn't a good solution. Because the printerinfo get a lot of information about the printers that i didn't want to know and retrieving all the
Informations of the printers is very slow.

IMHO the printerinfo solution as suggested by Alex is the correct one.  Whilst you could choose another command e.g. wmic printer list full brief https://superuser.com/questions/135393/list-printers-from-command-line-to-text-file, the "correct" tool to be used would be the one being used by the end tool, in this case Genero Report Writer.

Now I am intrigued my your commend about it being slow and having more information than needed.  You didn't say how slow.  (I would also make sure you are running printerinfo on client PC via front-call and not printerinfo on server) I would agree that the format of the output doesn't exactly make it easy for subsequent parsing and interpretation.  So perhaps question for Alex should be is it possible to output printerinfo in alternative formats e.g. JSON, XML, that would make parsing a lot simpler, or to have additional command line options that only outputs printer name and not all the properties.  It maybe that you actually need to read through the output to ensure you are showing valid printers.  e.g. if it is a report for A4 paper you should only show the printers that can printer A4 paper etc.  So whilst you may think you don't need to read and interpret all the output, you may need to.

Reuben



Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
ORGA-SOFT B.
Posts: 34


« Reply #6 on: June 19, 2017, 07:22:12 am »

Good Morning Reuben,

i checked the printerinfo utility again.

On my Client are 11 printers installed.
Some are distributed over a active directory domain and some are local printers like a pdf printer.
The printerinfo works well and fast for some printers and other printers it is not so fast to read the papersources.
In my case some this was a couple of HP Laserjets with the HP universal Printerdriver. Printerinfo took 1-2 seconds to read each papersource the printer can provide.
So in this case printerinfo tooks about 45 - 60 seconds to finish.

If Alex can modify the printerinfo utility in the way that it only the printernames are showen in the output and the output comes as an xml that would be a christmas present.

So let us find a pretty good solution.
Thanks for your help and time
Reuben B.
Four Js
Posts: 1119


« Reply #7 on: June 20, 2017, 12:28:07 am »

Hi,

IMHO printerinfo should not take 45-60 seconds to run.  You should raise that as a support case and get the support team to help investigate.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines