Export to PNG

Starting from version 4.1, dhtmlxScheduler provides an online export service that gives you the possibility to export the scheduler to the PNG format.

The service is free, but the output PNG file will contain the library's watermark under the GPL license. In case you buy a license, the result of export will be available without a watermark during the valid support period (1 month for Commercial license and 12 months for the Enterprise one).

Using Export Services

There are several export services available. You can install them on your computer and export Scheduler to PNG locally.

Note that export services are not included into the Scheduler package, read the corresponding article to learn the terms of using each of them.

Limits on request size

There is a common API endpoint https://export.dhtmlx.com/scheduler which serves for export methods (exportToPDF, exportToPNG, etc.). Max request size is 10 MB.

Default Export to PNG

To export the scheduler as a PNG image, do the following steps:

  1. Include the "http://export.dhtmlx.com/scheduler/api.js" file on the page to enable the online export service:
    <script src="codebase/dhtmlxscheduler.js"></script>
    <script src="http://export.dhtmlx.com/scheduler/api.js"></script>  <link rel="stylesheet" href="codebase/dhtmlxscheduler.css" type="text/css">
  2. Call the exportToPNG method to export the scheduler:
    <input value="Export to PNG" type="button" onclick='scheduler.exportToPNG()'> 
    <script>
        scheduler.init('scheduler_here',new Date(2019,5,30),"month");
        scheduler.load("data/events");
    </script>

Related sample:  Export to PDF/PNG

Parameters of the export method

The exportToPNG() method takes as a parameter an object with a number of properties (all the properties are optional):


Calling the export method with optional properties

scheduler.exportToPNG({
    format:"A4",
    orientation:"portrait",
    zoom:1,
    header:"<h1>My company</h1>",
    footer:"<h4>Bottom line</h4>",
    server:"https://myapp.com/myexport/scheduler"
});

Name of the output file

To set a custom name for the output file, use the name property in the exportToPNG method:

scheduler.exportToPNG({
    name:"my_beautiful_scheduler.png"});

Header/footer of the output file

To add the header/footer to the output PNG file, use the header/footer properties in the exportToPNG method:

Note, you can use any HTML while specifying the parameters. While specifying images, remember that you need to set global paths as values of the "src" attribute

scheduler.exportToPNG({
    name:"myscheduler.png",
    header:"<h1>My company</h1>",
    footer:"<h4>Bottom line</h4>"
});

Custom style for the output file

To apply a custom style for the scheduler, provide the stylesheet with your custom CSS classes:

  • through a link:
scheduler.exportToPNG({
    name:"calendar.png",
    header:'<link rel="stylesheet" href="http://mysite.com/custom.css">' });
  • or through the 'style' tag:
scheduler.exportToPNG({
    name:"calendar.png",
    header:'<style>... custom css classes here ...</style>' });

Note, the aforementioned solution works for the global HTTP reference. If you have CSS classes specified in an Intranet/local environment, you can embed all styles as in:

scheduler.exportToPNG({
    header:"<style>.tier1{   background: red;   color:white;}</style>"
});
Back to top