0

こんにちは、私はこのコードを Web サービス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:誰かが助けてくれます。

4

1 に答える 1

0

".ToString()" - 必要ありません

それは...ですか?

于 2013-01-05T08:23:47.383 に答える