Sending Zen report to printer using $MODE=ps&$PS=

103 views
Skip to first unread message

Avg Bear

unread,
May 7, 2013, 4:26:49 PM5/7/13
to intersys...@googlegroups.com
I have a functioning Zen reporting rendering to a browser as a PDF. I want to send directly to the printer now. The documentation seems very straight forward, but I am not being successful. Does anybody have an example? Thank you for any input you may have.

Jonathan Levinson

unread,
May 7, 2013, 4:37:01 PM5/7/13
to intersys...@googlegroups.com

What version of Cache’ and what platform (Windows 7, RedHat Linux, MAC, VMS,  etc.,)?

--
You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
To post to this group, send email to InterSys...@googlegroups.com
To unsubscribe from this group, send email to InterSystems-Z...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions
---
You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intersystems-z...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Avg Bear

unread,
May 8, 2013, 6:51:54 PM5/8/13
to intersys...@googlegroups.com


On Tuesday, May 7, 2013 2:26:49 PM UTC-6, Avg Bear wrote:
I have a functioning Zen reporting rendering to a browser as a PDF. I want to send directly to the printer now. The documentation seems very straight forward, but I am not being successful. Does anybody have an example? Thank you for any input you may have.

Cache for Windows (x86-64) 2012.2 (Build 638U) Fri Aug 31 2012 15:51:36 EDT

I have this working, but I need to stop a new tab/window from opening with the description of the processing.

var printerName zenPage.getComponentById('PrinterName').getProperty('value')
var url zenLink('.ZENRpts.MyRpt.cls?$MODE=ps&$PS='+printerName)
window.open(url,'View','modal=yes,resizable=yes,toolbar=no,menubar=no,width=800,height=800');

Thank you for your time.

APZ

unread,
May 9, 2013, 11:51:49 AM5/9/13
to intersys...@googlegroups.com
I see you are initiating browser-based generation by visiting the report's URI.
 
You might try calling the generation-methods of the report, instead. See :
 
 
You can record the printer name in class parameter PS, as noted in the documentation, or if the name is determined dynamically, set it in the class property of the same name.
 
 
Regards,
 
Ariela

On Wednesday, May 8, 2013 6:51:54 PM UTC-4, Avg Bear wrote:


On Tuesday, May 7, 2013 2:26:49 PM UTC-6, Avg Bear wrote:
...
 

Jonathan Levinson

unread,
May 9, 2013, 11:57:46 AM5/9/13
to intersys...@googlegroups.com

You write:

 

I have this working, but I need to stop a new tab/window from opening with the description of the processing.

Please send PNG with new tab/window opening.  I’m not sure what you mean.

 

Thanks,

Jonathan

 

From: intersys...@googlegroups.com [mailto:intersys...@googlegroups.com] On Behalf Of Avg Bear


Sent: Wednesday, May 08, 2013 6:52 PM
To: intersys...@googlegroups.com

--

Vlado

unread,
May 9, 2013, 12:28:37 PM5/9/13
to intersys...@googlegroups.com
window.open(url,'View','modal=yes,resizable=yes,toolbar=no,menubar=no,width=800,height=800');

opens new window/tab on the screen. 

He wants to send all the information(the report) directly to the
printer without any changes on the screen. Ariela's link shows how you can do it in terminal mode.
But question here is if you have Zen Page and you hit the button "Print" , for example ,how you can print
Directly to the printer?
**Владо

On Thursday, May 9, 2013 8:57:46 AM UTC-7, Jonathan Levinson wrote:

You write:

 

I have this working, but I need to stop a new tab/window from opening with the description of the processing.

Please send PNG with new tab/window opening.  I’m not sure what you mean.

 

Thanks,

Jonathan

 

From: intersys...@googlegroups.com [mailto:intersys...@googlegroups.com] On Behalf Of Avg Bear
Sent: Wednesday, May 08, 2013 6:52 PM
To: intersys...@googlegroups.com
Subject: [InterSystems-Zen] Re: Sending Zen report to printer using $MODE=ps&$PS=

 



On Tuesday, May 7, 2013 2:26:49 PM UTC-6, Avg Bear wrote:

I have a functioning Zen reporting rendering to a browser as a PDF. I want to send directly to the printer now. The documentation seems very straight forward, but I am not being successful. Does anybody have an example? Thank you for any input you may have.


Cache for Windows (x86-64) 2012.2 (Build 638U) Fri Aug 31 2012 15:51:36 EDT

I have this working, but I need to stop a new tab/window from opening with the description of the processing.

var printerName zenPage.getComponentById('PrinterName').getProperty('value')
var url zenLink('.ZENRpts.MyRpt.cls?$MODE=ps&$PS='+printerName)
window.open(url,
'View','modal=yes,resizable=yes,toolbar=no,menubar=no,width=800,height=800');

Thank you for your time.

--
You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.

To post to this group, send email to InterSy...@googlegroups.com
To unsubscribe from this group, send email to InterSystems-...@googlegroups.com

Jonathan Levinson

unread,
May 9, 2013, 12:31:26 PM5/9/13
to intersys...@googlegroups.com

I haven’t tried it so please take the following thought as a hypothesis rather than a fact.

 

I think what you do is define in your page a class method (maybe an instance method, don’t know) and you invoke this class method using zenPage.classMethodName.  I’m not sure how you specify the arguments but it may be straightforward. 

 

I think the use of zenPage to invoke Cache’ methods is in the ZEN doc but I’m not sure.

 

