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

DayPilot > Scheduler > Printing - results in blank page

Asked by stapes
7 years ago.

I am trying to make a print option for a DayPilot Scheduler, using Typescript language.
This is my code:

var image = this.$scope.dps.scheduler.exportAs("png", {
area: "range",
dateFrom: this.formatDate(fromDate),
dateTo: this.formatDate(toDate),
quality: 0.1
}).print();

Downloading the image worked fine (see attached image). The download code is practically identical:

var image = this.$scope.dps.scheduler.exportAs("png", {
area: "range",
dateFrom: this.formatDate(fromDate),
dateTo: this.formatDate(toDate),
quality: 0.1
}).download();

The print option produces a blank page, regardless of date ranges input.

How do I get a proper print?

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

What browser are you using?

Are you able to reproduce the issue using the online demo?
https://javascript.daypilot.org/demo/scheduler/exportprint.html

Comment posted by stapes
7 years ago.

Sorry Dan, that makes no sense to me at all. I can't see a demo on that link, just a picture of a scheduler?

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

If you choose "PNG" from the drop down below the Scheduler and click "Print", does it work?

Comment posted by stapes
7 years ago.

How does that help? I see no code?

Answer posted by stapes
7 years ago.

OK. Finally got this to work.

this was my final version:

var image = this.$scope.dps.scheduler.exportAs("SVG"
,{
area: "range",
dateFrom: this.formatDate(fromDate),
dateTo: this.formatDate(toDate),
quality: 0.1
}).print();

It appears the only major difference is the format being in UPPERCASE.

I managed to find the code behind your demo using Google Chrome's Developer Tools!

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

Great, thanks for the update!

The lowercase/uppercase shouldn't make any difference, at least in the latest version. However, I've noticed that you are using PNG format in your original example.

When using the print() method the exported image is created as a Blob and converted to data URI which is inserted into a new iframe using <img> element. Your exported image seems to be quite big and there might be a problem with the image size (browsers apply limits to the canvas, the generated blob and the data URI as well). That's why I was asking about your browser.

Anyway, using SVG is much better idea - it's vector (and scalable) and the output data is also much smaller in size.

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