Print report just ome time |
Some of our reports are very important and you don't want they can be printed more than once.
Therefore we needed a software that can enable us to send the print directly to printer. (If the user can preview, they can save it to file system and print it later.
Now you choose RepExpert . Repexpert can output oracle report to printer directly, Repexpert can also hide the source code of HTML report.
To let the customer
print report with RepExpert, you can append "&callrepexpert=yes"
to the url, please see here
for more information.
There is a solution to solve this problem. Try the following steps.
Example :
Suppose you use the following sample code to get reports .
web.show_document( v_url ,'_blank');
You can change to sample code to :
DECLARE
v_url VARCHAR2(700);
v_encrypted_url VARCHAR2(1000);
BEGIN
-- encrypt the url
v_encrypted_url:=encrypt_url(v_url); --A sample
below. You should change the encryption algorithm .
web.show_document('http://servername:7777/getreports.jsp?filepath='||v_encrypted_url||'&callrepexpert=yes','_blank');
END ;
Just a sample. You should change the encryption algorithm.
FUNCTION encrypt_url(p_url varchar) RETURN varchar IS
v_len number(5);
v_cur number(5);
v_url varchar2(2000):=NULL;
v_chr varchar2(1);
v_num number(3);
v_num_high number(3);
v_num_low number(3);
BEGIN
--TODO : Change the encryption algorithm, you should change the corresponding
decryption algorithm
-- in getreports.jsp
v_len := lengthb(p_url);
v_cur:=1;
loop
exit when v_cur>v_len;
v_chr := substrb(p_url,v_cur,1);
v_num := ascii(v_chr);
if v_num=32 then
v_url:=v_url||'+';
elsif (v_num>=65 and v_num<=90) THEN -- A - Z
v_url:=v_url||v_chr;
elsif (v_num>=97 and v_num<=122) THEN -- a - z
v_url:=v_url||v_chr;
ELSIF (v_num>=48 and v_num<=57) THEN -- 0 - 9
--encrypt the number
-- 0 -> 1
-- 1 -> 6
-- 2 -> 3
-- 3 -> 8
-- 4 -> 5
-- 5 -> 9
-- 6 -> 4
-- 7 -> 0
-- 8 -> 2
-- 9 -> 7
IF v_chr IN ('0','2','4') THEN
v_chr := v_chr+1;
ELSIF v_chr IN ('1','3') THEN
v_chr := v_chr+5;
ELSIF v_chr IN ('6','9') THEN
v_chr := v_chr-2;
ELSIF v_chr = '5' THEN
v_chr := '9' ;
ELSIF v_chr = '7' THEN
v_chr := '0' ;
ELSIF v_chr = '8' THEN
v_chr := '2' ;
END IF ;
v_url:=v_url||v_chr;
else
v_url:=v_url||'%';
v_num_high := floor(v_num/16);
if v_num_high>=10 then
v_chr:=chr(v_num_high+55);
else
v_chr:=chr(v_num_high+48);
end if;
v_url:=v_url||v_chr;
v_num_low:=mod(v_num,16);
if v_num_low>=10 then
v_chr:=chr(v_num_low+55);
else
v_chr:=chr(v_num_low+48);
end if;
v_url:=v_url||v_chr;
end if;
v_cur:=v_cur+1;
end loop;
return v_url;
END;
Example:
The sample code of getreports.jsp :
<%
// Usage: http://server-name:port/getreports.jsp?filepath=[encrypted_url]
// Author: Lion Van
// Email: support@lv2000.com
try{
String userAgent=request.getHeader("User-Agent");
if (userAgent.compareToIgnoreCase("Repexpert")==0) //Request comes
from Repexpert.
{
String filepath=request.getParameter("filepath");
//Decrypt the url
String original_url="";
int ilen=filepath.length();
for (int i=0;i<ilen;i++)
{
char chr=filepath.charAt(i);
if (chr=='1'){chr='0';}
else if (chr=='6'){chr='1';}
else if (chr=='3'){chr='2';}
else if (chr=='8'){chr='3';}
else if (chr=='5'){chr='4';}
else if (chr=='9'){chr='5';}
else if (chr=='4'){chr='6';}
else if (chr=='0'){chr='7';}
else if (chr=='2'){chr='8';}
else if (chr=='7'){chr='9';}
original_url+=chr;
}
// out.println(original_url);
response.sendRedirect(original_url);
}else{
out.println("<p>Hey! you should install RepExpert on your pc</p>");
out.println("If you have installed Repexpert, please contact your network
administrator");
//TODO: Record the event
}
}catch(Exception e){System.out.println(e);}
finally{
}
%>
4) Repexpert use the original link to download report output files.
Please click here to download the example.