New to Kendo UI for Angular? Start a free 30-day trial
The Chart Is Clipped during Printing
Environment
Product | Progress® Kendo UI® for Angular Charts |
Description
When I am printing the Chart using the browser Print option, the generated PDF is clipped and overflows the page.
Cause
The Chart element may overflow the page during printing if the component size is larger than the paper size.
Solution
- Set the print dimensions of the Chart by using a Media Query and matchMedia method.
css
@media print {
kendo-chart {
width: 200mm;
}
}
``
```ts
private matchPrint: MediaQueryList = window.matchMedia('print');
- Add listener to the
MediaQueryList
and before printing, call theresize
method of the Chart.
ts
public ngOnInit(): void {
this.matchPrint.addEventListener('change', this.resizeChart);
}
- Remove the
MediaQueryList
listener with anngOnDestroy
hook.
ts
public ngOnDestroy(): void {
if (this.matchPrint) {
this.matchPrint.removeEventListener('change', this.resizeChart);
this.matchPrint = null;
}
}
Due to Bug 774398, Firefox does not support the suggested approach.
The following example shows the full implementation of the demonstrated approach.
Change Theme
Theme
Loading ...