Click here to Skip to main content
11,412,834 members (73,443 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi,
I need to convert Html file into PDF file using c#

please, help ASAP.
Thank you.
Posted 20-Jul-12 3:22am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can convert html page to pdf using wkhtmltopdf opensource library.

here is the implementation
Html to PDF in c#
  Permalink  
Comments
MarinaE at 1-Apr-15 3:31am
   
Can wkhtmltopdf use HTML string content or HTML file's path instead of URL?
Currently I'm using an alternative approach from this article about converting a HTML file into a PDF file from C#. It can receive the input from both path and URL.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Use itextsharp library to convert simple html to pdf.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There are many solutions can convert html to PDF. However they have different effects. For some converters, they are quick and free, but many can export only simple html webpage without dynamic images, while for other non converters, such as iTexsharp or other libraries, they can export complex webpage to PDF. As far as I know, the simplest solution that I ever seen is the code as below:

namespace htmltopdf
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            String url = “Http://apple.com/”;
            doc.LoadFromHTML(url, false, true, true);
            doc.SaveToFile(“webpageaspdf.pdf”);
            doc.Close();
            System.Diagnostics.Process.Start(“webpageaspdf.pdf”);
        }
    }
}

You can see details about which tool is best suitable for you:
Save Webpage as PDF[^]

I belive this works only for Windows 8.1.
  Permalink  
v2
Comments
Pro Idiot at 28-Nov-12 22:54pm
   
Vote of 5 .
Lacy00 at 28-Nov-12 22:57pm
   
Thanks!
nika2008 at 17-Mar-13 18:55pm
   
simple way, best way +5
swift.D at 23-Oct-14 5:28am
   
Will this need a dll?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 19

If you are looking for a free .NET component, take a look at SelectPdf[^]. The community edition is free to use.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 16

This project uses an HTML to PDF exe from ESP. Please read the GNU license agreement for more information. HTMLDOC is a desktop application to create PDF documents from a HTML page. I wrote some code to use it from a web application. The best used is from a Web Report to add a PRINT to PDF button to use the C# class.
Code see here:
Generate PDF documents from a HTML page using ASP.NET[^]


And with the help of third party software for .net ,you can realize it too.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 414
1 Sascha Lefévre 200
2 Maciej Los 155
3 ProgramFOX 130
4 Sergey Alexandrovich Kryukov 110
0 Sergey Alexandrovich Kryukov 9,025
1 OriginalGriff 7,317
2 Maciej Los 3,570
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.1 | Last Updated 8 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100