我真誠地懇求您的耐心和理解。我該如何將其遷移到Web服務
下面的代碼通過提供一個框和一個按鈕來工作。
該框包含一個URL和按鈕簡單地說,轉換。
如果您點擊轉換按鈕,它會打開url的內容並將其轉換爲pdf。
This works great。
不幸的是,他們希望將其翻譯爲Web服務,以便其他應用程序可以通過提供2個輸入參數,url和文檔名稱來執行類似的任務。
我已經看過創建和使用Web服務的幾個例子,雖然它們看起來相當簡單,但是編寫代碼的方式使得翻譯極其困難。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EO.Pdf;
public partial class HtmlToPdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnConvert_Click(object sender, EventArgs e)
{
//Create a PdfDocument object and convert
//the Url into the PdfDocument object
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertUrl(txtUrl.Text, doc);
//Setup HttpResponse headers
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearHeaders();
response.ContentType = "application/pdf";
//Send the PdfDocument to the client
doc.Save(response.OutputStream);
Response.End();
}
}
如果您可以提供足夠的幫助,我真的很感激。
http://whathaveyoutried.com? – 2012-07-12 21:02:33