0

Hi all I have written this code in a web-service http://www.hiqpdf.com/demo/ConvertHtmlToPdf.aspx as follows

[WebMethod]
    public void convert(string strURL)
    {
        HtmlToPdf htmlToPdfConverter = new HtmlToPdf();
        string url = strURL;
        byte[] pdfBuffer = htmlToPdfConverter.ConvertUrlToMemory(url);

        HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

        // let the browser know how to open the PDF document, attachment or inline, and the file name
        HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=ConvertHtmlPart.pdf; size={0}",
                    pdfBuffer.Length.ToString()));

        // write the PDF buffer to HTTP response
        HttpContext.Current.Response.BinaryWrite(pdfBuffer);

        // call End() method of HTTP response to stop ASP.NET page processing
        HttpContext.Current.Response.End();
    }

I added this as a reference in my project from my local host but when trying to convert I am getting an exception as Client found response content type of 'application/pdf', but expected 'text/xml'. The request failed with the error message: can some one help me.

Developer
  • 8,390
  • 41
  • 129
  • 238

1 Answers1

0

".ToString()" - it is not necessary

is it?