Click here to Skip to main content
15,910,083 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can ne1 pls help me to convert html doc to pdf
Posted
Updated 22-Mar-17 0:09am

This question seems to appear on the forums at least once a day, and yet no-one bothers to try and search for the answer for themselves. Take a look at this answer[^] to help you.
 
Share this answer
 
execute Run function and pass HTML file in 'filename'. add ghtmldoc.exe file in bin folder. Your HTML file would be created at \\Upload\\Invoice folder.

C#
public string Run(string filename)
    {
        string sFileName = filename;
        string m_Directory = Server.MapPath("~");
        System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
        pProcess.StartInfo.FileName = m_Directory + "\\bin\\ghtmldoc.exe";
        pProcess.StartInfo.Arguments = "--webpage --datadir " + m_Directory + " --quiet --bodyfont Helvetica --size Letter --left 0.6in --right 0.4in --linkstyle plain --linkcolor #000ff --top 0.5in --fontsize 10 --footer t / --header ... -t pdf14 --jpeg -f " + sFileName + "_t.pdf " + sFileName + ".html";
        pProcess.StartInfo.WorkingDirectory = m_Directory + "\\Upload\\Invoice";

        pProcess.Start();
        Response.Write("Started : " + DateTime.Now.ToLongTimeString());
        pProcess.WaitForExit(20000);
        Response.Write("Done : " + DateTime.Now.ToLongTimeString());
        return "";
    }
 
Share this answer
 
Refer one more similar thread
Trying to convert a webpage into pdf format[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900