Disable dhtmlxlayout for printing

I’m using dhtmlxlayout to display a very large organigram without breaking the website. When a user wants to print the page, i want to disable the dhtmlxlayout so the framed content an be printed.

How is this possible?

Unfortunatelly, there is no such possibility.

I went on and hacked something like this:

function PrintPage(){
	window.onbeforeprint = removeelements();
	window.print(); 
	window.onafterprint = revertback();
}

this seems to work

Yes, you can try it.
I meant really possibity of printing just layout’s frame.

Hi

did you manager to get the function to work?

thx
Q

yes, but that gave some other issues.
I’m now using this one, which does the work perfectly:
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}

but my page has scripts on it, which won’t work after the print action. So i have a new idea to create a iframe, then place the print content in there, then print the iframe, then remove the iframe, something like this:

function printDivNew(divName) {
	var printContents = document.getElementById(divName).innerHTML;
	var iframe = document.createElement('iframe');
	
	iframe.src = 'about:blank';
	iframe.style.position = 'absolute';
	iframe.style.width = '100px';
	iframe.style.left = '-200px';
	
	var win = iframe.contentWindow;
	win.document.write('<!doctype html><html><head></head><body>' + printContents + '</body></html>');
	win.print();
}

Hi

Cool, but where do you add the script, in the layout page or in the iframe that you want to print?

thx
Q

in the layout page.