Skip to content

Commit 03f8ca6

Browse files
908232: Added PDF UG
1 parent 59f7640 commit 03f8ca6

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

blazor/gantt-chart/template-pdf-export.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ documentation: ug
1212

1313
The Gantt chart export functionality allows you to export both column and header templates to a PDF document. These templates can include various customizations such as images, formatted text, and custom cell styles within the header and columns.
1414

15-
## Exporting with column header template
15+
## Exporting with column template
1616

17-
The PDF export functionality allows for customization of Gantt chart columns header, including the inclusion of images, background colors, and custom text. This can be achieved using the [PdfColumnHeaderQueryCellInfo](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfColumnHeaderQueryCellInfo) event. By handling this event, you can define how each column header in the Gantt chart is rendered in the exported PDF.
17+
The PDF export functionality allows for advanced customization of Gantt chart columns, including the inclusion of images, background colors, and custom text. This can be achieved using the [PdfQueryCellInfo](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfQueryCellInfo) event. By handling this event, you can define how individual cells in the Gantt chart are rendered in the exported PDF.
1818

19-
The following code snippet demonstrates how to use the `PdfColumnHeaderQueryCellInfo` event to export Gantt columns header with custom text and image on the task name column header,
19+
The following code snippet demonstrates how to use the `PdfQueryCellInfo` event to export Gantt columns with custom text and different cell background colors,
2020

21-
``` cshtml
21+
```cshtml
2222
@using Syncfusion.Blazor.Gantt
2323
@using Syncfusion.Blazor.Grids
2424
@using Syncfusion.Blazor.Navigations
2525
@using Syncfusion.PdfExport
26-
@using System.Net
2726
2827
<SfGantt @ref="Gantt" ID="GanttExport" DataSource="@TaskCollection" Height="450px" Width="900px" AllowPdfExport="true" Toolbar="toolbarItem">
2928
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Dependency="Predecessor"
@@ -37,17 +36,13 @@ The following code snippet demonstrates how to use the `PdfColumnHeaderQueryCell
3736
<GanttColumn Field="Duration" HeaderText="Duration"></GanttColumn>
3837
<GanttColumn Field="Predecessor" HeaderText="Dependency"></GanttColumn>
3938
</GanttColumns>
40-
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfColumnHeaderQueryCellInfo="PdfHeaderQueryCellInfoHandler" TValue="TaskData"></GanttEvents>
39+
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfQueryCellInfo="PdfQueryCellInfoHandler" TValue="TaskData"></GanttEvents>
4140
</SfGantt>
4241
4342
@code {
4443
private List<TaskData> TaskCollection { get; set; }
4544
private SfGantt<TaskData> Gantt;
4645
private List<object> toolbarItem = new List<Object>() { new ToolbarItem() { Text = "PDF Export", TooltipText = "PDF Export", Id = "PdfExport", PrefixIcon = "e-pdfexport" } };
47-
private static WebClient webClient = new WebClient();
48-
private static byte[] imageBytes = webClient.DownloadData("https://cdn.syncfusion.com/content/images/landing-page/yes.png");
49-
private static MemoryStream imageStream = new MemoryStream(imageBytes);
50-
public static PdfImage image = PdfImage.FromStream(imageStream);
5146
protected override void OnInitialized()
5247
{
5348
this.TaskCollection = GetTaskCollection();
@@ -59,12 +54,30 @@ The following code snippet demonstrates how to use the `PdfColumnHeaderQueryCell
5954
await Gantt.ExportToPdfAsync();
6055
}
6156
}
62-
public void PdfHeaderQueryCellInfoHandler(Syncfusion.Blazor.Gantt.PdfHeaderQueryCellInfoEventArgs args)
57+
public void PdfQueryCellInfoHandler(Syncfusion.Blazor.Gantt.PdfQueryCellInfoEventArgs<TaskData> args)
6358
{
64-
if (args.Column.Field == "TaskName")
59+
if (args.Column.Field == "TaskName" && args.Data.TaskId == 5)
6560
{
6661
args.Cell.Value = "Updated Value";
67-
args.Cell.CellStyle = new PdfElementStyle() { Image = image};
62+
args.Cell.CellStyle = new PdfElementStyle()
63+
{
64+
FillBackgroundColor = "Orange",
65+
Font = new PdfGridFont()
66+
{
67+
FontFamily = PdfFontFamily.TimesRoman,
68+
FontSize = 6,
69+
FontStyle = PdfFontStyle.Italic,
70+
IsTrueType = false,
71+
TextColor = "Red",
72+
TextHighlightColor = "Green"
73+
}
74+
};
75+
args.Cell.CellStyle.Border = new PdfBorder()
76+
{
77+
Color = "Black",
78+
DashStyle = Syncfusion.Blazor.Grids.PdfDashStyle.Dot,
79+
Width = 0.1
80+
};
6881
}
6982
}
7083
public class TaskData
@@ -97,17 +110,18 @@ The following code snippet demonstrates how to use the `PdfColumnHeaderQueryCell
97110
}
98111
```
99112

