大家好,我在web-service http://www.hiqpdf.com/demo/ConvertHtmlToPdf.aspx中编写了以下代码
[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();
}
我添加了这个作为参考在我的项目从我的本地主机,但当试图转换我得到一个异常作为Client found response content type of 'application/pdf', but expected 'text/xml'. The request failed with the error message:
可以有人帮助我。
".ToString()"-没有必要
?