PDF (Portable Document Format), as I said in many former articles, owns a lot of functions, such as it meets Legal Document Requirements, a “read only” document which cannot be altered without leaving an electronic footprint, compression of a Scanned Image into a PDF File is Sizeable and so on.
Actually, the character of PDF format is far more, and I personally think that whenever how good this format is, if it cannot be converted by other file formats, its function cannot be fully used. So the reasons why PDF format is such popular should not be only attributed to the characteristics, but also its applicability. That means PDF can be converted by many file formats, also can be converted to various formats.
Today, I am very glad to share an easy method to convert HTML to PDF with C#,V.NET by using Spire.PDF, which is a PDF creation component that enables your .NET/Silverlight applications to read, write and manipulate PDF documents without using Adobe Acrobat. Please follow the below steps.
Actually, the character of PDF format is far more, and I personally think that whenever how good this format is, if it cannot be converted by other file formats, its function cannot be fully used. So the reasons why PDF format is such popular should not be only attributed to the characteristics, but also its applicability. That means PDF can be converted by many file formats, also can be converted to various formats.
Today, I am very glad to share an easy method to convert HTML to PDF with C#,V.NET by using Spire.PDF, which is a PDF creation component that enables your .NET/Silverlight applications to read, write and manipulate PDF documents without using Adobe Acrobat. Please follow the below steps.
Procedure
Step1. Create a PDF Document.
Step2. Load the HTML file from the system.
I insert a url directly in the project, you also can load an existing HTML file that you want to convert.
Step3. Save the HTML file to PDF format, and launch it.
Main code:
Step2. Load the HTML file from the system.
I insert a url directly in the project, you also can load an existing HTML file that you want to convert.
Step3. Save the HTML file to PDF format, and launch it.
Main code:
Convert HTML to PDF with C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Pdf;
namespace HTML2PDF
{
class Program
{
[STAThread]//do not lose it if your project is not in single thread static void Main(string[] args)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
String url = http://www.e-iceblue.com/;
doc.LoadFromHTML(url, false, true, true);
//Save pdf file.
doc.SaveToFile("sample.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start("sample.pdf");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Pdf;
namespace HTML2PDF
{
class Program
{
[STAThread]//do not lose it if your project is not in single thread static void Main(string[] args)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
String url = http://www.e-iceblue.com/;
doc.LoadFromHTML(url, false, true, true);
//Save pdf file.
doc.SaveToFile("sample.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start("sample.pdf");
}
}
}
Convert HTML to PDF with VB.NET:
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Pdf
Namespace HTML2PDF
Class Program
<STAThread> _ Private Shared Sub Main(args As String())
'Create a pdf document.
Dim doc As New PdfDocument()
Dim url As [String] = http://www.e-iceblue.com/
doc.LoadFromHTML(url, False, True, True)
'Save pdf file.
doc.SaveToFile("sample.pdf")
doc.Close()
'Launching the Pdf file.
System.Diagnostics.Process.Start("sample.pdf")
End Sub
End Class
End Namespace
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Pdf
Namespace HTML2PDF
Class Program
<STAThread> _ Private Shared Sub Main(args As String())
'Create a pdf document.
Dim doc As New PdfDocument()
Dim url As [String] = http://www.e-iceblue.com/
doc.LoadFromHTML(url, False, True, True)
'Save pdf file.
doc.SaveToFile("sample.pdf")
doc.Close()
'Launching the Pdf file.
System.Diagnostics.Process.Start("sample.pdf")
End Sub
End Class
End Namespace
Preview
Besides converted from HTML, PDF can be converted by EXCEL, Word, Text, XML, Image and RTF. If you want to give it a try, you can Freely Download Spire. PDF
Source
Source
This comment has been removed by a blog administrator.
ReplyDeleteI have used Aspose.PDF for .NET to convert my HTML to PDF and vice versa and it has generated good results. So, Try it i hope you will found it useful also:
ReplyDeletehttp://www.aspose.com/.net/pdf-component.aspx
There is one more simple way of converting HTML to PDF and it is offered by pdfonline.com, the company also offers quality JPG to PDF converters free of cost.
ReplyDeleteThis is a good way to convert html into pdf file. This article helps me a lot to see the whole picture. I just tried to develop a C# .NET windows application for html to pdf conversion.
ReplyDeleteHow to convert html to pdf using c#? iDiTect.Converter provides simple use tool, support html5 and css3
ReplyDelete