Download QR code in pdf by button in portal

Rosy14
Tera Guru

Hi,

I want to download a QR code by button in pdf. The qr code widget is as. Trying to encode in base64. Plz help.

HTML
<div>
  <h3>
    Details of Postage Label:
  </h3>
<!-- your widget template -->
  	<div ng-if="data.show" id="qrcode"></div>
	<br/><canvas id="qrcode" width="5" height="5"></canvas>
  <a target="_new"  href="{{c.data.dataURL}}.do?PDF">
  <button>
    Test
  </button>
  </a> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js">
</script>
</div>
CS:
api.controller=function($scope,$timeout) {
  /* widget controller */
  var c = this;
	//$j('#qrcode').qrcode('hello');
	$scope.$watch('$viewContentLoaded', function() { 
		$timeout(function() {			
			new QRCode(document.getElementById("qrcode"), document.URL);
		}, 2000);    
	});
	var canvas = document.getElementById("qrcode");
	c.data.dataURL = canvas.toDataURL();
	c.img64= function() {
	    c.server.update();
	}
	//c.server.dataURL = canvas.toDataURL();
	//c.data.x="text";
	//alert("Test "+dataURL);
};
JS:
(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	
	data.show = $sp.getParameter('sys_id') == -1 ? false : true;
	
	data.dataURL = input.dataURL;
	gs.addInfoMessage(input.dataURL);
	
})();

 

1 REPLY 1

ben_hollifield
Tera Guru

Hi Rosy14 - I don't have an answer to your direct question. However, Yansa Labs offers a QR/Barcode Generator app that can expose QR Codes in any ServiceNow interface, including Service Portal, and allows downloading of the generated code in PDF. If you're still stuck, this could meet your requirement. The links below may be helpful. Feel free to reach out to me at ben@yansalabs.com with any questions!

 

https://docs.yansalabs.com/barcode-and-qr-code-generator

https://store.servicenow.com/sn_appstore_store.do#!/store/application/eb2b91341bd68490118b8774cc4bcb...