本文介绍了如何将HTML代码转换为Pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
foreach (int Purchase_id in lstPurchaseId)
{
//if (Invoice_id != 0)
//{
PurchaseMasterBean objInv = new PurchaseMasterBean();
DataTable dtPurchase = objInv.LoadDataPurchasePrintFormate(Purchase_id);
DataTable dtPurDetails = objInv.LoadPurchaseDetailPrintFormate(Purchase_id);
strHTML = strHTML + "<div><table width='800px' style='border: thin solid #C0C0C0'>" +
"<tr>"
+ "<td colspan='4' align='center' style='font-family:Lucida Sans Unicode;'>" +
"<h3 style='background-color:#4978A8; font-weight: bold;font-size: xx-large;'>Purchase Order</h3>"//font-size: xx-large;background-color: #4978A8'>"
+ "</td></tr>" +
"<tr>" +
"<td>" +
"<img alt='' src='~/Images/Betanet.jpg' /> " +
"</td>" +
"<td colspan='2'>" +
" <b>" + dtPurchase.Rows[0]["YourCompanyName"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["CompanyAddress"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["WebURL"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["EmailId"].ToString() + "</b> <br/>" +
"</td>" +
"<td>" +
" CSTNO:<b>" + dtPurchase.Rows[0]["CSTNO"].ToString() + "</b> <br/>" +
" GSTNO:<b>" + dtPurchase.Rows[0]["GSTNO"].ToString() + "</b> <br/>" +
" Service Tax No:<b>" + dtPurchase.Rows[0]["ServiceTaxNo"].ToString() + "</b> <br/>" +
"</td>" +
" </tr> " +
"<tr>" +
"<td width='50%' class='datepick' Colspan='2' style='border-style: solid; border-width: thin' valign='Top' align='left'>" +
" <b>Client Name:</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorName"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorAddress"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorCity"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorPincode"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorPhoneNumber"].ToString() + "</b> <br/>" +
" <b>" + dtPurchase.Rows[0]["VendorEmail"].ToString() + "</b> <br/>" +
"</td>" +
"<td class='datepick' Colspan='2' style='border-style: solid; border-width: thin' valign='Top' align='left'>" +
" <b>Delivery Address:</b> <br/>" +
" <b>"+
" <b>"+
"<b>Contact Person:</b>" +
" <b>"+
"</td>" +
"</tr>"
+ "<tr><td></td><td style='width: 93px'><b>"
+ "</b> <br/></td></tr>"
+ "<tr><td style='width: 120px'>"
+ "Purchase Order#</td>"
+ "<td style='width: 93px'><b>"
+ dtPurchase.Rows[0]["PONumber"].ToString()
+ "</b> <br/></td>"
+ "<td style='width: 215px' class='datepick'>"
+ "Purchase Date: </td> <td style='width: 88px' class='datepick'>"
+ dtPurchase.Rows[0]["PurchaseDate"].ToString()
+ "</td></tr><tr><td style='width: 120px'>Quotation No:</td>"
+ "<td style='width: 93px'>"
+ dtPurchase.Rows[0]["QuotationNo"].ToString()
+ "</td><td style='width: 215px' class='datepick'>Quotation Date:</td>"
+ "<td style='width: 88px class='datepick'>"
+ dtPurchase.Rows[0]["QuotationDate"].ToString()
+ "</td></tr><tr><td style='width: 120px'>Vendor</td>"
+ "<td style='width: 93px'><b>"
+ dtPurchase.Rows[0]["VendorName"].ToString()
+ "</b></td><td style='width: 215px' class='datepick'>Delivery At:</td>"
+ "<td style='width: 88px' class='datepick'>"
+ "</td></tr><tr><td style='width: 120px'>Priority:</td>"
+ "<td style='width: 93px>"
+ "</td><td style='width: 215px'></td></tr><tr><td colspan='4'></td></tr>"
+ "<tr><td colspan='4' align='center'><div>"
+ "<table width='90%' cellspacing='0' cellpadding='3' rules='all' id='MainContent_NestedContent_grdMaterialPurchasDetails' style='background-color:White;border-color:#CCCCCC;border-width:1px;border-style:None;border-collapse:collapse;'>"
+ "<tr style='color:White;background-color:#006699;font-weight:bold;'>"
+ "<th scope='col'>Code</th><th scope='col'>Description</th><th scope='col'>U.O.M.</th><th scope='col'>Quantity</th><th scope='col'>Rate</th><th scope='col'>Value</th></tr>";
for (int i = 0; i < dtPurDetails.Rows.Count; i++)
{
strHTML += "<tr style='color:#000066;'>"
+ "<td>" + dtPurDetails.Rows[i]["MaterialCode"].ToString()
+ "</td><td align='right'>"
+ dtPurDetails.Rows[i]["Description"].ToString()
+ "</td><td align='right'>"
+ dtPurDetails.Rows[i]["Unit"].ToString()
+ "</td><td align='right'>"
+ dtPurDetails.Rows[i]["Quantity"].ToString()
+ "</td><td align='right'>"
+ dtPurDetails.Rows[i]["ProductPrice"].ToString()
+ "</td><td align='right'>"
+ dtPurDetails.Rows[i]["TotalPrice"].ToString()
+ "</td></tr>";
}
strHTML += "</table></div></td></tr><tr><td colspan='4' style='width: 120px'></td></tr>"
+ "<tr><td style='width: 120px'>"
+ "</td><td style='width: 93px'></td>"
+ "<td style='width: 215px' align='right'>Total Amount:</td>"
+ "<td style='width: 95px' class='datepick'>"
+ dtPurchase.Rows[0]["TotalAmount"].ToString()
+ "</td></tr>";
if (Convert.ToDecimal(dtPurchase.Rows[0]["Tax1Amount"]) != 0)
{
strHTML += "<tr><td style='width: 120px'> </td>"
+ "<td style='width: 93px'> </td>"
+ "<td>Tax1:</td><td style='width: 88px' class='datepick'>"
+ dtPurchase.Rows[0]["Tax1Amount"].ToString()
+ "</td></tr>";
}
if (Convert.ToDecimal(dtPurchase.Rows[0]["Tax2Amount"]) != 0)
{
strHTML += "<tr><td style='width: 120px'> </td>"
+ "<td style='width: 93px'> </td>"
+ "<td>Tax2:</td><td style='width: 88px' class='datepick'>"
+ dtPurchase.Rows[0]["Tax2Amount"].ToString()
+ "</td></tr>";
}
strHTML += "<tr style=' font-family:Lucida Sans Unicode;font-size: 13px; font-weight: bold'>"
+ "<td colspan='3' style=' background-color: #006699; color: #FFFFFF;text-align: right'>"
+ "Payable Amount </td><td><b>"
+ dtPurchase.Rows[0]["AmountPayable"].ToString() + " Rs." +
"</b></td></tr><tr>" +
"<td colspan='3' align='right'>Amount In Words:" + NumericToWorldJP.NumericToWordIND((long)Convert.ToDouble(dtPurchase.Rows[0]["AmountPayable"])) + "</td>" +
"</tr><tr><td colspan='4'></td></tr>"
+ "<tr><td style='width: 120px'>Transportaion:"
+ "</td><td style='width: 93px'>"
+ dtPurchase.Rows[0]["Transportaion"].ToString()
+ "</td></tr><tr><td style='width: 120px'>Delivery Date:</td>"
+ "<td style='width: 93px'>"
+ dtPurchase.Rows[0]["DeliveryDate"].ToString()
+ "</td><td style='width: 120px'>Payment Terms:</td></tr>"
+ "<tr><td style='width: 120px'>Remarks:"
+ "</td><td colspan='3' style='width: 93px'>"
+ "</td></tr>"
+ "</table></div>";
}
return strHTML;
}
推荐答案
这篇关于如何将HTML代码转换为Pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!