I am trying to export a page to PDF and when the code reaches the page render section, I am getting an error for the RadAjaxManager.
I have several RadHtmlCharts on the page and am trying to export them to a PDF. Here is a snippet of the control:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadHtmlChart ChartTitle-Text="Overall" runat="server" ID="rcOverall" Width="600px" Height="400px" Skin="Bootstrap" DataSourceID="sqlOverall" RegisterWithScriptManager="false">
<PlotArea>
<Series>
<telerik:BarSeries Name="BarSeries1" DataFieldY="points">
<LabelsAppearance Visible="false" />
<TooltipsAppearance Visible="false" />
</telerik:BarSeries>
</Series>
<XAxis DataLabelsField="Section" >
<TitleAppearance Text="Section">
<TextStyle FontSize="12" Bold="true" />
</TitleAppearance>
</XAxis>
<YAxis Visible="false" MinValue="0" MaxValue="27" Step="3">
<TitleAppearance Text="Total Mark">
<TextStyle FontSize="12" Bold="true" />
</TitleAppearance>
</YAxis>
</PlotArea>
<Legend>
<Appearance Visible="false" />
</Legend>
</telerik:RadHtmlChart>
The code to export:
Protected Sub ExportButton_OnClick(sender As Object, e As EventArgs) Handles ExportButton.Click
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=Image.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
Dim srdr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 15.0F, 15.0F, 75.0F, 0.2F)
Dim hparse As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
hparse.Parse(srdr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
End Sub