Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my html page code i want to convert this html page into PDF format

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="Stylesheet" type="text/css" href="../../../CSS/style.css" />
</head>
<body>
  <form id="form1" runat="server">
  <div style="background:transparent url(WrittenTestCallLetter.jpg); height:1160px; background-repeat:no-repeat;">

  </div>
  <table>
      <tr>
          <td align="center"><asp:Button ID="btnSubmit" runat="server" Text="Submit"
           onclick="btnSubmit_Click" /> </td>
       </tr>
  </table>
 </form>
</body>
</html>
Posted
Updated 25-Feb-15 0:14am
v5

1 solution

use.
wkhtmltopdf.exe in bin folder of your project.

C#
string url= @"http://www.google.com";

try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = Server.MapPath("~/bin/") + "wkhtmltopdf.exe";
process.StartInfo.Arguments = "\""+ url+ " " + Server.MapPath("~/PDFFiles/") + "test.pdf\"";

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.WaitForExit();

}
catch (Exception ee)
            {
        //logging
            }


or see this ref.
Pdfizer, a dumb HTML to PDF converter, in C#[^]
 
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