The exportAs() method exports the monthly calendar in the specified image format.
DayPilot.Month.exportAs(format[, options]);format ("svg" | "png" | "jpeg" | "xlsx") - output image format
options.area ("viewport" | "full" | "range") - exported area; defaults to "viewport"
options.dateFrom - start date (applies only to area: "range")
options.dateTo - end date (applies only to area: "range")
options.quality - quality of the output JPEG image (applies only to format: "jpeg"); defaults to 0.92
options.scale - output scale factor; defaults to 1 (use 2 for 200% magnification)
Returns a DayPilot.Export object that provides the following methods:
toElement() - returns a DOM element with the image (<svg> or <img>)
toHtml() - returns the image element as HTML
toDataUri() - returns a data URI string (SVG or image data)
toBlob() - returns a Blob object
download(filename) - forces download of the image
print() - prints the exported image using the browser print dialog
Use options.area to export the current viewport, the full calendar, or a custom date range. When area is set to "range", you need to specify options.dateFrom and options.dateTo.
The quality option only affects JPEG output, and scale controls the size of the generated image.
const image = dp.exportAs("png", {
area: "full",
scale: 2
});
image.download("month.png");