2
votes

how to export crystal report to pdf without temp file programmatically in asp net from server to end user. If we remove write access of temp folder , then it will cause error.Our admin not giving access to it.Is that any option to export crystal report to pdf for end user. Please suggest.

        reportDocument.Load(this.MapPath("xyz.rpt"));
        reportDocument.Database.Tables[0].SetDataSource(dsReport.Tables[0]);           
        rptviewer.ReportSource = Salary_reportDocument;
        rptviewer.Visible = true;
        rptviewer.DataBind();
        reportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "XYZReport");
1
I want to know if you find methods to avoid save the temp pdfs, that will waste a lot of useless space. Thanks.fish-404
I find the temp files seems mandatory. And I add a logic to delete them.fish-404

1 Answers

1
votes

Something like this

 {
        ExportOptions CrExportOptions ;
        DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
        PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
        CrDiskFileDestinationOptions.DiskFileName = "c:\\csharp.net-informations.pdf";
        CrExportOptions = cryRpt.ExportOptions;
        {
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
            CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
            CrExportOptions.FormatOptions = CrFormatTypeOptions;
        }
        cryRpt.Export();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }