PdfExport error in EDGE/Chrome when file name has COMMA

Posted by: debasis.dalal on 26 July 2021, 6:06 pm EST

  • Posted 26 July 2021, 6:06 pm EST

    I used ActiveReport 6.2.3681.0 in a ASP.Net/C# Web application. For PDF export I used following code :
    DataDynamics.ActiveReports.Export.Pdf.PdfExport pdfExportObject = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();

    pdfExportObject.ExportBookmarks = true;
    pdfExportObject.Options.Title = exportFileName;

    pdfExportObject.Export(DataDynamics.ActiveReports.ActiveReport.Document, exportPath + "\\" + exportFileName);

    It is working fine in Internet Explorer but it is throwing error in EDGE/CHROME when the file name has COMMA.
    I found this is a known issue specific to Chrome/EDGE specifically related to the Content-Disposition header. This is caused by the fact that chrome/edge doesn't properly handle escaping of commas while Firefox, IE, etc. do.

    In order to fix this we need to wrap the file name in response header with "Double Quotes". E.g.-
    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + saveNm + ".pdf\"");

    MY QUESTION IS, HOW SHOULD I DO THIS IN DataDynamics.ActiveReports.Export.Pdf.PdfExport ?
  • Replied 27 July 2021, 11:52 pm EST

    Please try exporting the Pdf to a stream instead of a file - https://help.grapecity.com/activereports/webhelp/Legacy/ActiveReports6/webframe.html

    Then you can download this stream as Pdf through the Response object and add the Header as required.
  • Replied 28 July 2021, 2:48 am EST

    Thanks for your reply. I tried DataDynamics.ActiveReports.ActiveReport.Document to convert stream of bytes[], but that is not working. Probably that is not properly being parsed.
    Is there any code snippet that exports the pdf to a stream?
  • Marked as Answer

    Replied 28 July 2021, 10:44 pm EST

    Here is a code snippet:

    private void btnExport_Click(object sender, System.EventArgs e)
    rptDataDynamics rpt = new rptDataDynamics();
    DataDynamics.ActiveReports.Export.Pdf.PdfExport p = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();
    this.arv.Document = rpt.Document;
    MemoryStream ms = new MemoryStream();
    p.Export(rpt.Document, ms);
  • Replied 28 July 2021, 11:08 pm EST

    Thank you so much Michael...I resolved it in a different way....but surely will give your solution a try.
  • Replied 7 September 2021, 6:45 pm EST

    Michael, thank you very much... I came up with an alternative approach, but I'll definitely give yours a shot. https://cookieclicker2.io
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels