Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:08:38+00:00 2026-06-07T10:08:38+00:00

I sincerely beg for your patience and understanding. The below code works by providing

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:08:42+00:00Added an answer on June 7, 2026 at 10:08 am

    The most basic form of a web service is to use an HTTP handler:

    public class HtmlToPdfHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string url = context.Request["url"];
            string documentName = context.Request["name"];
    
            PdfDocument doc = new PdfDocument();
            HtmlToPdf.ConvertUrl(url, doc);
            context.Response.ContentType = "application/pdf";
            doc.Save(context.Response.OutputStream);
        }
    
        public bool IsReusable
        {
            get { return false; }
        }
    }
    

    and then: http://example.com/HtmlToPdfHandler.ashx?url=someurl&name=some_doc_name

    For more advanced services you might take a look at WCF or the upcoming Web API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to achieve the following and would sincerely appreciate your help. onclick
Thanks for looking. All sincerely helpful answers are voted up. I use a password
i wanna ask you about your opinion: I work as independent software developer, and
The following code I am using to update a textarea dynamically without reloading the
I sincerely apologize if this is a noob question, however I am failrly new
Although I'm sincerely hoping there aren't going to be any Google+ apps similar to
Thanks for looking, all sincerely helpful answers are up-voted. I have some date input
If this has been asked before I sincerely apologize. After around half an hour
Disclaimer : My apologies for all the text below (for a single simple question),
I'm trying to find a way to automate some exception logging code to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.