Adsense Ad

Direct Print using Webutil

Procedure Print_Drirectly(In_Server_Name Varchar2,
                          In_Rep_Name    Varchar2,
                          In_Obj_Name    Varchar2) Is
  Lc$rep           Varchar2(100);
  Lc$rep_Status    Varchar2(20);
  Lc$ln$adobe_Path Varchar2(500);
  Ln$process_Id    Webutil_Host.Process_Id;
  Repid            Report_Object;
  Lc$file_Path     Varchar2(1024);
  Printer_Path     Varchar2(2000);
  Lc$temp_Path Constant Varchar2(256) := '\\192.168.1.2\temp\';
  Pl_Id Paramlist;
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, 'v_id ', Text_Parameter, :Vn);
  Lc$file_Path := Lc$temp_Path || In_Rep_Name || To_Char(Sysdate, 'hhmiss') ||'.pdf';  
  Repid := Find_Report_Object(In_Obj_Name);
  Set_Report_Object_Property(Repid, Report_Filename, In_Rep_Name);--'<Directory_Location>\myreport.rdf'
  Set_Report_Object_Property(Repid, Report_Server, 'rep_server');
  Set_Report_Object_Property(Repid, Report_Execution_Mode, Batch);
  Set_Report_Object_Property(Repid, Report_Comm_Mode, Synchronous);
  Set_Report_Object_Property(Repid, Report_Destype, File);
  --File name must be unique otherwise it will override the old file with same name  
  Set_Report_Object_Property(Repid, Report_Desname, Lc$file_Path);
  Set_Report_Object_Property(Repid, Report_Desformat, 'pdf');
  --Add_Parameter(pl_id,'repot paramter', TEXT_PARAMETER, form parameter);
  Lc$rep        := Run_Report_Object(Repid, Pl_Id);
  Lc$rep_Status := Report_Object_Status(Lc$rep);
  While Lc$rep_Status In ('RUNNING', 'OPENING_REPORT', 'ENQUEUED') Loop
    Lc$rep_Status := Report_Object_Status(Lc$rep);
  End Loop;
  If Lc$rep_Status = 'FINISHED' Then
    --IF WEBUTIL_FILE_TRANSFER.IS_AS_READABLE (LC$FILE_PATH)  
    -- THEN  
    -- Try to get the correct instaled version of Adobe Reader program  
    For i In Reverse 5 .. 13 Loop
      Begin
        Lc$ln$adobe_Path := Client_Win_Api_Environment.
                            Read_Registry('HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\' || i ||
                                          '.0\Installer',
                                          'Path',
                                          True);
      Exception
        When No_Data_Found Then
          --If path not exists in Registery, it will raise NO_DATA_FOUND EXCEPTION  
          Null;
        When Others Then
          Message('others');
      End;
      If Lc$ln$adobe_Path Is Not Null Then
        Exit;
      End If;
    End Loop;
  
    Begin
      Ln$process_Id := Webutil_Host.
                       Nonblocking('cmd.exe /c start AcroRd32.exe' ||
                                   ' /H /P ' || Lc$file_Path);
    Exception
      When Others Then
        Null;
    End;
    --sleep for sometime until printing is finished  
    Dbms_Lock.Sleep(3);
    -- Teminate PDF Reader Program Process  
    If Not Webutil_Host.Id_Null(Ln$process_Id) Then
      Webutil_Host.Terminate_Process(Ln$process_Id);
    End If;
  Else
    Message(Lc$file_Path || ' is unreadable path at application server');
  End If;
End Print_Drirectly;

1 comment:

M. Faramawy said...

Kindly if you can attach an FMB example, I would be very grateful !