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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

117727 Dec 4,2014 04:32 AM UTC Dec 17,2014 04:15 AM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: PDF
Amit Kumar
Asked On December 4, 2014 04:32 AM UTC

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


KarthikeyanC [Syncfusion]
Replied On 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

 


Nishant Garg
Replied On 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



KarthikeyanC [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;