We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PDF is not generated in IE while it is generated in Firefox

Hi,
I am creating the PDF using the Syncfusion Dll. First i create a word document then i convert it to the PDF using the below code.

DocToPDFConverter converter = new DocToPDFConverter();
 string fileName = @"RFPQuoteSlip_" + UserContext.TenantName.ToString() + ".pdf";
fileName = Regex.Replace(fileName, @"[\[,:=\]?^\/|]", string.Empty);
 PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

 pdfDoc.Save(fileName, Response, HttpReadType.Open);

In pdfDoc.Save method i am getting the Thread.AbortInternal execption  but pdf is generated in my local machine in all the browser. 
But i run the same code in the prod environment then i am getting the same Thread.AbortInternal execption and pdf is generated in firefox but it is not generated in IE8. please help me on that how can i solve the problem?

Thanks
Amit Kumar


3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team December 5, 2014 12:21 PM UTC

Hi Amit,

Thank you for using Syncfusion Products.

We are internally using httpresponse to save or open the document in browser as follow

 

if (fileName == null)

{

throw new ArgumentNullException("fileName");

}

if (response == null)

{

throw new ArgumentNullException("response");

}

response.ClearContent();

response.Expires = 0;

response.Buffer = true;

string disposition = "content-disposition";

if (type == HttpReadType.Open)

{

response.AddHeader(disposition, "inline; filename=" + fileName);

}

else if (type == HttpReadType.Save)

{

response.AddHeader(disposition, "attachment; filename=" + fileName);

}

response.AddHeader("Content-Type", "application/pdf");

response.Clear();

Save(response.OutputStream);

if (PdfDocumentBase.IsSecurityGranted)

{

response.Flush();

response.End();

}

else

{

response.End();

}

 

So the thread exception occurs when end the response. But is not an issue, it is an actual behaviour you can refer the following link

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx

when end response it tries to raise the thredabortexception so it is not an issue it an actual behavior of Microsoft “HttpResponse.End”.

 

Please let us know if you need any further assistance.

Regards,

Karthikeyan.C

 



NG Nishant Garg replied to Karthikeyan Chandrasekar December 15, 2014 03:07 PM UTC

Hi Amit,

Thank you for using Syncfusion Products.

We are internally using httpresponse to save or open the document in browser as follow

 

if (fileName == null)

{

throw new ArgumentNullException("fileName");

}

if (response == null)

{

throw new ArgumentNullException("response");

}

response.ClearContent();

response.Expires = 0;

response.Buffer = true;

string disposition = "content-disposition";

if (type == HttpReadType.Open)

{

response.AddHeader(disposition, "inline; filename=" + fileName);

}

else if (type == HttpReadType.Save)

{

response.AddHeader(disposition, "attachment; filename=" + fileName);

}

response.AddHeader("Content-Type", "application/pdf");

response.Clear();

Save(response.OutputStream);

if (PdfDocumentBase.IsSecurityGranted)

{

response.Flush();

response.End();

}

else

{

response.End();

}

 

So the thread exception occurs when end the response. But is not an issue, it is an actual behaviour you can refer the following link

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx

when end response it tries to raise the thredabortexception so it is not an issue it an actual behavior of Microsoft “HttpResponse.End”.

 

Please let us know if you need any further assistance.

Regards,

Karthikeyan.C

 


Hi Karthikeyan,

I have done the changes that you had suggested, But still I am facing the same issue. And it is working fine on my local machine but on server report is not getting generated. It may be the problem of compiled code because server use compiled code. 

WordDocument wordDoc = new WordDocument();
rfpWordReports = new RFPQuoteSlipReports();
rfpWordReports.GenerateReports(orm, wordDoc);

DocToPDFConverter converter = new DocToPDFConverter();
string fileName = @"RFPQuoteSlip_" + UserContext.TenantName.ToString() + ".pdf";
PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

pdfDoc.Save(fileName, Response, HttpReadType.Save);

After change the "HttpReadType.Open" with "HttpReadType.Save". Problem is being still persists. 

So please help us ASAP...

Environment Detail: 

Server 2008 R2 for web

Windows Server 2012 for SQL Server 


Thanks
Nishant Garg




KC Karthikeyan Chandrasekar Syncfusion Team December 17, 2014 04:15 AM UTC

Hi Nishant,

Please use the below method to save the PDF document to avoid this exception.

 

        protected void PdfSave(PdfDocument pdfDoc, HttpResponse response)

        {

            //File name to save as PDF

            string fileName = "Sample.pdf";

 

            if (fileName == null)

            {

                throw new ArgumentNullException("fileName");

            }

            if (response == null)

            {

                throw new ArgumentNullException("response");

            }

            response.ClearContent();

            response.Expires = 0;

            response.Buffer = true;

            string disposition = "content-disposition";

           

            //To open within Browser

            if (CheckBox1.Checked)

            {

                response.AddHeader(disposition, "inline; filename=" + fileName);

            }

            //To download as attachment

            else

            {

                response.AddHeader(disposition, "attachment; filename=" + fileName);

            }

            response.AddHeader("Content-Type", "application/pdf");

            response.Clear();

 

            //Saving the PDF document

            pdfDoc.Save(response.OutputStream);

            response.Flush();

        }

Regards,

Karthikeyan.C


Loader.
Live Chat Icon For mobile
Up arrow icon