'Error in exporting fastreport to pdf on asp.net c#

I want to export .frx report that designed by FastReport as an pdf or excel file on a c# web form application like code below:

    public static bool ShowReport(string ReportFileName, DataTable ReportData, string DBObjectName, string ExportType, out string Message, params string[] AdditionalParams)
    {
        FastReport.Utils.Config.WebMode = true;
        string ReportFile = HttpContext.Current.Server.MapPath(WPResources.ReportsRoot) + string.Format("{0}_{1}.frx", ReportFileName, ExportType.ToUpper());

        FastReport.Report objReport = new FastReport.Report();
        objReport.Load(ReportFile);
        objReport.Dictionary.Connections.Clear();
        System.Data.DataTable resultTable = new DataTable();

        objReport.RegisterData(ReportData, DBObjectName);
        objReport.GetDataSource(DBObjectName).Enabled = true;


        int ParamsCount = AdditionalParams.Length;
        if ((ParamsCount % 2) != 0)
            ParamsCount--;

        for (int i = 0; i < ParamsCount; i += 2)
        {
            var DynamicControl = (objReport.FindObject(AdditionalParams[i]) as FastReport.TextObject);
            if (DynamicControl != null)
            {
                DynamicControl.Text = AdditionalParams[i + 1];
                DynamicControl.Visible = !string.IsNullOrEmpty(AdditionalParams[i + 1]);
            }
        }

        (objReport.FindObject("rptData") as FastReport.DataBand).DataSource = objReport.GetDataSource(DBObjectName);

        string fileName = Path.GetFileNameWithoutExtension(ReportFile);
        fileName += "_" + WPFarsiDate.Today.ToString().Replace("/", ".") + "_" +
            DateTime.Now.Hour.ToString() + "." +
            DateTime.Now.Minute.ToString();

        if (ExportType == "Excel")
        {
            using (MemoryStream objMemoryStream = new MemoryStream())
            {
                objReport.Prepare(false);
                FastReport.Export.OoXML.Excel2007Export objExcel2007Export = new FastReport.Export.OoXML.Excel2007Export();
                objExcel2007Export.OpenAfterExport = false;
                objExcel2007Export.Export(objReport, objMemoryStream);
                byte[] buffer = objMemoryStream.ToArray();
                HttpContext.Current.Response.ClearHeaders();
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
                HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("inline;filename={0}.xlsx", fileName));
                HttpContext.Current.Response.BinaryWrite(buffer);
                HttpContext.Current.Response.End();
            }
        }
        else if (ExportType == "Pdf")
        {
            using (MemoryStream objMemoryStream = new MemoryStream())
            {
                objReport.Prepare(false);
                FastReport.Export.Pdf.PDFExport objPDFExport = new FastReport.Export.Pdf.PDFExport();
                objPDFExport.EmbeddingFonts = true;
                objPDFExport.OpenAfterExport = false;
                objPDFExport.Export(objReport, objMemoryStream);
                byte[] buffer = objMemoryStream.ToArray();
                HttpContext.Current.Response.ClearHeaders();
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.ContentType = "application/octet-stream";
                HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf", fileName));
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.BinaryWrite(buffer);
                HttpContext.Current.Response.End();

            }
        }

        Message = string.Empty;
        return true;
    }

When I export it to excel, that is no any matter and it will be done successfuly. But when I export it to pdf, I get this error:

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

It should be noted that mentioned error just occurs in the main server and the job can be done successfully in localhost. It would be very helpful if someone could explain solution for this problem.



Solution 1:[1]

After much effort, I find solution for the problem. Fonts used in .frx files weren't the windows/fonts folder. So I copied the metioned fonts there and it worked properly.

Solution 2:[2]

Did you tried debug it? Which line throws this error? Did you see any dialog windows in desktop version? Try to avoid it.

Solution 3:[3]

I use fast report in one of my ASP.Net Web Forms projects and I see this exception when I try to export PDF. I have this tag in .aspx file:

<fastreport:webreport id="remainedLeave" runat="server" 
Width="100%" Height="100%"></fastreport:webreport>

Adding this property to fast report tag solved my problem:

PdfEmbeddingFonts="false"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Reza Amini
Solution 2 xaml
Solution 3 Abolfazl Davoodi Shandiz