Friday, May 5, 2017

Read Image / Picture in Oracle Reports from File System

As salamualikum (islamic greetings), brothers and sisters. :)
Hope you are well with the grace of Almighty Allah (swt).

Today, i discuss an important issue, many of oracle developer spend hours and hours to make a reports to show image from file system, which is much complex.

From Now on, it will be easy and remain easy. :)

Follow the bellow steps.


  1. Take a Formula column
  2. Data Type Char
  3. Length 500
  4. Set READ FROM FILE property to YES
  5. Set File Format to Image
  6. Make the Image stored folder as Shared Folder
Example Code::

function CF_IMAGEFormula return Char is
  
  filename VARCHAR2(200);
  tiff_image_dir VARCHAR2(80) :='/emp_picture/'; --// Folder name should be shared for shared link.
    out_file Text_IO.File_Type;
BEGIN

out_file :=Text_IO.Fopen(tiff_image_dir||:EMP_CODE||'.jpg', 'r'); -- r is read only AND EMP_CODE is the name of image.

filename := tiff_image_dir||:EMP_CODE||'.jpg';
return filename;

exception
when no_data_found then
RETURN tiff_image_dir||'blank.jpg';

when others then
if sqlcode=-302000 then
RETURN tiff_image_dir||'blank.jpg';
end if; 

end;





How to Read Image File at Oracle Forms 10g ?

I heard and answered lot's of question. How i read image file from file system to Database in oracle forms 10g ?
Here is the solution.
First of all you have to configure webutil correctly. You need to configure formsweb.cfg, webutil.cfg
Attach the webutil.pll library at your forms. Make object group and subclass of webutil.pll
Now add a puss button to your form and write the following code at When-Button-Pressed trigger
--------------------------------------------
declare
vfilename varchar2(300);
begin
vfilename := client_get_file_name(file_filter => 'jpg(*.jpg,*.gif)|*.*');
if vfilename is not null then
client_image.read_image_file(vfilename,substr( vfilename,instr( vfilename, -1)),'COMPANY_INFO_MST.CIM_LOGO');
client_image.write_image_file(vfilename,'','COMPANY_INFO_MST.CIM_LOGO');
end if;
 
end;
-----------------------------------
set the following property of the image item.
image format: TIFF
sizing style: Adjust
 

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...