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: Printing pdf files on local printer.  (Read 26488 times)
Snorri B.
Posts: 104


« on: March 10, 2014, 06:36:39 pm »

Hi.

We generate PDF from our Genero app. I would like to implement an action so users can print the pdf file to the default local (windows) printer (through GDC). If I go to file manager in windows, find a PDF file, right-click -> Print it will silently print the pdf file on my default printer. That is what I am trying to emulate.

The first part is easy (transfering the file to the client) but the second part is not (printing the file).
The command line "print" (example C:>print mydfile.pdf) command does not work, so what I really need to do is running
"acrord32.exe /t myfile.pdf"

However, I don't know where the acrobat reader is installed on the client so running for example:
call ui.interface.frontCall("standard","execute",["acrord32.exe /t C:\\Users\\Snorri\\Downloads\\prentarar.pdf",1],[ret])
does not work.

call ui.interface.frontCall("standard","shellexec",["C:\\Users\\Snorri\\Downloads\\prentarar.pdf",""],[ret])
opens the pdf file however happily in Acrobat reader. Is it somehow possible to pass an argument to the associated program via shellexec? Any other obvious way to achieve what I'm trying to do?

Thanks in advance,
-Snorri

Snorri B.
Posts: 104


« Reply #1 on: March 10, 2014, 06:50:45 pm »

I actually succeeded (the documentation is not very clear):

call ui.interface.frontCall("standard","shellexec",["C:\\Users\\Snorri\\Downloads\\prentarar.pdf","print"],[ret])

Daniele A.
Posts: 28


« Reply #2 on: March 11, 2014, 08:36:44 am »

hi,
and if i need to print to printer other that default ?

bye
Daniele
Snorri B.
Posts: 104


« Reply #3 on: March 11, 2014, 10:20:26 am »

Hi Daniele.

You could open the file in acrobat as I describe, an then the user can press CTRL-P to open the print dialog.

Best regards,
-S
Lionel F.
Four Js
Posts: 83


« Reply #4 on: March 11, 2014, 10:50:39 am »

Quote
I actually succeeded (the documentation is not very clear):

call ui.interface.frontCall("standard","shellexec",["C:\\Users\\Snorri\\Downloads\\prentarar.pdf","print"],[ret])


Hi Snorri,

Well done! :)

As mentioned by the documentation, the second parameter is optional, available on Windows only, and really depends on the way the file type has been registered in Windows registry (https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_FrontEndFunctions_004.html).
That's mainly why there is no more precision about this: it may really depend on the workstation whereon you're running your program.

Regards,
Lionel
Reuben B.
Four Js
Posts: 1126


« Reply #5 on: March 11, 2014, 11:48:12 am »

Snorri,

You may enjoy some of this old discussion https://4js.com/fjs_forum/index.php?topic=140.new;topicseen#new&key=7a6687458834new

Danielle,

How have you generated the PDF?  If you have a PDF because you used something like ascii2pdf and it is sitting on the front-end, then you have the options available to you via shellexec or execute frontcalls.

If you are using GeneroReport Writer, you have the fgl_report_svg* series of functions to send a report straight to a local printer https://4js.com/online_documentation/fjs-gst-manual-html/#c_grw_fgl_report_configureSVGPreview.html#c_grw_fgl_report_configureSVGPreview

If you have an old-style report, you have the options available to you via DBPRINT https://4js.com/online_documentation/fjs-fgl-manual-html/index.html#c_fgl_EnvVariables_DBPRINT.html.  That also uses the settings on the GDC monitor report tab https://4js.com/online_documentation/fjs-gdc-manual-html/#c_gdc_Starting_report_config_panel.html

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Daniele A.
Posts: 28


« Reply #6 on: March 11, 2014, 12:02:46 pm »

hi Reuben,
i have a pdf on server side, and i'd like to send it to a  specific local printer (client side)
using call ui.interface.frontCall("standard","shellexec",["c:\path\.....pdffile.pdf","print","EPSON-C70"],[ret])

thanks
bye
Snorri B.
Posts: 104


« Reply #7 on: March 11, 2014, 03:03:20 pm »

Thanks Lionel and Reuben.

Another issue:
Would it be possibe (through frontcall) to get a list of printers the client has access to?

Best regs,
-Snorri
Lionel F.
Four Js
Posts: 83


« Reply #8 on: March 11, 2014, 05:14:37 pm »

Hi again,

I'm afraid we don't have any "out of the box" solution on the frontcall list.
You may have a look at the Java interface (https://4js.com/online_documentation/fjs-fgl-manual-html/?path=fjs-fgl-manual#c_fgl_JavaBridge_002.html), perhaps there are some functions allowing this  (see for instance: http://stackoverflow.com/questions/15274328/how-to-get-the-list-of-printers-in-java).

Best regards,
Lionel
Reuben B.
Four Js
Posts: 1126


« Reply #9 on: March 13, 2014, 04:37:33 am »

...

If you have an old-style report, you have the options available to you via DBPRINT https://4js.com/online_documentation/fjs-fgl-manual-html/index.html#c_fgl_EnvVariables_DBPRINT.html.  That also uses the settings on the GDC monitor report tab https://4js.com/online_documentation/fjs-gdc-manual-html/#c_gdc_Starting_report_config_panel.html

Reuben

... just for completeness and to expand on this portion of my previous answer, there is also these FrontCalls to override the settings in the GDC monitor report tab https://4js.com/online_documentation/fjs-gdc-manual-html/#c_gdc_NewFeatures230_report_to_printer_settings.html

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


« Reply #10 on: March 13, 2014, 04:48:17 am »

Thanks Lionel and Reuben.

Another issue:
Would it be possibe (through frontcall) to get a list of printers the client has access to?

Best regs,
-Snorri

Short answer = Yes

Long answer ...

In another thread, Lionel commented to think of the execute frontcall as being what you can do via Start, think of shellexec as what you can do via double-click in Explorer.  So if you can write a vbscript (it doesn't have to be vbscript), then you can FGL_PUTFILE() from your server to  the GDC, shellexec to execute that file so it produces a list of printers, and then FGL_GETFILE() to return the output file containing your list of printers back to you.

However what the original designers probably envisioned you doing, is writing a function inside your own DLL/Shared Object/Dynamic Library that you can then execute via the FrontCall structure https://4js.com/online_documentation/fjs-gdc-manual-html/#c_gdc_FEextensions.html.  Its one of those things that is probably easier once you have done one or two.  The equivalent on the GWC is creating some javascript functions that you can execute also via FrontCall

Reuben

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


« Reply #11 on: March 13, 2014, 05:08:15 am »

hi Reuben,
i have a pdf on server side, and i'd like to send it to a  specific local printer (client side)
using call ui.interface.frontCall("standard","shellexec",["c:\path\.....pdffile.pdf","print","EPSON-C70"],[ret])

thanks
bye

When you shellexec, it is launching the default handler for files of that extension on the front-end device.  For PDF that is probably Adobe Reader (AcroRd32.exe) and that command can be opened with additional arguments http://stackoverflow.com/questions/619158/adobe-reader-command-line-reference, note the last one /t

So you will probably find that executing a command such as AcroRd32.exe /t <filename> <printer>  (having used FGL_PUTFILE to put file on the front-end PC) may get you close.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Daniele A.
Posts: 28


« Reply #12 on: March 14, 2014, 11:43:21 am »

Hi Reuben,
well,  it could be useful for me,
but to discover the path of the AcroRd32.exe ?

Daniele
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines