Hello All,
There is always a requirement when the client wants to download a PDF for the smartform on a single click and have it autodownloaded.
To achieve the same the below steps can be followed.
1)on click of a button save the PDF to K2 using save as PDF OOB control.
2)obtain the base 64 string for the PDF
3)set a datafield with an expression on runtime
The expression holds the script for the PDF download
<script type="text/javascript">$(document).ready(function () { var base64PDF =' Data Label Raw Data '; var objbuilder = ''; objbuilder += ('<object width="100%" height="100%" data="data:application/pdf;base64,'); objbuilder += (base64PDF); objbuilder += ('" type="application/pdf" class="internal">'); objbuilder += ('<embed src="data:application/pdf;base64,'); objbuilder += (base64PDF); objbuilder += ('" type="application/pdf" />'); objbuilder += ('</object>'); var win = window.open("", "_blank", "titlebar=yes"); win.document.title = "Print"; win.document.write('<html><body>'); win.document.write(objbuilder); win.document.write('</body></html>'); layer = jQuery(win.document); });</script>
The script work well for all browsers, except IE.
In case of IE, the user would be displayed with a custom message and a file attachment download link for the PDF.
Regards
Lubna