This is the html which i had saved in html file. i gives corrrect format in browser or even in mail body when i send this html in mail as a body.
<div style="width:850px;height:1120px;margin:auto;">
<div style="width:850px;height:1120px; margin:auto;">
<div style="height:190px;border:1px solid black;padding:10px;">
<div style="width:150px;float:left;"><img src="http://billing.ganpatitravels.co/images/logoGanpati.gif" /></div>
<div style="width:600px;float:left;text-align:center;padding-right:30px;">
<h1 style="margin-top:0px;"><span style="color:red;border-bottom:2px solid #FACC2E;letter-spacing:4px;font-size:48px;">Eshant Kapoor</span></h1>
<h2 style="margin-top:-25px;color:#facc2e;font-style:italic;font-family:Comic Sans MS;margin-bottom:0px;">.......care for you</h2>
<span style="font-size:12px;">
Shop No. 194,195 Market, Cantt. 000000,
Haryana, India<br />
Tel. Off. :0000-2222222,000000-00000. Resi. :2222222. Fax : 2223334<br />
Mobile: <span style="font-size:12px;">98120-60294 , </span>98960-60294.<br />
Email: eshant_kapoor2000@yahoo.com, eshantkapoor2010@gmail.com, eshantkapoor2010@yahoo.com<br />
Website: www.eshantkapoor2010.co
</span>
<hr />
</div>
<div style="padding:20px;">
<div style="float:right;width:150px;">
<strong>Date :</strong>
<!--<asp:Label ID="lblDate" runat="server"></asp:Label>-->
</div>
<div style="float:left;width:300px;">
<strong>Sr. No. :</strong> <!--<asp:Label ID="lblSrNo" runat="server"></asp:Label>-->
</div>
</div>
</div>
<div style="border-bottom:1px solid black;">
<table style="width:850px; height:70px; border:1px solid black;">
<tr>
<td style="width:425px;">
<strong>Party Name :</strong> <!--<asp:Label ID="lblCustName" runat="server"></asp:Label>-->
</td>
<td>
<strong>Phone No. :</strong> <!--<asp:Label ID="lblCustPhoneNo" runat="server"></asp:Label>
,<asp:Label ID="lblCustMobile" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td colspan=2>
<strong>Address :</strong> <!--<asp:Label ID="lblCustAddr1" runat="server"></asp:Label>
,<asp:Label ID="lblCustAddr2" runat="server"></asp:Label>
,<asp:Label ID="lblCustAddr3" runat="server"></asp:Label>
,<asp:Label ID="lblCustPinCode" runat="server"></asp:Label>-->
</td>
</tr>
</table>
<h3 style="padding:0 20px;text-transform:uppercase;height:10px;">NOTE: Toll Tax,Parking & Driver Food Charges Extra From The Party.</h3>
<table id="fill" border='1' style="width:850px;height:100px;">
<tr>
<td style="width:212px;"><strong>Fill Meter & Time Both</strong></td>
<td style="width:212px;"> <strong>Date (MM/dd/yyyy)</strong></td>
<td style="width:212px;"><strong>Time</strong></td>
<td style="width:212px;"><strong>K.M. Reading</strong></td>
</tr>
<tr>
<td><strong>In Scheduling</strong></td>
<td>
<!--<asp:Label ID="lblSchInDate" runat="server"></asp:Label>-->
</td>
<td>
<!--<asp:Label ID="lblInTime" runat="server"></asp:Label>-->
</td>
<td>
<!--<asp:Label ID="lblStartReading" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><strong>Out Scheduling</strong></td>
<td>
<!--<asp:Label ID="lblSchOutDate" runat="server"></asp:Label>-->
</td>
<td>
<!--<asp:Label ID="lblOutTime" runat="server"></asp:Label>-->
</td>
<td>
<!--<asp:Label ID="lblCloseReading" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td>
<!--<asp:Label ID="lblTotDays" runat="server"></asp:Label>-->
</td>
<td></td>
<td>
<!--<asp:Label ID="lblTotalKM" runat="server"></asp:Label>-->
</td>
</tr>
</table>
<table style="width:850px;height:200px;">
<tr>
<td style="width:150px;"><b>Nature of Duty</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblDutyNature" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Destination</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblDesignation" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Charges Of Duty</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblDutyCharge" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>K.M. Limit Max</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblMaxKM" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>K.M. Limit Min</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblMinKM" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Extra Charges</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblExtraCharge" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Total Payment</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblTotPayment" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Advance Recieved</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblAdvReceived" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Balance Payment</b></td>
<td style="border-bottom:1px dotted black;">
<!--<asp:Label ID="lblBalPayment" runat="server"></asp:Label>-->
</td>
</tr>
</table>
<table border=1 style="width:850px;height:80px;">
<tr>
<td style="width:150px;"><b>Driver Name</b></td>
<td style="width:250px;">
<!--<asp:Label ID="lblDriverName" runat="server"></asp:Label>-->
</td>
<td style="width:200px;"><b>Party Remarks about Driver</b></td>
<td>
<!--<asp:Label ID="lblDriverRemark" runat="server"></asp:Label>-->
</td>
</tr>
<tr>
<td><b>Vehicle No , Type</b></td>
<td>
<!--<asp:Label ID="lblVehNo" runat="server"></asp:Label>
,<asp:Label ID="lblVehType" runat="server"></asp:Label>-->
</td>
<td><b>Party Remarks about Vehicle</b></td>
<td>
<!--<asp:Label ID="lblVehicleRemark" runat="server"></asp:Label>-->
</td>
</tr>
</table>
</div>
<div style="width:830px;border:1px solid black; padding:0 10px; margin-top:10px;height:350px;">
<ol>
<li>Per Day Average 250 KM.</li>
<li>Parking,Toll Tax,Chungi Will be paid by the party.</li>
<li>
Night Charges Will be charged after 10:00 pm of Rs. <!--<asp:Label ID="lblNightCharges" runat="server" Font-Bold="True" Font-Underline="True"></asp:Label>-->
</li>
<li>Vehicle not to move off road.</li>
<li>Expenses for the Luggage carrier shall be beared by the party.</li>
<li>
Only
<!--<asp:Label ID="lblPassengersAllowed" runat="server" Font-Bold="True"
Font-Underline="True"></asp:Label>-->
Passenger are allowed.
</li>
<li>Child above 3 years count a adult.</li>
<li>Total Payment received in advance.</li>
<li>Subject to Ambala Cantt Jurisdiction.</li>
<li>K.M. Reading will be calculated from Garage to Garage, Local 8 hours 80 K.M.</li>
<li>We are not responsible for passenger's Luggage(Theft,Breakage,Misplace)</li>
<li>AC will not work in Hilly area,Parking & Stop for Breakfast/Lunch/Dinner.</li>
</ol>
<strong>Note:State Tax Extra:</strong> J&K<input type="checkbox" /> U.P<input type="checkbox" /> Uttrakhand<input type="checkbox" /> Rajasthan<input type="checkbox" /> Punjab<input type="checkbox" />
<br /><br />
<div style="width:800px;">
<div style="width:300px;float:left;">
Total Conditions Accepted<br />
(Hirer Signatue)
</div>
<div style="width:150px;float:right; font-weight: 700;">
For Eshant Travels
</div>
</div>
</div>
</div>
</div>
Code for Making PDF from html file using itextsharp
If Not IsPostBack Then
SendPDFEmail()
End If
Private Sub SendPDFEmail()
Dim MyWebClient As WebClient = New WebClient()
Dim body As String = String.Empty
Dim reader As StreamReader = New StreamReader(Server.MapPath("~/SlipPrint.html"))
body = reader.ReadToEnd
Dim oUTF8 As UTF8Encoding = New UTF8Encoding()
Using sw As New StringWriter()
Using hw As New HtmlTextWriter(sw)
Dim sb As New StringBuilder()
sb.Append(body)
Dim sr As New StringReader(sb.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
Using memoryStream As New MemoryStream()
Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, memoryStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Dim bytes As Byte() = memoryStream.ToArray()
memoryStream.Close()
Dim mm As New MailMessage("mymail@gmail.com", "SecondMail@gmail.com")
mm.Subject = "iTextSharp PDF"
mm.Body = "iTextSharp PDF Attachment"
mm.Attachments.Add(New Attachment(New MemoryStream(bytes), "iTextSharpPDF.pdf"))
mm.IsBodyHtml = True
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Dim NetworkCred As New NetworkCredential()
NetworkCred.UserName = "mymail@gmail.com"
NetworkCred.Password = "Password"
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
End Using
End Using
End Using
End Sub