Hi,
I am exporting a RadGrid and directing the output to a server file in the OnGridExporting event.
The file is successfully created and if I open it with NotePad the file does in fact begin with %PDF-.
But when I attempt to open it in my browser, I get the error you see in the title of this thread.
I cannot open it directly with Adobe Reader either.
I used the technique identified in this thread to create the file (although it was for an xls file):
Here are the relevant code pieces:
Declaration:
Code that performs the export:
Code that creates the file:
What am I doing wrong?
Thanks in advance for any suggestions.
Jim
I am exporting a RadGrid and directing the output to a server file in the OnGridExporting event.
The file is successfully created and if I open it with NotePad the file does in fact begin with %PDF-.
But when I attempt to open it in my browser, I get the error you see in the title of this thread.
I cannot open it directly with Adobe Reader either.
I used the technique identified in this thread to create the file (although it was for an xls file):
Here are the relevant code pieces:
Declaration:
<telerik:RadGrid ID="grdRACI" Skin="Outlook" GridLines="Both" runat="server" AutoGenerateColumns="true" OnGridExporting="grdRACI_Exporting" OnItemDataBound="grdRACI_ItemDataBound" OnColumnCreated="grdRACI_ColumnCreated" > <MasterTableView NoMasterRecordsText="No responsibilities defined" NoDetailRecordsText="No responsibilities defined"> </MasterTableView> <ClientSettings> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> <Resizing AllowColumnResize="true" AllowResizeToFit="true" ResizeGridOnColumnResize="true" /> </ClientSettings> <ExportSettings OpenInNewWindow="false" HideStructureColumns="true"> </ExportSettings> </telerik:RadGrid>Code that performs the export:
...grdRACI.ExportSettings.Pdf.PageTitle = "RACI Chart For - " + Session["currentProcessName"].ToString(); grdRACI.ExportSettings.Pdf.DefaultFontFamily = "Arial Narrow"; grdRACI.ExportSettings.Pdf.PageLeftMargin = Unit.Parse("0.25in"); grdRACI.ExportSettings.Pdf.PageRightMargin = Unit.Parse("0.25in"); Session["RACI_PDF_Filename"] = "ExternalDocs/" + "RACI_Chart_ For_" + Session["currentProcessName"].ToString() + " - " + DateTime.Now.ToString("ddMMMyyyy-HHmm") + ".pdf"; grdRACI.MasterTableView.ExportToPdf();...Code that creates the file:
protected void grdRACI_Exporting(object source, GridExportingArgs e) { string path = Server.MapPath("~/" + Session["RACI_PDF_Filename"].ToString()); using (FileStream fs = File.Create(path)) { Byte[] info = System.Text.Encoding.Unicode.GetBytes(e.ExportOutput); fs.Write(info, 0, info.Length); } Response.Redirect(Request.Url.ToString()); }What am I doing wrong?
Thanks in advance for any suggestions.
Jim