kodie
1/18/2016 - 6:13 PM

Print just an image from a page.

Print just an image from a page.

function printImage(image, title) {
	var winContent = "<html><head><title>" + title + "</title><script>function step1(){\n" +
						"setTimeout('step2()', 10);}\n" +
						"function step2(){window.print();window.close()}\n" +
						"</scri" + "pt></head><body onload='step1()'>\n" +
						"<img src='" + image + "' /></body></html>";

	var win = window.open('about:blank', '_new');
	win.document.open();
	win.document.write(winContent);
	win.document.close();
}

printImage('path/to/image.png', 'Title for top of page');