Question:I want to convert an HTML file to PDF by using C#. I've searched website here and other sites. I am surprised. Because I couldn't find any easy way.Could you help me with to do that? Thanks VeryPDF in advance.
Answer: According to your needs, maybe you can have a free trial of this software: VeryPDF HTML Converter Command Line. By this software, you can convert HTML file to PDF by using C# in the easiest way and keeping all their pictures and style. This software takes advanced technology to keep all the original elements of HTML file in PDF. By this command line application, you can also call it from ASP, VB, VC, Delphi, BCB, Java, .NET and COM+ codes. Please check more related information of this software on homepage, in the following part , let us check how to use this software.
- As its name shows, this software is command line application, when downloading finishes, there will be a zip file. Please extract it to some folder then you can check related element, help documents and other files.
- There are two license type of this software: developer license and server license. By the server version, you can install this software under the whole sever. By the developer version, you can integrate the corresponding SOFTWARE into your developed software and redistribute it with royalty-free.
Step 2. Convert HTML file to PDF with pictures and style using C#.
- When you use this software, please refer to the usage and examples.
- When converting
webkit : use the Webkit engine to convert HTML and web pages to PDF files. This parameter can help you convert HTML file to PDF and keeping all the pictures and style.
with pictures and style using C#, you may use the following parameters.
-width <int> : Set page width to PDF file
-height <int> : Set page height to PDF file
-bwidth <int> : Set web browser's width for HTML conversion
-bheight <int> : Set web browser's height for HTML conversion
-append <int> :
-append 0: Overwrite if PDF file exists
-append 1: Insert before first page if PDF file exists
-append 2: Append to last page if PDF file exists
-append 3: Rename filename if PDF file exists
-postdata <string> : Set the data to be posted to the URL. Use this function for some urls protected by forms.
-postdatafile <string> : Read long postdata parameter from a disk file
-producer <string> : Set 'producer' to PDF file
There are too many parameters of this software, please check more on readme.txt. Now let us check one example of calling this software from C# code.
static void Main(string args)
Process proc = new Process();
proc.StartInfo.FileName = @"C:\\htmltools.exe";
string strArguments = "";
strArguments += "-webkit";
strArguments += " D:\\temp\\sample.html D:\\temp\\out.pdf";
proc.StartInfo.Arguments = @strArguments;
Please check more examples on homepage. During the using, if you have any question, please contact us as soon as possible.