I don’t have time to try these things right now, but hopefully someone else on this list will find my “hints” helpful.

 

Thanks,

Jonathan

To post to this group, send email to InterSys...@googlegroups.com
To unsubscribe from this group, send email to InterSystems-Z...@googlegroups.com

APZ

unread,
May 9, 2013, 12:41:41 PM5/9/13
to intersys...@googlegroups.com
Good point, Vlado.
 
The same code that one can use in a terminal can be used inside a classmethod of the Zen page. I presume the "Print" button can be configured to call the classmethod, presumably accessed via the special zenPage object in a javascript callback.
 
I must apologize for an error in what I wrote previously. The "PS" property of a ZEN Report is not available in 2012.2, it appears in 2013.1.
The doc which I linked to above includes an example of how to work around this (by setting $PS in the %request special variable), so the approach should still be viable.
 
Ariela

Vlado

unread,
May 9, 2013, 1:00:42 PM5/9/13
to intersys...@googlegroups.com
Yes, but I think in the future it should be made more simple,
how it was in the good past - 
O 0 U 0 W .... prints on the screen
O 3 U 3 W  ... prints on the printer.
What I am trying to say is the code to be the same and we to use
only redirection somehow.
**Владо

Vlado

unread,
May 9, 2013, 1:11:49 PM5/9/13
to intersys...@googlegroups.com
Something like:

Parameter PRINTERMODE = "screen" ;

Parameter PRINTERMODE = "printer" ;

**Владо

Avg Bear

unread,
May 9, 2013, 2:10:20 PM5/9/13
to intersys...@googlegroups.com
Thank you to everyone, very much appreciated. The example in the documentation, with the path to the printer in place of file name works!

APWZ

unread,
May 9, 2013, 2:46:17 PM5/9/13
to intersys...@googlegroups.com
First:  congratulations, Avg Bear. I am pleased to read that you have succeeded.
 
I can't tell if you're doing this, but: I warn you not rely on the file-name argument to set the printer-name. The output file name is not really used by PS/mode-6 (because there is no ultimate output file!). Putting the printer name as the file-name won't hurt anything. Just don't forget to also set the printer-name in $PS.  
 
 
 
 
Vlado, you are talking about using the Spooler I/O device, as described in
yes?
 
I am not an expert at the low-level use of I/O devices, but I don't think that simple redirection to a spooler/printer device is a good approach for reports. The content isn't pure text data. For instance, the output for the screen includes HTML markup, which one wouldn't want to see come out a printer.  Instead, we tell the ZEN Report what its target output mode is, and the report will adjust to ensure the appropriate formatting.
 
 
Essentially, the necessary effort to redirect the output IS as easy as a one-line change, just as you wish for:
     Parameter DEFAULTMODE = "html" ;
to
     Parameter DEFAULTMODE = "ps" ;
 
(or, $MODE=html to $MODE=ps on URI,  or  GenerateReport(file,1) to GenerateReport(file,6),  depending on which technique one is using to generate the report)
Of course, even when USEing the spooler device, it's still necessary to have configured the printer-device's info at some point. 
     OPEN "|PRN|\\business\accounting"
In a ZEN Report this is done by putting the printer name in $PS (or permanently in the Parameter PS )
      $PS=\\business\accounting
 
 
I respect that your opinion on which is simpler may differ from mine.
 
 
regards and thank you for an interesting hypothetical exercise,
 
Ariela
 

Avg Bear

unread,
May 9, 2013, 3:44:22 PM5/9/13
to intersys...@googlegroups.com
This is my working Method:
Method PrintMyZenRpt() [ ZenMethod ]
{
    s tMyId=%page.%GetValueById("tMyId")
    s printerName=^CacheTempUser.BCDATA(tMyId_"-myPrinterName")
    s tRpt=##class(ZENRpts.MyZenRpt).%New()
    s tRptStatus = tRpt.GenerateReport(printerName, 2)
}

Parameter DEFAULTMODE = "pdf"

These Zen Rpts are being created by end users printing to their default printer.
Is it possible to set the PS class parameter in the Zen Rpt(tRpt)
after I instantiate it, but before I invoke the GenerateReport?

Vlado

unread,
May 9, 2013, 5:20:52 PM5/9/13
to intersys...@googlegroups.com
>Essentially, the necessary effort to redirect the output IS as easy as a one-line change, just as you wish for:
>     Parameter DEFAULTMODE = "html" ;
>to
>     Parameter DEFAULTMODE = "ps" ;
 
And 
       Parameter DEFAULTMODE = "pdfprinter" ;

Ariela,

Sorry I didn't read the documentation recently.
I see, it's already have done.
It seems, that I discovered the hot water today again:)
**Владо

APWZ

unread,
May 10, 2013, 12:57:54 PM5/10/13
to intersys...@googlegroups.com
Hi,
No, it is not possible to set the class parameter after instanciating the report. The difference between class PARAMETERS and class PROPERTIES is that the Properties can be set like variables. The Parameters are like constants; you compile them in the class and they don't change.
What you can do is set $PS into the %request special variable (see doc), and the tRpt will pick up the value from there.
Did you say this method is already working, or that you are "working on" it?
Ariela

Avg Bear

unread,
May 13, 2013, 12:03:09 PM5/13/13
to intersys...@googlegroups.com
The code that I included IS working at this time. I am reading up on the %request direction. Thank you for your time.
Reply all
Reply to author
Forward
0 new messages