Tuesday, February 15, 2011

How to Print Oracle Report To A Network Shared Printer

In this post I will demonstrate how to send Oracle Report print job direct to a network shared printer.(WINDOWS ONLY)

Assuming you are running your application on Oracle Application Server 10g.




WHEN-BUTTON-PRESSED

DECLARE
  pl_id ParamList;
  lv_repid REPORT_OBJECT;
  lv_report VARCHAR2(100);
BEGIN
   pl_id := Get_Parameter_List('tmpdata');
  IF NOT Id_Null(pl_id) THEN
    Destroy_Parameter_List( pl_id );
  END IF;
  pl_id := Create_Parameter_List('tmpdata');
  Add_Parameter(pl_id,'P_1',TEXT_PARAMETER,:STUDENTS.STDCODE);
  Add_Parameter(pl_id, 'PARAMFORM', TEXT_PARAMETER, 'NO');
  lv_repid:=FIND_REPORT_OBJECT('std_ledger');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_FILENAME, 'c:\apps\reports\std_ledger1.rep');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_EXECUTION_MODE, RUNTIME);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_COMM_MODE , SYNCHRONOUS);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESTYPE ,PRINTER);
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESNAME ,'\\192.168.101.69\hpLaserJ');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_DESFORMAT ,'hpl.prt');
  SET_REPORT_OBJECT_PROPERTY(lv_repid, REPORT_SERVER , 'rep_localhost_oracleas');
  lv_report := RUN_REPORT_OBJECT (lv_repid,pl_id);
END;

Note:
In my case I am using HP Laserjet printer. hpl.prt is the name of printer file shipped with oracle and located in your ORACLE_ASHOME/reports/printer directory.

7 comments:

Shop Towel said...

Another great article. I like that you are very honest and direct to the point.

Anonymous said...

I would like to say this is an excellent blog that I have ever come across. Very informative. Please write more so that we can get more details.





Web Design

sms message said...

These days, we often do not find the time to talk to friends or relatives on a regular basis. One of the ways in which we can let them know that we care and remember is to send them text messages.

athletic clothing said...

oracle report is nice stuff

Anonymous said...

how i can get printer name

Kazi Iqbal said...

Your code not execute.

Cindy Dy said...


Your blog is so cute and I love it. Keep it up.Happy blogging. :)

www.gofastek.com