Export

15 Mar 202424 minutes to read

PDF Export

PDF export allows exporting Gantt data to PDF document. You need to use the pdfExport method for exporting. To enable PDF export in the Gantt, set the allowPdfExport to true.

To export data to PDF document, inject the PdfExport module in Gantt.

NOTE

Currently, we don’t have support for exporting the manually scheduled tasks.

@using Syncfusion.EJ2
@{
    ViewBag.Title = "DefaultFunctionalities";
}
<div class="container body-content">
    @(Html.EJS().Gantt("GanttContainer").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).TaskFields(ts => ts.Id(
            "TaskId").Name("TaskName").StartDate("StartDate").Duration("Duration").Progress("Progress").Child("SubTasks")).Toolbar(new List<string>() {
     "PdfExport" }).ToolbarClick("toolbarClick").Render())

    <script>
    function toolbarClick(args) {
        var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
        if (args.item.id === "GanttContainer_pdfexport") {
            ganttObj.pdfExport();
        }
    }
    </script>
</div>
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}

Indicators in PDF exporting

The PDF export functionality allows users to export Gantt charts enriched with dynamic indicators and accompanying images.
These indicators, represented by images,can be effortlessly defined using the base64 encoding value in the data object of datasource.This data object field should be mapped to indiactor property of task fields.

@using Syncfusion.EJ2
@{
    ViewBag.Title = "DefaultFunctionalities";
}
<div class="container body-content">
    @(Html.EJS().Gantt("GanttContainer").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).TaskFields(ts => ts.Id(
            "TaskId").Name("TaskName").StartDate("StartDate").Duration("Duration").Progress("Progress").Child("SubTasks")).Toolbar(new List<string>() {
     "PdfExport" }).ToolbarClick("toolbarClick").Indicators("indicators").Render())

    <script>
    function toolbarClick(args) {
        var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
        if (args.item.id === "GanttContainer_pdfexport") {
            ganttObj.pdfExport();
        }
    }
    </script>
</div>
public IActionResult Index()
{
    ViewBag.DataSource = ganttData();
    return View();
}

public static List<GanttDataSource> ganttData()
        {
            var indicatorImage = "/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UpQKUpQKUpQKUpQKUpQKUpQKUpQKUpQKUpQf/9k=";

            List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

            List<IndicatorsData> Indicators = new List<IndicatorsData>();

            GanttDataSource Record1 = new GanttDataSource()
            {
                TaskId = 1,
                TaskName = "Project initiation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child1 = new GanttDataSource()
            {
                TaskId = 2,
                TaskName = "Identify site location",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 70,
                Indicators = new List<IndicatorsModel>() {
                    new IndicatorsModel() {date = "04/08/2019", iconClass="e-btn-icon e-notes-info e-icons e-icon-left e-gantt e-notes-info::before", name= "Custom String", tooltip="Follow up",base64 = indicatorImage},
                    new IndicatorsModel() {date = "04/11/2019", iconClass="e-btn-icon e-notes-info e-icons e-icon-left e-gantt e-notes-info::before", name= "<span style="color:red">String Template</span>" base64 = indicatorImage}
                }
            };
            GanttDataSource Child2 = new GanttDataSource()
            {
                TaskId = 3,
                TaskName = "Perform soil test",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50

            };
            GanttDataSource Child3 = new GanttDataSource()
            {
                TaskId = 4,
                TaskName = "Soil test approval",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50
            };
            Record1.SubTasks.Add(Child1);
            Record1.SubTasks.Add(Child2);
            Record1.SubTasks.Add(Child3);

            GanttDataSource Record2 = new GanttDataSource()
            {
                TaskId = 5,
                TaskName = "Project estimation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>()
            };
            GanttDataSource Child4 = new GanttDataSource()
            {
                TaskId = 6,
                TaskName = "Develop floor plan for estimation",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 70,
                Indicators = new List<IndicatorsModel>() {
                    new IndicatorsModel() {date = "04/10/2019", iconClass="e-btn-icon e-notes-info e-icons e-icon-left e-gantt e-notes-info::before", name= "Indicator title", tooltip="tooltip",base64 = indicatorImage}
                }
            };
            GanttDataSource Child5 = new GanttDataSource()
            {
                TaskId = 7,
                TaskName = "List materials",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 50
            };
            Record2.SubTasks.Add(Child4);
            Record2.SubTasks.Add(Child5);

            GanttDataSourceCollection.Add(Record1);
            GanttDataSourceCollection.Add(Record2);

            return GanttDataSourceCollection;
        }
		
		public class GanttDataSource
        {
            public int TaskId { get; set; }
            public string TaskName { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public int? Duration { get; set; }
            public int Progress { get; set; }
            public List<GanttDataSource> SubTasks { get; set; }
            public List<IndicatorsModel> Indicators { get; set; }
        }

        public class IndicatorsModel
        {
            public string date { get; set; }
            public string iconClass { get; set; }
            public string name { get; set; }
            public string tooltip { get; set; }
            public string base64 { get; set; }
        }

Exporting Gantt data as a blob object

In Gantt, you can export the Gantt chart data as a blob object, which allows you to preview or modify the data before exporting it.

To export the Gantt chart data as a blob object, follow these steps:

step 1: pdfExport fourth argument set as true.

step 2: Then , pdfExpComplete return as blob object.

@(Html.EJS().Gantt("GanttContainer").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).AllowExcelExport(true).TaskFields(ts => ts.Id(
        "TaskId").Name("TaskName").StartDate("StartDate").Duration("Duration").Progress("Progress").Child("SubTasks")).Toolbar(new List<string>() {
"PdfExport","ExcelExport" }).ToolbarClick("toolbarClick").PdfExportComplete("pdfExpComplete").ExcelExportComplete("excelExpComplete").TreeColumnIndex(1).Render())

<script>
    function toolbarClick(args) {
        var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
        if (args.item.id === "GanttContainer_pdfexport") {
            ganttObj.pdfExport(null,null,null,true);
        }
        if (args.item.id === "GanttContainer_excelexport") {
            ganttObj.excelExport(null,null,null,true);
        }
    }
    let excelExpComplete = (args) => {
        //This event will be triggered when excel exporting.
            args.promise.then((e) => {
        //In this `then` function, we can get blob data through the arguments after promise resolved.
                exportBlob(e.blobData);
    });
};
let pdfExpComplete = (args) => {
    //This event will be triggered when pdf exporting.
        args.promise.then((e) => {
        //In this `then` function, we can get blob data through the arguments after promise resolved.
        exportBlob(e.blobData);
    });
};


let exportBlob = (blob) => {
    let a = document.createElement('a');
    document.body.appendChild(a);
    a.style.display = 'none';
    let urlg = window.URL.createObjectURL(blob);
    a.href = url;
    a.download = 'Export';
    a.click();
    window.URL.revokeObjectURL(url);
    document.body.removeChild(a);
}
</script>
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}

