Export to PDF (version 4.0)

The article refers to exporting of dhtmlxScheduler 4.0 or earlier versions. If you use dhtmlxScheduler 4.1+, see details here.

Starting from version 4.1, dhtmlxScheduler provides a new approach for exporting the scheduler into the PDF format - an online export service.


The PHP version of the package: https://github.com/DHTMLX/scheduler-to-pdf-php

The Java version of the package: https://github.com/DHTMLX/scheduler-to-pdf-java

The .NET version of the package: https://github.com/DHTMLX/scheduler-to-pdf-net

Related sample:  Export to PDF [Legacy]

Necessary includes

On the scheduler page, enable one more extension:

    pdf: true

Triggering the export

To export scheduler data to PDF, you just need to add on the page a button, which will call the toPDF() method. The parameter of the toPDF() method is the URL of the script, which has been installed previously:

<input type="button" name="save" value="save" 
style="right:300px; width:80px; position:absolute; top:1px;">

Configuring service

To configure the export options, you need to deal with both client and server sides.

Client side

As mentioned above, for export activation you should use the method toPDF():

scheduler.toPDF(path, color, header, footer);


  • path - (url) the path to the php file which generates PDF-file. See details below.
  • color - ('color', 'gray', 'bw', 'custom', 'fullcolor') specifies colormap.
    • 'color' - full-color printing, default value.
    • 'gray' - prints in shades of black and white.
    • 'bw' - uses only black and white colors.
    • 'custom' - can be used to enable a custom colormap ( requires php coding, see below ).
    • 'fullcolor' - actual background and text colors that are used while exporting.
  • header - (boolean, optional) defines whether a header will be added to the page. By default, false. See details below.
  • footer - (boolean, optional) defines whether a footer will be added to the page. By default, false.

    See details below.

So, to your HTML page add a code line that will call toPDF() method with the appropriate number of the parameters. For example, it may look like:


Server side

In the code snippet above generate.php is a php file that defines export options.

The simplest sample of the file is:

$scPDF = new schedulerPDF();

But before executing the printScheduler() method, you can apply some custom configuration options:

Size of elements:

// the height of the header of the day container in the month mode
$scPDF->monthDayHeaderHeight = 6;
 // the height of the header in the month mode
$scPDF->monthHeaderHeight = 8;
 // the height of the month name container in the year mode
$scPDF->yearMonthHeaderHeight = 8;
 // height of the row in the agenda mode
$scPDF->agendaRowHeight = 6;
 // the height of the header in the day and week mode
$scPDF->dayTopHeight = 6;
 // the width of the left scale in the day and week mode
$scPDF->dayLeftWidth = 16;

Font size:

 // font size settings
$scPDF->monthHeaderFontSize = 9;
$scPDF->monthDayHeaderFontSize = 8;
$scPDF->monthEventFontSize = 7;
$scPDF->yearHeaderFontSize = 8;
$scPDF->yearFontSize = 8;
$scPDF->agendaFontSize = 8;
$scPDF->dayHeaderFontSize = 7;
$scPDF->dayScaleFontSize = 8;
$scPDF->dayEventHeaderFontSize = 7;
$scPDF->dayEventBodyFontSize = 7;
$scPDF->todayFontSize = 11;

Custom colors (make sure, you use the 'custom' value as the name of the colormap on the client side):

$scPDF->lineColor = '586A7E';
$scPDF->bgColor = 'C2D5FC';
$scPDF->dayHeaderColor = 'EBEFF4';
$scPDF->dayBodyColor = 'FFFFFF';
$scPDF->dayHeaderColorInactive = 'E2E3E6';
$scPDF->dayBodyColorInactive = 'ECECEC';
$scPDF->headerTextColor = '2F3A48';
$scPDF->textColor = '2F3A48';
$scPDF->eventTextColor = '887A2E';
$scPDF->eventBorderColor = 'B7A543';
$scPDF->eventColor = 'FFE763';
$scPDF->todayTextColor = '000000';
$scPDF->scaleColorOne = 'FCFEFC';
$scPDF->scaleColorTwo = 'DCE6F4';
$scPDF->yearDayColor = 'EBEFF4';
$scPDF->yearDayColorInactive = 'd6d6d6';

Headers and footers:

// the height of the header
$scPDF->headerImgHeight = 40;
// the height of the footer
$scPDF->footerImgHeight = 40;
// the path to the header image
$scPDF->headerImg = './header.png';
// the path to the footer image
$scPDF->footerImg = './footer.png';

Header and Footer

It's possible to define custom header and footer for each page.

To achieve that, do the following steps:

  • create images with the names "header.png" and "footer.png".
  • copy those images to the same folder where generate.php resides.
  • on the client side, change the code's call as:
scheduler.toPDF(url, "color", true, true);

As a result, you will have "header.png" and "footer.png" images as the header and footer on all pages in the generated PDF file.

Error reporting

If output of PDF file is failed, there must be the file named as "error_report_xxxx.xml". Please, send this file with any bug-reports.

If output doesn't fail, but still has some problems, you can edit generate.php and change

$debug = false;


$debug = true;

As a result, there will be a new file saved. It will be called like "debug_xxxxx.xml". Please, send it with the related error report.

Back to top