I sincerely beg for your patience and understanding.
The below code works by providing a box and a button.
The box contains a url and the button simply says, Convert.
If you click the convert button, it opens the contents of the url and converts it to pdf.
This works great.
Unfortunately, they want it translated as web service so other apps can use it to perform similar task by providing 2 input params, url and document name.
I have looked at several examples of creating and consuming web services, while they seem fairly simple, the way this code is written makes it extemely difficult to translate.
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();
}
}
If you could be kind enough to assist, I am truly grateful.
The most basic form of a web service is to use an HTTP handler:
and then:
http://example.com/HtmlToPdfHandler.ashx?url=someurl&name=some_doc_nameFor more advanced services you might take a look at
WCFor the upcomingWeb API.