renderAsync does not show nothing



  • Hello,
    I built a template in jsreportOnline and it works if I run it from jsReport Studio.

    Then I incapsulated it in my web application so that I can run it from my javascript application.

    here my code that till some days ago worked, but now it does not show nothing in the browser page:

    //return false;
    jsreport.serverUrl = 'https://nimacad.jsreportonline.net/';
    jsreport.headers['Authorization'] = "Basic " + btoa("xxxxxx:yyyyyyyy")
    
    var request = {
    	template: {
    		shortid: 'S16Ay4UzW', recipe: 'phantom-pdf'
    	},
    	data: reportData
    };
    
    //display report in the new tab
    jsreport.renderAsync(request).then(function(res) {
    	console.log(res);
    
    	//open in new window
    	window.open(res.toDataURI())
    });
    

    it runs, it opens a new browser tab with url like data:application/pdf;base64, JVBERi0xLjQKMSAwIG9iago8P........ but the page is blank, it doesn't show the report. Instead if I take the same reportData and put it in the STUDIO online, when I run the report it shows correctly



  • Hello,
    checking better the console messages I found this error
    "Not allowed to navigate top frame to data URL: data:application/pdf;base64"
    due to last Chrome update

    so I was able to fix it with this updates

    var url = res.toDataURI();
    var url_with_name = url.replace("data:application/pdf;", "data:application/pdf;name=myname.pdf;")
    var html = '<html>' +
    	'<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}  </style>' +
    	'<body>' +
    	'<p>new viewer</p>' +
    	'<iframe type="application/pdf" src="' + url_with_name + '"></iframe>' +
    	'</body></html>';
    var a = window.open("about:blank", "Zupfnoter");
    a.document.write(html);
    a.document.close();
    


  • Thank you for sharing this!

    It is now part of the documentation:
    https://jsreport.net/learn/browser-client


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.