Single page exporting in gantt

In Gantt, we have provided support to export the Gantt component where each rows are auto-fit to the PDF document page width by setting IsFitToWidth as true in FitToWidthSettings of PdfExportProperties.

Also, we can customize the chart width and grid width in exported file using ChartWidth and GridWidth by defining it as percentage in string.

@using Syncfusion.EJ2
@{
    ViewBag.Title = "DefaultFunctionalities";
}
<div class="container body-content">
    @(Html.EJS().Gantt("GanttContainer").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).TaskFields(ts => ts.Id(
            "TaskId").Name("TaskName").StartDate("StartDate").Duration("Duration").Progress("Progress").Child("SubTasks")).Toolbar(new List<string>() {
     "PdfExport" }).ToolbarClick("toolbarClick").Render())

    <script>
    function toolbarClick(args) {
        var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
        if (args.item.id === "GanttContainer_pdfexport") {
            var exportProperties = {
                    fitToWidthSettings: {       
                        isFitToWidth: true,       
                    }       
                };
            ganttObj.pdfExport(exportProperties);
        }
    }
    </script>
</div>
public IActionResult Index()
{
    ViewBag.DataSource = GanttData.ProjectNewData();
    return View();
}

Exporting with template

Exporting with column template

The PDF export functionality allows to export Grid columns that include images, hyperlinks, and custom text to an PDF document using pdfQueryCellInfo event.

In the following sample, the hyperlinks and images are exported to PDF using hyperlink and image properties in the pdfQueryCellInfo event.

Note: PDF Export supports base64 string to export the images.

@Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).Height("450px").TaskFields(ts
    =>
    ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Child(
    "SubTasks").Toolbar(new List<string>() {
        "PdfExport" }).ToolbarClick("toolbarClick").PdfQueryCellInfo("pdfQueryCellInfo").ResourceInfo("ResourceId")).ResourceFields(rf =>
        rf.Id("ResourceId").Name("ResourceName")).Resources((
        IEnumerable<object>)ViewBag.projectResources).Columns(col =>
            {
            col.Field("TaskId").HeaderText("Task ID").Width(250).Add();
            col.Field("TaskName").HeaderText("Task Name").Width(250).Add();
            col.Field("ResourceId").HeaderText("Resources").Template("#columnTemplate").Add();
            col.Field("StartDate").Add();
            col.Field("Duration").Add();
            col.Field("Progress").Add();
            }).Render()
            <script>
                function toolbarClick(args) {
                    var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
                    if (args.item.id === "GanttContainer_pdfexport") {
                        ganttObj.pdfExport();
                    }
                }
                function pdfQueryCellInfo(args) {
                        if (args.column.headerText === 'Resources') {
                            {
                                args.image = { height: 40, width: 40, base64: (args).data.taskData.resourcesImage };
                            }
                        }
                    }
            </script>
            <script type="text/x-jsrender" id="columnTemplate">
        ${if(ganttProperties.resourceNames)}
         <div class="image">
            <img src="${TaskID}.png" style="height:40px;width:40px" /><div style="display:inline-block;width:100%;position:relative;left:30px;top:-14px">${ganttProperties.resourceNames}</div>
        </div>
        ${/if}
    </script>
public IActionResult Index()
{
     ViewBag.DataSource = ganttData();
     ViewBag.projectResources = projectResources();
    return View();
}

