HTML Report with Image when Print :
CREATE TABLE "IMAGES"
( "IMAGE_ID" NUMBER(10,0),
"NAME" VARCHAR2(100),
"MOBILE_NUMBER" VARCHAR2(100),
"ADDRESS" VARCHAR2(100),
"IMAGE_DATA" BLOB,
"IMAGE_MIMETYPE" VARCHAR2(2000),
"IMAGE_FILENAME" VARCHAR2(2000),
"IMAGE_LAST_UPDATE" DATE,
"IMAGE_CHARACTERSET" VARCHAR2(2000)
) ;
PLSQL Dynamic Content : -
DECLARE
cursor mycur IS
SELECT IMAGE_ID,NAME,MOBILE_NUMBER,ADDRESS,IMAGE_DATA,IMAGE_MIMETYPE,IMAGE_FILENAME,IMAGE_LAST_UPDATE,
IMAGE_CHARACTERSET FROM IMAGES;
BEGIN
htp.p('<a id="b_exit" type="button1" class="button button3" class="exit" '||'href="'||APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:1:&SESSION.::&DEBUG.::::')||'">Close</a>
<input type="button1" class="button button1" class="t-Icon t-Icon--right fa fa-print" id="print" type="button" onclick="printDiv(''div_print1'') ;" value="Print"/><br/>
');
--- onClick="window.print()"
htp.p('<!DOCTYPE html>
<html>
<head>
<style>
#customers {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#customers td, #customers th {
border: 1px solid #ddd;
padding: 8px;
}
#customers tr:nth-child(even){background-color: #f2f2f2;}
#customers tr:hover {background-color: #ddd;}
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
</style>
<script type = "text/javascript" src="functions.js"></script>
</head>
<div id="div_print1" style="margin-top:5px;">
<body>
<table id="customers">
<tr>
<th>SL NO</th>
<th>EMP ID</th>
<th>NAME</th>
<th>PICTURE</th>
</tr>');
for i in mycur loop
htp.p('
<tr>
<td>'||i.IMAGE_ID||'</td>
<td>'||i.NAME||'</td>
<td>'||i.ADDRESS||'</td>
<td style="width: 25%;">'||'<img src="'||apex_util.get_blob_file_src('P3_IMAGE_DATA',i.IMAGE_ID)||'" style="height: 250px;width: 100%;border-radius: 24px;" />'||'</td>
</tr>');
END LOOP;
htp.p('
</table>
<script>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
//document.getElementById("ftr").style.display = "block";
window.print();
document.body.innerHTML = originalContents;
javascript:apex.submit();
}
</script>
</body>
</div>
</html>
');
END;
Apex Backup :
Tags:
Oracle Apex