100-
## Exporting with column template
113+
## Exporting with column header template
101114

102-
The PDF export functionality allows for advanced customization of Gantt chart columns, including the inclusion of images, background colors, and custom text. This can be achieved using the [PdfQueryCellInfo](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfQueryCellInfo) event. By handling this event, you can define how individual cells in the Gantt chart are rendered in the exported PDF.
115+
The PDF export functionality allows for customization of Gantt chart columns header, including the inclusion of images, background colors, and custom text. This can be achieved using the [PdfColumnHeaderQueryCellInfo](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Gantt.GanttEvents-1.html#Syncfusion_Blazor_Gantt_GanttEvents_1_PdfColumnHeaderQueryCellInfo) event. By handling this event, you can define how each column header in the Gantt chart is rendered in the exported PDF.
103116

104-
The following code snippet demonstrates how to use the `PdfQueryCellInfo` event to export Gantt columns with custom text and different cell background colors,
117+
The following code snippet demonstrates how to use the `PdfColumnHeaderQueryCellInfo` event to export Gantt columns header with custom text and image on the task name column header,
105118

106-
```cshtml
119+
``` cshtml
107120
@using Syncfusion.Blazor.Gantt
108121
@using Syncfusion.Blazor.Grids
109122
@using Syncfusion.Blazor.Navigations
110123
@using Syncfusion.PdfExport
124+
@using System.Net
111125
112126
<SfGantt @ref="Gantt" ID="GanttExport" DataSource="@TaskCollection" Height="450px" Width="900px" AllowPdfExport="true" Toolbar="toolbarItem">
113127
<GanttTaskFields Id="TaskId" Name="TaskName" StartDate="StartDate" EndDate="EndDate" Dependency="Predecessor"
@@ -121,13 +135,17 @@ The following code snippet demonstrates how to use the `PdfQueryCellInfo` event
121135
<GanttColumn Field="Duration" HeaderText="Duration"></GanttColumn>
122136
<GanttColumn Field="Predecessor" HeaderText="Dependency"></GanttColumn>
123137
</GanttColumns>
124-
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfQueryCellInfo="PdfQueryCellInfoHandler" TValue="TaskData"></GanttEvents>
138+
<GanttEvents OnToolbarClick="ToolbarClickHandler" PdfColumnHeaderQueryCellInfo="PdfHeaderQueryCellInfoHandler" TValue="TaskData"></GanttEvents>
125139
</SfGantt>
126140
127141
@code {
128142
private List<TaskData> TaskCollection { get; set; }
129143
private SfGantt<TaskData> Gantt;
130144
private List<object> toolbarItem = new List<Object>() { new ToolbarItem() { Text = "PDF Export", TooltipText = "PDF Export", Id = "PdfExport", PrefixIcon = "e-pdfexport" } };
145+
private static WebClient webClient = new WebClient();
146+
private static byte[] imageBytes = webClient.DownloadData("https://cdn.syncfusion.com/content/images/landing-page/yes.png");
147+
private static MemoryStream imageStream = new MemoryStream(imageBytes);
148+
public static PdfImage image = PdfImage.FromStream(imageStream);
131149
protected override void OnInitialized()
132150
{
133151
this.TaskCollection = GetTaskCollection();
@@ -139,30 +157,12 @@ The following code snippet demonstrates how to use the `PdfQueryCellInfo` event
139157
await Gantt.ExportToPdfAsync();
140158
}
141159
}
142-
public void PdfQueryCellInfoHandler(Syncfusion.Blazor.Gantt.PdfQueryCellInfoEventArgs<TaskData> args)
160+
public void PdfHeaderQueryCellInfoHandler(Syncfusion.Blazor.Gantt.PdfHeaderQueryCellInfoEventArgs args)
143161
{
144-
if (args.Column.Field == "TaskName" && args.Data.TaskId == 5)
162+
if (args.Column.Field == "TaskName")
145163
{
146164
args.Cell.Value = "Updated Value";
147-
args.Cell.CellStyle = new PdfElementStyle()
148-
{
149-
FillBackgroundColor = "Orange",
150-
Font = new PdfGridFont()
151-
{
152-
FontFamily = PdfFontFamily.TimesRoman,
153-
FontSize = 6,
154-
FontStyle = PdfFontStyle.Italic,
155-
IsTrueType = false,
156-
TextColor = "Red",
157-
TextHighlightColor = "Green"
158-
}
159-
};
160-
args.Cell.CellStyle.Border = new PdfBorder()
161-
{
162-
Color = "Black",
163-
DashStyle = Syncfusion.Blazor.Grids.PdfDashStyle.Dot,
164-
Width = 0.1
165-
};
165+
args.Cell.CellStyle = new PdfElementStyle() { Image = image};
166166
}
167167
}
168168
public class TaskData
@@ -194,4 +194,3 @@ The following code snippet demonstrates how to use the `PdfQueryCellInfo` event
194194
}
195195
}
196196
```
197-

0 commit comments

Comments
 (0)