public static List<GanttResources> projectResources()
        {
            List<GanttResources> GanttResourcesCollection = new List<GanttResources>();

            GanttResources Record1 = new GanttResources()
            {
                ResourceId = 1,
                ResourceName = "Martin Tamer"
            };
            GanttResources Record2 = new GanttResources()
            {
                ResourceId = 2,
                ResourceName = "Rose Fuller"
            };
            GanttResources Record3 = new GanttResources()
            {
                ResourceId = 3,
                ResourceName = "Margaret Buchanan"
            };
            GanttResources Record4 = new GanttResources()
            {
                ResourceId = 4,
                ResourceName = "Fuller King"
            };
            GanttResources Record5 = new GanttResources()
            {
                ResourceId = 5,
                ResourceName = "Davolio Fuller"
            };
            GanttResources Record6 = new GanttResources()
            {
                ResourceId = 6,
                ResourceName = "Van Jack"
            };
            GanttResources Record7 = new GanttResources()
            {
                ResourceId = 7,
                ResourceName = "Fuller Buchanan"
            };
            GanttResources Record8 = new GanttResources()
            {
                ResourceId = 8,
                ResourceName = "Jack Davolio"
            };
            GanttResources Record9 = new GanttResources()
            {
                ResourceId = 9,
                ResourceName = "Tamer Vinet"
            };
            GanttResources Record10 = new GanttResources()
            {
                ResourceId = 10,
                ResourceName = "Vinet Fuller"
            };
            GanttResources Record11 = new GanttResources()
            {
                ResourceId = 11,
                ResourceName = "Bergs Anton"
            };
            GanttResources Record12 = new GanttResources()
            {
                ResourceId = 12,
                ResourceName = "Construction Supervisor"
            };
            GanttResourcesCollection.Add(Record1);
            GanttResourcesCollection.Add(Record2);
            GanttResourcesCollection.Add(Record3);
            GanttResourcesCollection.Add(Record4);
            GanttResourcesCollection.Add(Record5);
            GanttResourcesCollection.Add(Record6);
            GanttResourcesCollection.Add(Record7);
            GanttResourcesCollection.Add(Record8);
            GanttResourcesCollection.Add(Record9);
            GanttResourcesCollection.Add(Record10);
            GanttResourcesCollection.Add(Record11);
            GanttResourcesCollection.Add(Record12);
            return GanttResourcesCollection;
        }
        public static List<GanttDataSource> ganttData()
        {
            List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

            GanttDataSource Record1 = new GanttDataSource()
            {
                TaskId = 1,
                TaskName = "Project initiation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child1 = new GanttDataSource()
            {
                TaskId = 2,
                TaskName = "Identify site location",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 70,
                ResourceId = new int[] { 1 },
            };
            GanttDataSource Child2 = new GanttDataSource()
            {
                TaskId = 3,
                TaskName = "Perform soil test",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                Notes = "Obtain an engineered soil test of lot where construction is planned.From an engineer or company specializing in soil testing",
                ResourceId = new int[] { 2 },
            };
            GanttDataSource Child3 = new GanttDataSource()
            {
                TaskId = 4,
                TaskName = "Soil test approval",
                Dependency = "3FS",
                Notes = "Measure the total property area alloted for construction",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                ResourceId = new int[] { 3 }
            };
            Record1.SubTasks.Add(Child1);
            Record1.SubTasks.Add(Child2);
            Record1.SubTasks.Add(Child3);

            GanttDataSource Record2 = new GanttDataSource()
            {
                TaskId = 5,
                TaskName = "Project estimation",
                StartDate = new DateTime(2019, 04, 02),

                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child4 = new GanttDataSource()
            {
                TaskId = 6,
                TaskName = "Develop floor plan for estimation",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 70,
                ResourceId = new int[] { 4 },

            };
            GanttDataSource Child5 = new GanttDataSource()
            {
                TaskId = 7,
                TaskName = "List materials",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Dependency = "6FS",
                Progress = 50,
                ResourceId = new int[] { 3 },

            };
            Record2.SubTasks.Add(Child4);
            Record2.SubTasks.Add(Child5);

            GanttDataSourceCollection.Add(Record1);
            GanttDataSourceCollection.Add(Record2);

            return GanttDataSourceCollection;
        }
        public class GanttResources
        {
            public int ResourceId { get; set; }
            public string ResourceName { get; set; }
        }
        public class GanttDataSource
        {
            public int TaskId { get; set; }
            public string TaskName { get; set; }
            public string Dependency { get; set; }
            public string Notes { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public int? Duration { get; set; }
            public int Progress { get; set; }
            public List<GanttDataSource> SubTasks { get; set; }
            public int[] ResourceId { get; set; }

        }

Exporting with taskbar template

The PDF export functionality allows to export taskbar templates that include images and text to an PDF document using pdfQueryTaskbarInfo event. Taskbars in the exported PDF document can be customized or formatted using the pdfQueryTaskbarInfo event for parent taskbar templates, taskbar template and milestone templates.

In the following sample, taskbar templates with images and text are exported to PDF using taskbarTemplate properties in the pdfQueryTaskbarInfo event.

Note: PDF Export supports base64 string to export the images.

@Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).Height("450px").RowHeight(60).TaskbarTemplate(
    "#TaskbarTemplate").ParentTaskbarTemplate("#ParentTaskbarTemplate").MilestoneTemplate("#MilestoneTemplate").TaskFields(ts
    =>
    ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Child("SubTasks").Toolbar(new
    List<string>() {
        "PdfExport"
        }).ToolbarClick("toolbarClick").PdfQueryTaskbarInfo("pdfQueryTaskbarInfo").ResourceInfo("ResourceId")).ResourceFields(rf
        =>
        rf.Id("ResourceId").Name("ResourceName")).Resources((
        IEnumerable<object>)ViewBag.projectResources).Columns(col =>
            {
            col.Field("TaskId").HeaderText("Task ID").Width(250).Add();
            col.Field("TaskName").HeaderText("Task Name").Width(250).Add();
            col.Field("ResourceId").HeaderText("Resources").Template("#columnTemplate").Add();
            col.Field("StartDate").Add();
            col.Field("Duration").Add();
            col.Field("Progress").Add();
            }
            ).Render()

            <script>
                function toolbarClick(args) {
                    var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
                    if (args.item.id === "GanttContainer_pdfexport") {
                        ganttObj.pdfExport();
                    }
                }
                function pdfQueryTaskbarInfo(args) {
                    if (!args.data.hasChildRecords) {
                        if (args.data.ganttProperties.resourceNames) {
                            args.taskbarTemplate.image = [{
                                width: 20, base64: (args).data.taskData.resourcesImage, height: 20
                            }]
                        }
                        args.taskbarTemplate.value = args.data.TaskName;
                    }
                    if (args.data.hasChildRecords) {
                        if (args.data.ganttProperties.resourceNames) {
                            args.taskbarTemplate.image = [{
                                width: 20, base64: (args).data.taskData.resourcesImage, height: 20
                            }]
                        }
                        args.taskbarTemplate.value = args.data.TaskName;
                    }
                    if (args.data.ganttProperties.duration === 0) {    
                        if (args.data.ganttProperties.resourceNames) {
                            args.taskbarTemplate.image = [{
                                width: 20, base64: (args).data.taskData.resourcesImage, height: 20,
                            }]
                        }
                        args.taskbarTemplate.value = args.data.TaskName
                    }
                }
            </script>

            <script type="text/x-jsrender" id="TaskbarTemplate">
        <div class="e-gantt-child-taskbar-inner-div e-gantt-child-taskbar" style="height:100%">
            <div class="e-gantt-child-progressbar-inner-div e-gantt-child-progressbar" style="width:${ganttProperties.progressWidth}px;height:100%">
                <img src="${ganttProperties.resourceNames}.png" style="height:40px;width:40px" />
                <span class="e-task-label" style="position: absolute; z-index: 1; font-size: 12px; color: white; top: 5px; left: 10px; font-family: " Segoe UI"; overflow: hidden; text-overflow: ellipsis; width: 40%; cursor: move;">${taskData.TaskName}</span>
            </div>
        </div>
    </script>

            <script type="text/x-jsrender" id="ParentTaskbarTemplate">
        <div class="e-gantt-parent-taskbar-inner-div e-gantt-parent-taskbar" style="height:100%">
            <div class="e-gantt-parent-progressbar-inner-div e-gantt-parent-progressbar" style="width:${ganttProperties.progressWidth}px;height:100%">
                <span class="e-task-label" style="position: absolute; z-index: 1; font-size: 12px; color: white; top: 5px; left: 10px; font-family: " Segoe UI"; overflow: hidden; text-overflow: ellipsis; width: 40%; cursor: move;">${taskData.TaskName}</span>
            </div>
        </div>
    </script>

            <script type="text/x-jsrender" id="MilestoneTemplate">
        <div class="e-gantt-milestone" style="position:absolute;">
            <div class="e-milestone-top" style="border-right-width:15px;border-left-width:15px;border-bottom-width:15px;"></div>
            <div class="e-milestone-bottom" style="top:15px;border-right-width:15px; border-left-width:15px; border-top-width:15px;">
            </div>
            <img src="${ganttProperties.resourceNames}.png" style="height:40px;width:40px" />
        </div>
    </script>
public IActionResult Index()
{
     ViewBag.DataSource = GanttData();
     ViewBag.ProjectResources = ProjectResources();
    return View();
}

public static List<GanttResources> ProjectResources()
        {
            List<GanttResources> GanttResourcesCollection = new List<GanttResources>();

            GanttResources Record1 = new GanttResources()
            {
                ResourceId = 1,
                ResourceName = "Martin Tamer"
            };
            GanttResources Record2 = new GanttResources()
            {
                ResourceId = 2,
                ResourceName = "Rose Fuller"
            };
            GanttResources Record3 = new GanttResources()
            {
                ResourceId = 3,
                ResourceName = "Margaret Buchanan"
            };
            GanttResources Record4 = new GanttResources()
            {
                ResourceId = 4,
                ResourceName = "Fuller King"
            };
            GanttResources Record5 = new GanttResources()
            {
                ResourceId = 5,
                ResourceName = "Davolio Fuller"
            };
            GanttResources Record6 = new GanttResources()
            {
                ResourceId = 6,
                ResourceName = "Van Jack"
            };
            GanttResources Record7 = new GanttResources()
            {
                ResourceId = 7,
                ResourceName = "Fuller Buchanan"
            };
            GanttResources Record8 = new GanttResources()
            {
                ResourceId = 8,
                ResourceName = "Jack Davolio"
            };
            GanttResources Record9 = new GanttResources()
            {
                ResourceId = 9,
                ResourceName = "Tamer Vinet"
            };
            GanttResources Record10 = new GanttResources()
            {
                ResourceId = 10,
                ResourceName = "Vinet Fuller"
            };
            GanttResources Record11 = new GanttResources()
            {
                ResourceId = 11,
                ResourceName = "Bergs Anton"
            };
            GanttResources Record12 = new GanttResources()
            {
                ResourceId = 12,
                ResourceName = "Construction Supervisor"
            };
            GanttResourcesCollection.Add(Record1);
            GanttResourcesCollection.Add(Record2);
            GanttResourcesCollection.Add(Record3);
            GanttResourcesCollection.Add(Record4);
            GanttResourcesCollection.Add(Record5);
            GanttResourcesCollection.Add(Record6);
            GanttResourcesCollection.Add(Record7);
            GanttResourcesCollection.Add(Record8);
            GanttResourcesCollection.Add(Record9);
            GanttResourcesCollection.Add(Record10);
            GanttResourcesCollection.Add(Record11);
            GanttResourcesCollection.Add(Record12);
            return GanttResourcesCollection;
        }
        public static List<GanttDataSource> GanttData()
        {
            List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

            GanttDataSource Record1 = new GanttDataSource()
            {
                TaskId = 1,
                TaskName = "Project initiation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child1 = new GanttDataSource()
            {
                TaskId = 2,
                TaskName = "Identify site location",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 70,
                ResourceId = new int[] { 1 },
            };
            GanttDataSource Child2 = new GanttDataSource()
            {
                TaskId = 3,
                TaskName = "Perform soil test",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                Notes = "Obtain an engineered soil test of lot where construction is planned.From an engineer or company specializing in soil testing",
                ResourceId = new int[] { 2 },
            };
            GanttDataSource Child3 = new GanttDataSource()
            {
                TaskId = 4,
                TaskName = "Soil test approval",
                Dependency = "3FS",
                Notes = "Measure the total property area alloted for construction",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                ResourceId = new int[] { 3 }
            };
            Record1.SubTasks.Add(Child1);
            Record1.SubTasks.Add(Child2);
            Record1.SubTasks.Add(Child3);

            GanttDataSource Record2 = new GanttDataSource()
            {
                TaskId = 5,
                TaskName = "Project estimation",
                StartDate = new DateTime(2019, 04, 02),

                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child4 = new GanttDataSource()
            {
                TaskId = 6,
                TaskName = "Develop floor plan for estimation",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 70,
                ResourceId = new int[] { 4 },

            };
            GanttDataSource Child5 = new GanttDataSource()
            {
                TaskId = 7,
                TaskName = "List materials",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Dependency = "6FS",
                Progress = 50,
                ResourceId = new int[] { 3 },

            };
            Record2.SubTasks.Add(Child4);
            Record2.SubTasks.Add(Child5);

            GanttDataSourceCollection.Add(Record1);
            GanttDataSourceCollection.Add(Record2);

            return GanttDataSourceCollection;
        }
        public class GanttResources
        {
            public int ResourceId { get; set; }
            public string ResourceName { get; set; }
        }
        public class GanttDataSource
        {
            public int TaskId { get; set; }
            public string TaskName { get; set; }
            public string Dependency { get; set; }
            public string Notes { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public int? Duration { get; set; }
            public int Progress { get; set; }
            public List<GanttDataSource> SubTasks { get; set; }
            public int[] ResourceId { get; set; }

        }

Exporting with task label template

The PDF export functionality allows to export task label template that include images and text to an PDF document using pdfQueryTaskbarInfo event.

In the following sample, task label template with images and text are exported to PDF using labelSettings properties in the pdfQueryTaskbarInfo event.

Note: PDF Export supports base64 string to export the images.

@Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).Height("450px").RowHeight(60).TaskFields(ts
    =>
    ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Child("SubTasks").Toolbar(new
    List<string>() {
        "PdfExport"
        }).ToolbarClick("toolbarClick").PdfQueryTaskbarInfo("pdfQueryTaskbarInfo").ResourceInfo("ResourceId")).ResourceFields(rf
        =>
        rf.Id("ResourceId").Name("ResourceName")).Resources((
        IEnumerable<object>)ViewBag.projectResources).Columns(col =>
            {
            col.Field("TaskId").HeaderText("Task ID").Width(250).Add();
            col.Field("TaskName").HeaderText("Task Name").Width(250).Add();
            col.Field("ResourceId").HeaderText("Resources").Template("#columnTemplate").Add();
            col.Field("StartDate").Add();
            col.Field("Duration").Add();
            col.Field("Progress").Add();
            }
            )
            .ResourceFields(rf => rf.Id("ResourceId").Name("ResourceName")).Resources((IEnumerable<object>)ViewBag.Resources)
            .LabelSettings(ls => ls.LeftLabel("#leftLabel").RightLabel("#rightLabel").TaskLabel("${Progress}%"))
            .ProjectStartDate("03/24/2019")
            .ProjectEndDate("05/04/2019")
            .Render()

            <script>
                function toolbarClick(args) {
                    var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
                    if (args.item.id === "GanttContainer_pdfexport") {
                        ganttObj.pdfExport();
                    }
                }
                function pdfQueryTaskbarInfo(args) {
                    args.labelSettings.leftLabel.value = args.data.ganttProperties.taskName + '[' + args.data.ganttProperties.progress + ']';
                    if (args.data.ganttProperties.resourceNames) {
                        args.labelSettings.rightLabel.value = args.data.ganttProperties.resourceNames;
                        args.labelSettings.rightLabel.image = [{
                            base64: (args).data.taskData.resourcesImage, width: 20, height: 20
                        }]

                    }
                    args.labelSettings.taskLabel.value = args.data.ganttProperties.progress + '%'
                }
            </script>

<script type="text/x-template" id="leftLabel">
    <div style="margin-top=-7px;">
        <div id="leftLabel">
            <span>${TaskName} [ ${Progress}% ]</span>
        </div>
    </div>
</script>
<script type="text/x-template" id="rightLabel">
    <div style="margin-top=-7px;">
        ${if(ganttProperties.resourceInfo)}
        <div id="rightLabel">
            ${getResourceElements(ganttProperties.resourceInfo)}
        </div>
        ${/if}
    </div>
</script>
<script>
    function getResourceElements(value) {
        var out = "";
        var img = document.createElement('img');
        img.height = 40;
        var span = document.createElement('span');
        span.style.marginLeft = "5px";
        span.style.marginRight = "5px";
        for (var index = 0; index < value.length; index++) {
            var imgName = value[index].ResourceName;
            img.src = '../Content/gantt/images/' + value[index].ResourceName + '.png';
            span.innerHTML = value[index].ResourceName;
            out = out + img.outerHTML + span.outerHTML;
        }
        return out;
    }
</script>
public IActionResult Index()
{
     ViewBag.DataSource = GanttData();
     ViewBag.ProjectResources = ProjectResources();
    return View();
}

public static List<GanttResources> ProjectResources()
        {
            List<GanttResources> GanttResourcesCollection = new List<GanttResources>();

            GanttResources Record1 = new GanttResources()
            {
                ResourceId = 1,
                ResourceName = "Martin Tamer"
            };
            GanttResources Record2 = new GanttResources()
            {
                ResourceId = 2,
                ResourceName = "Rose Fuller"
            };
            GanttResources Record3 = new GanttResources()
            {
                ResourceId = 3,
                ResourceName = "Margaret Buchanan"
            };
            GanttResources Record4 = new GanttResources()
            {
                ResourceId = 4,
                ResourceName = "Fuller King"
            };
            GanttResources Record5 = new GanttResources()
            {
                ResourceId = 5,
                ResourceName = "Davolio Fuller"
            };
            GanttResources Record6 = new GanttResources()
            {
                ResourceId = 6,
                ResourceName = "Van Jack"
            };
            GanttResources Record7 = new GanttResources()
            {
                ResourceId = 7,
                ResourceName = "Fuller Buchanan"
            };
            GanttResources Record8 = new GanttResources()
            {
                ResourceId = 8,
                ResourceName = "Jack Davolio"
            };
            GanttResources Record9 = new GanttResources()
            {
                ResourceId = 9,
                ResourceName = "Tamer Vinet"
            };
            GanttResources Record10 = new GanttResources()
            {
                ResourceId = 10,
                ResourceName = "Vinet Fuller"
            };
            GanttResources Record11 = new GanttResources()
            {
                ResourceId = 11,
                ResourceName = "Bergs Anton"
            };
            GanttResources Record12 = new GanttResources()
            {
                ResourceId = 12,
                ResourceName = "Construction Supervisor"
            };
            GanttResourcesCollection.Add(Record1);
            GanttResourcesCollection.Add(Record2);
            GanttResourcesCollection.Add(Record3);
            GanttResourcesCollection.Add(Record4);
            GanttResourcesCollection.Add(Record5);
            GanttResourcesCollection.Add(Record6);
            GanttResourcesCollection.Add(Record7);
            GanttResourcesCollection.Add(Record8);
            GanttResourcesCollection.Add(Record9);
            GanttResourcesCollection.Add(Record10);
            GanttResourcesCollection.Add(Record11);
            GanttResourcesCollection.Add(Record12);
            return GanttResourcesCollection;
        }
        public static List<GanttDataSource> GanttData()
        {
            List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

            GanttDataSource Record1 = new GanttDataSource()
            {
                TaskId = 1,
                TaskName = "Project initiation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child1 = new GanttDataSource()
            {
                TaskId = 2,
                TaskName = "Identify site location",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 70,
                ResourceId = new int[] { 1 },
            };
            GanttDataSource Child2 = new GanttDataSource()
            {
                TaskId = 3,
                TaskName = "Perform soil test",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                Notes = "Obtain an engineered soil test of lot where construction is planned.From an engineer or company specializing in soil testing",
                ResourceId = new int[] { 2 },
            };
            GanttDataSource Child3 = new GanttDataSource()
            {
                TaskId = 4,
                TaskName = "Soil test approval",
                Dependency = "3FS",
                Notes = "Measure the total property area alloted for construction",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                ResourceId = new int[] { 3 }
            };
            Record1.SubTasks.Add(Child1);
            Record1.SubTasks.Add(Child2);
            Record1.SubTasks.Add(Child3);

            GanttDataSource Record2 = new GanttDataSource()
            {
                TaskId = 5,
                TaskName = "Project estimation",
                StartDate = new DateTime(2019, 04, 02),

                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child4 = new GanttDataSource()
            {
                TaskId = 6,
                TaskName = "Develop floor plan for estimation",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 70,
                ResourceId = new int[] { 4 },

            };
            GanttDataSource Child5 = new GanttDataSource()
            {
                TaskId = 7,
                TaskName = "List materials",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Dependency = "6FS",
                Progress = 50,
                ResourceId = new int[] { 3 },

            };
            Record2.SubTasks.Add(Child4);
            Record2.SubTasks.Add(Child5);

            GanttDataSourceCollection.Add(Record1);
            GanttDataSourceCollection.Add(Record2);

            return GanttDataSourceCollection;
        }
        public class GanttResources
        {
            public int ResourceId { get; set; }
            public string ResourceName { get; set; }
        }
        public class GanttDataSource
        {
            public int TaskId { get; set; }
            public string TaskName { get; set; }
            public string Dependency { get; set; }
            public string Notes { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public int? Duration { get; set; }
            public int Progress { get; set; }
            public List<GanttDataSource> SubTasks { get; set; }
            public int[] ResourceId { get; set; }

        }

Exporting with header template

The PDF export functionality allows to export header template that include images and text to an PDF document using pdfColumnHeaderQueryCellInfo event.

In the following sample, header template with images and text are exported to PDF using headerTemplate properties in the pdfColumnHeaderQueryCellInfo event.

Note: PDF Export supports base64 string to export the images.

@Html.EJS().Gantt("Gantt").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowPdfExport(true).Height("450px").RowHeight(60).TaskFields(ts
    =>
    ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration").Progress("Progress").Child("SubTasks").Toolbar(new
    List<string>() {
        "PdfExport"
        }).ToolbarClick("toolbarClick").PdfColumnHeaderQueryCellInfo("pdfColumnHeaderQueryCellInfo").ResourceInfo("ResourceId")).ResourceFields(rf
        => rf.Id("ResourceId").Name("ResourceName")).Resources((
        IEnumerable<object>)ViewBag.ProjectResources).Columns(col =>
            {
            col.Field("TaskName").HeaderText("Task ID").HeaderTemplate("#projectName").Width(250).Add();
            col.Field("StartDate").HeaderTemplate("#dateTemplate").Add();
            }
            ).Render()

            <script>
                function toolbarClick(args) {
                    var ganttObj = document.getElementById("GanttContainer").ej2_instances[0];
                    if (args.item.id === "GanttContainer_pdfexport") {
                        ganttObj.pdfExport();
                    }
                }
                let i = 0;
                function pdfColumnHeaderQueryCellInfo(args) {   
                        let base64Array = [
                            { 'TaskName': '/9j/4AAQSkZJRgABAQIAHAAcAAD/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAMAAAITAAMAAAABAAEAAAAAAAAAAAAcAAAAAQAAABwAAAAB/9sAQwADAgICAgIDAgICAwMDAwQGBAQEBAQIBgYFBgkICgoJCAkJCgwPDAoLDgsJCQ0RDQ4PEBAREAoMEhMSEBMPEBAQ/9sAQwEDAwMEAwQIBAQIEAsJCxAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ/8AAEQgAIAAgAw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s2TiABkRKIlTDTELjvBg/MDZ6eF+WIHT+C4vaHci4i5hqprczb1xabkI5w20LNkyaQBo6lz3v5aQW8R2aYz1VOkrq9rP1Sfx3gX1P9rJvPof8PP8Ar92zDQxLHQ71NzbzJ+EHBkuAfV/X5Gefw968t8+Z7P6fZs4dUz9DvU3KXLf4QcGV4/8AV/X5HmTz968tz+X7P6/fs4dM9K+krq9ox0t/yLjv1P8Aaz7t67/fw/t9uzTH/9k=' },
                        ]
                        while (i < base64Array.length) {
                            const key = Object.keys(base64Array[i])[0];
                            const value = base64Array[i][key];
                            if (key === args.column.field) {
                                args.headerTemplate.image = [{
                                    base64: value, width: 20, height: 20
                                }];
                                args.headerTemplate.value = args.column.field;
                                break;
                            }
                            i++;
                        }
                }
            </script>

<script type="text/x-template" id="projectName">
    <div>
        <div>
            <img class="taskName" width="20" height="20"  />
            <span>&nbsp;Task Name</span>
        </div>
    </div>
</script>
<script type="text/x-template" id="projectName">
    <div>
        <div>
            <img class="taskName" width="20" height="20"  />
            <span>&nbsp;Task Name</span>
        </div>
    </div>
</script>

<style>
    .material img.resource, .fabric img.resource, .bootstrap img.resource,
    .tailwind img.resource, .bootstrap5 img.resource, .bootstrap4 img.resource,
    .fluent img.resource,.material3 img.resource{
        content: url("../Content/gantt/images/Resources.png");
    }
    .material-dark img.resource, .fabric-dark img.resource, .bootstrap-dark img.resource,
    .tailwind-dark img.resource, .bootstrap5-dark img.resource, .highcontrast img.resource,
    .fluent-dark img.resource,.material3-dark img.resource {
        content: url("../Content/gantt/images/ResourcesDark.png");
    }
    .material img.taskName, .fabric img.taskName, .bootstrap img.taskName,
    .tailwind img.taskName, .bootstrap5 img.taskName, .bootstrap4 img.taskName,
    .fluent img.taskName,.material3 img.taskName {
        content: url("../Content/gantt/images/TaskName.png");
    }
    .material-dark img.taskName, .fabric-dark img.taskName, .bootstrap-dark img.taskName,
    .tailwind-dark img.taskName, .bootstrap5-dark img.taskName, .highcontrast img.taskName,
    .fluent-dark img.taskName,.material3-dark img.taskName {
        content: url("../Content/gantt/images/TaskNameDark.png");
    }
    .material img.startDate, .fabric img.startDate, .bootstrap img.startDate,
    .tailwind img.startDate, .bootstrap5 img.startDate, .bootstrap4 img.startDate,
    .fluent img.startDate,.material3 img.startDate {
        content: url("../Content/gantt/images/StartDate.png");
    }
    .material-dark img.startDate, .fabric-dark img.startDate, .bootstrap-dark img.startDate,
    .tailwind-dark img.startDate, .bootstrap5-dark img.startDate, .highcontrast img.startDate,
    .fluent-dark img.startDate,.material3-dark img.startDate {
        content: url("../Content/gantt/images/StartDateDark.png");
    }
    .material img.duration, .fabric img.duration, .bootstrap img.duration,
    .tailwind img.duration, .bootstrap5 img.duration, .bootstrap4 img.duration,
    .fluent img.duration,.material3 img.duration {
        content: url("../Content/gantt/images/Duration.png");
    }
    .material-dark img.duration, .fabric-dark img.duration, .bootstrap-dark img.duration,
    .tailwind-dark img.duration, .bootstrap5-dark img.duration, .highcontrast img.duration,
    .fluent-dark img.duration,.material3-dark img.duration {
        content: url("../Content/gantt/images/DurationDark.png");
    }
    .material img.progressTemplate, .fabric img.progressTemplate, .bootstrap img.progressTemplate,
    .tailwind img.progressTemplate, .bootstrap5 img.progressTemplate, .bootstrap4 img.progressTemplate,
    .fluent img.progressTemplate,.material3 img.progressTemplate {
        content: url("../Content/gantt/images/Progress.png");
    }
    .material-dark img.progressTemplate, .fabric-dark img.progressTemplate, .bootstrap-dark img.progressTemplate,
    .tailwind-dark img.progressTemplate, .bootstrap5-dark img.progressTemplate, .highcontrast img.progressTemplate,
    .fluent-dark img.progressTemplate,.material3-dark img.progressTemplate {
        content: url("../Content/gantt/images/ProgressDark.png");
    }
    img.resource, img.taskName, img.startDate, img.duration, img.progressTemplate {
        margin-right: 8px;
    }
</style>
public IActionResult Index()
{
     ViewBag.DataSource = GanttData();
     ViewBag.ProjectResources = ProjectResources();
    return View();
}

public static List<GanttResources> ProjectResources()
        {
            List<GanttResources> GanttResourcesCollection = new List<GanttResources>();

            GanttResources Record1 = new GanttResources()
            {
                ResourceId = 1,
                ResourceName = "Martin Tamer"
            };
            GanttResources Record2 = new GanttResources()
            {
                ResourceId = 2,
                ResourceName = "Rose Fuller"
            };
            GanttResources Record3 = new GanttResources()
            {
                ResourceId = 3,
                ResourceName = "Margaret Buchanan"
            };
            GanttResources Record4 = new GanttResources()
            {
                ResourceId = 4,
                ResourceName = "Fuller King"
            };
            GanttResources Record5 = new GanttResources()
            {
                ResourceId = 5,
                ResourceName = "Davolio Fuller"
            };
            GanttResources Record6 = new GanttResources()
            {
                ResourceId = 6,
                ResourceName = "Van Jack"
            };
            GanttResources Record7 = new GanttResources()
            {
                ResourceId = 7,
                ResourceName = "Fuller Buchanan"
            };
            GanttResources Record8 = new GanttResources()
            {
                ResourceId = 8,
                ResourceName = "Jack Davolio"
            };
            GanttResources Record9 = new GanttResources()
            {
                ResourceId = 9,
                ResourceName = "Tamer Vinet"
            };
            GanttResources Record10 = new GanttResources()
            {
                ResourceId = 10,
                ResourceName = "Vinet Fuller"
            };
            GanttResources Record11 = new GanttResources()
            {
                ResourceId = 11,
                ResourceName = "Bergs Anton"
            };
            GanttResources Record12 = new GanttResources()
            {
                ResourceId = 12,
                ResourceName = "Construction Supervisor"
            };
            GanttResourcesCollection.Add(Record1);
            GanttResourcesCollection.Add(Record2);
            GanttResourcesCollection.Add(Record3);
            GanttResourcesCollection.Add(Record4);
            GanttResourcesCollection.Add(Record5);
            GanttResourcesCollection.Add(Record6);
            GanttResourcesCollection.Add(Record7);
            GanttResourcesCollection.Add(Record8);
            GanttResourcesCollection.Add(Record9);
            GanttResourcesCollection.Add(Record10);
            GanttResourcesCollection.Add(Record11);
            GanttResourcesCollection.Add(Record12);
            return GanttResourcesCollection;
        }
        public static List<GanttDataSource> GanttData()
        {
            List<GanttDataSource> GanttDataSourceCollection = new List<GanttDataSource>();

            GanttDataSource Record1 = new GanttDataSource()
            {
                TaskId = 1,
                TaskName = "Project initiation",
                StartDate = new DateTime(2019, 04, 02),
                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child1 = new GanttDataSource()
            {
                TaskId = 2,
                TaskName = "Identify site location",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 70,
                ResourceId = new int[] { 1 },
            };
            GanttDataSource Child2 = new GanttDataSource()
            {
                TaskId = 3,
                TaskName = "Perform soil test",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                Notes = "Obtain an engineered soil test of lot where construction is planned.From an engineer or company specializing in soil testing",
                ResourceId = new int[] { 2 },
            };
            GanttDataSource Child3 = new GanttDataSource()
            {
                TaskId = 4,
                TaskName = "Soil test approval",
                Dependency = "3FS",
                Notes = "Measure the total property area alloted for construction",
                StartDate = new DateTime(2019, 04, 02),
                Duration = 4,
                Progress = 50,
                ResourceId = new int[] { 3 }
            };
            Record1.SubTasks.Add(Child1);
            Record1.SubTasks.Add(Child2);
            Record1.SubTasks.Add(Child3);

            GanttDataSource Record2 = new GanttDataSource()
            {
                TaskId = 5,
                TaskName = "Project estimation",
                StartDate = new DateTime(2019, 04, 02),

                EndDate = new DateTime(2019, 04, 21),
                SubTasks = new List<GanttDataSource>(),
            };
            GanttDataSource Child4 = new GanttDataSource()
            {
                TaskId = 6,
                TaskName = "Develop floor plan for estimation",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Progress = 70,
                ResourceId = new int[] { 4 },

            };
            GanttDataSource Child5 = new GanttDataSource()
            {
                TaskId = 7,
                TaskName = "List materials",
                StartDate = new DateTime(2019, 04, 04),
                Duration = 3,
                Dependency = "6FS",
                Progress = 50,
                ResourceId = new int[] { 3 },

            };
            Record2.SubTasks.Add(Child4);
            Record2.SubTasks.Add(Child5);

            GanttDataSourceCollection.Add(Record1);
            GanttDataSourceCollection.Add(Record2);

            return GanttDataSourceCollection;
        }
        public class GanttResources
        {
            public int ResourceId { get; set; }
            public string ResourceName { get; set; }
        }
        public class GanttDataSource
        {
            public int TaskId { get; set; }
            public string TaskName { get; set; }
            public string Dependency { get; set; }
            public string Notes { get; set; }
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public int? Duration { get; set; }
            public int Progress { get; set; }
            public List<GanttDataSource> SubTasks { get; set; }
            public int[] ResourceId { get; set; }

        }