Comment posted by Dan Letecky [DayPilot]
4 years ago.

I confirm the problem, Chrome seems to freeze during the print() call. Let's see if it can be fixed - I'll keep you updated.

Comment posted by Maarten Baars
4 years ago.

Will you keep updating this thread? I have the same problem in my company and more colleagues are pressing the alarm button. We are currently working around the issue with Firefox. This one does not seem to have the problem.

Answer posted by Maarten Baars
4 years ago.

Workaround found. By creating a fake (hidden) iFrame and exporting the daypilot calendar to an image, you can place the image in the iframe and print the iframe. Like so:

$("#print-button").click(function (ev) {
const iframe = document.createElement('iframe');
iframe.style.height = 0;
iframe.style.visibility = 'hidden';
iframe.style.width = 0;

iframe.setAttribute('srcdoc', '<html><body></body></html>');

document.body.appendChild(iframe);

iframe.addEventListener('load', function() {
const image = dp.exportAs('png').toElement();
image.style.maxWidth = '100%';

const body = iframe.contentDocument.body;
body.style.textAlign = 'center';
body.appendChild(image);

iframe.contentWindow.print();
});
});

This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.