search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

daypilot print() Chrome not working

Asked by Anonymous
8 months ago.

I think

daypilot.exportAs("JPG", { area: "full" }).print();

isn't working on google chrome, but it's work on internet explorer

i try the demo

https://javascript.daypilot.org/demo/scheduler/exportprint.html

it's not working too on google chrome, but it's work on internet explorer

there is any bug fixing to this case?

Comment posted by Dan Letecky [DayPilot]
8 months 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
8 months 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
8 months 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 3 months old and has been closed. Please create a new question if you have anything to add.