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 786465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:02:44+00:00 2026-05-14T21:02:44+00:00

Background: I couldn’t find any decent free HTML to PDF conversion utilities in C#.

  • 0

Background:

I couldn’t find any decent free HTML to PDF conversion utilities in C#. There are 100s of them for PHP with extensive documentation, support, and CSS support. So I am using html2ps and html2pdf (php).

I have PHP 5.2 installed on IIS7 and its working beautifully to create PDFs.

I have the following in getPDF.aspx

<!-- Output the header -->
<DM:header runat="server" ID="header" />

<asp:Placeholder id="content" runat="server" />

<!-- Output the footer -->
<DM:footer runat="server" ID="footer" />

and in getPDF.aspx.cs:

protected void Page_Load(object sender, EventArgs e){
    // AddContentControl simples adds a controls to the content Placeholder.

    AddContentControl("controls/page1.ascx");
    AddContentControl("controls/page2.ascx");
    AddContentControl("controls/page3.ascx");
}

and in generatePDF.php:

<?php
    /* ... includes and stuff here ... */

    $data = "THE HTML GOES HERE!";
    // creates the PDF from the $data and Outputs the created file.
    convert_to_pdf($data);
?>

—
getPDF.aspx works perfectly…except the output is HTML.

So how can I get getPDF.aspx to output its HTML as PDF generated by generatePDF.php?

  • 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-05-14T21:02:45+00:00Added an answer on May 14, 2026 at 9:02 pm

    I’d suggest looking into iTextSharp a free .NET port of iText (Java-Based PDF Lib) Then you can cut php right out of the equation.

    For converting HTML using iTextSharp Please See This Post (Found using google)

    Update

    Rendering Partials in ASP.NET Forms (i.e. rendering a single control, or a page with controls) You create a System.Web.Page to drive the event structure.

    Here’s a code-sample I adapted for a project of mine:

        public static string Render<T>(string controlPath, Action<T> initControlCallback) where T : Control
        {
            Page renderPage = new Page();
    
            // Load the control & add to page
            T control = (T) renderPage.LoadControl(controlPath);
            renderPage.Controls.Add(control);
    
            // Initialize the control
            initControlCallback.Invoke(control);
            renderPage.DataBind();
    
            StringWriter result = new StringWriter();
            HttpContext.Current.Server.Execute(renderPage, result, false); // Render Process
            return result.ToString();
        }
    

    It’s called like this:

    MyHelper.Render<MyControlBase>("~/SomePath/SomeControl.ascx", p => { p.SomeProperty = "Initializer" });
    

    This code may not be what you need, but as you can see you can render a result using the Server / Page objects, this may be the route you should take.

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

Sidebar

Related Questions

Background information: I've searched stackoverflow for a specific solution and couldn't find one that
I find the background transition of the jQuery Colorbox very 'hard'. I couldn't find
I couldn't find any good application for streaming MP3s from a URL that can
I couldn't find a open source PHP Script that allow me to choose the
I couldn't find any article that would help me. I want to make an
I ran out of ideas and couldn't find any reference about it so here
I just started learning swing, and couldn't find any clear instructions for this: I'd
I'm sure it has been asked before (but couldn't find any resources that solves
I have searched everywhere but I couldn't find my answer, is there a way
Background: What I need to accomplish is to remove any records in a collection

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.