static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //specify some options p.PageSettings.Size.A4(); p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = @"..\..\test.pdf"; int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { System.Console.WriteLine("Converting Error!"); } } }
private static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; //Prepare variables with path. string docxFile = Path.GetFullPath(@"..\..\example.docx"); string pdfFileFromDocx = Path.GetFullPath(@"..\..\exampleResultDocx.pdf"); string rtfFile = Path.GetFullPath(@"..\..\example.rtf"); string pdfFileFromRtf = Path.GetFullPath(@"..\..\exampleResultRtf.pdf"); string htmlFile = Path.GetFullPath(@"..\..\example.htm"); string pdfFileFromHtml = Path.GetFullPath(@"..\..\exampleResultHtml.pdf"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(Path.GetFullPath(@"..\..\")) { UseShellExecute = true }); // Convert DOCX file to PDF file p.DocxToPdfConvertFile(docxFile, pdfFileFromDocx); // Convert RTF file to PDF file p.RtfToPdfConvertFile(rtfFile, pdfFileFromRtf); // Convert HTML file to PDF file p.HtmlToPdfConvertFile(htmlFile, pdfFileFromHtml); }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //specify some options p.PageSettings.Size.A4(); p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Auto; p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = @"..\..\test.pdf"; int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { MessageBox.Show("Converting Error!"); } } }
protected string GeneratePDF(string strHtml, string P_Company_Id, string P_Case_Id, string P_User_Name, string P_Case_No, string P_Invoice_ID) { GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); Bill_Sys_NF3_Template objNF3Template = new Bill_Sys_NF3_Template(); string pdffilename = ""; try { SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); _InvoiceDAO = new InvoiceDAO(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("I") + ".htm"; string FullPath = ""; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(strHtml); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); String szDestinationDir = Company_Name + "/" + Case_Id + "/No Fault File/Invoice/"; FullPath = objNF3Template.getPhysicalPath().ToString() + szDestinationDir.ToString() + pdffilename.ToString(); string FilePath = szDestinationDir.ToString(); string Path = szDestinationDir.ToString() + pdffilename.ToString(); if (File.Exists(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename)) { if (!Directory.Exists(objNF3Template.getPhysicalPath() + szDestinationDir)) { Directory.CreateDirectory(objNF3Template.getPhysicalPath() + szDestinationDir); } File.Copy(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename, objNF3Template.getPhysicalPath() + szDestinationDir + pdffilename); } ArrayList objAL1 = new ArrayList(); objAL1.Add(P_Company_Id); objAL1.Add(P_Case_Id); objAL1.Add(pdffilename); // SZ_BILL_NAME objAL1.Add(FilePath); // SZ_BILL_FILE_PATH objAL1.Add(P_User_Name); objAL1.Add("NF"); objAL1.Add(P_Case_No); objAL1.Add(Path); objAL1.Add(P_Invoice_ID); _InvoiceDAO.saveGeneratedInvoicePath(objAL1); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } return(pdffilename); }
protected string GeneratePDF() { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); string pdffilename = ""; try { string szFileData = File.ReadAllText(ConfigurationManager.AppSettings["NF2_SENT_MAIL_HTML"]); szFileData = objPDF.getNF2MailDetails(szFileData, oC_Account.SZ_COMPANY_ID); string strHtml = GenerateHTML(); szFileData = szFileData.Replace("VL_SZ_TABLE_DATA", strHtml); szFileData = szFileData.Replace("VL_SZ_CASE_COUNT", Session["VL_COUNT"].ToString()); SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("P") + ".htm"; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(szFileData); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); } catch (Exception ex) { //string strError = ex.Message.ToString(); //strError = strError.Replace("\n", " "); Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } return(pdffilename); //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
static void Main(string[] args) { //How to add page header and footer SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //Let's add page header in HTML format string headerInHtml = "<table width=\"100%\" border=\"1\"><tr><td width=\"50%\" align=\"center\"></td><td>You are welcome!</td></tr></table>"; p.PageSettings.Header.FromString(headerInHtml, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); string footerInRtf = @"{\rtf1\i Italic footer }"; p.PageSettings.Footer.FromString(footerInRtf, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = Path.ChangeExtension(inputFile, ".pdf"); int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { System.Console.WriteLine("Converting Error!"); } } }
private void creatPDF() { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } String szSourceFile1 = ""; String szSourceFile1_FullPath = ""; String szSourceFile2 = ""; String szSourceFile2_FullPath = ""; String szOpenFilePath = ""; string pdffilename = ""; string genhtmlNF = ""; string genhtmlWC = ""; string billIDWC = ""; string billIDNF = ""; string providerNameWC = ""; string providerNameNF = ""; int i = 0; int printi = 0; int printiWC = 0; int iPageCount = 1; string billidWC = ""; string billidNF = ""; int i_pom_id = 0; string NodeIdPath = ""; Bill_Sys_NF3_Template _objTemp = new Bill_Sys_NF3_Template(); StringBuilder sbFinalHTML = new StringBuilder(); sbFinalHTML.AppendLine(""); int iRecordOnpageNF = Convert.ToInt32(ConfigurationManager.AppSettings["POM_RECORD_PER_PAGE"]); int iRecordOnpageWC = Convert.ToInt32(ConfigurationManager.AppSettings["POM_RECORD_PER_PAGE"]); try { String szBasePhysicalPath = _objTemp.getPhysicalPath(); string szDefaultPath = ApplicationSettings.GetParameterValue("FETCHEXCEL_SHEET"); int iFlag = 0; DataSet ds = CreateGroupData(); int iRecordsPerPageNF = 0; int iRecordsPerPageWC = 0; string strProvider = null; string strProviderNF = null; string strCasetype = null; bool iWCCount = false; genhtmlNF = "<table border='1' width='100%'> <tr> <td style='font-size:9px' width='3%'>Line</td> <td style='font-size:9px' width='5%'>Article Number</td> <td style='font-size:9px' width='25%'>Name of Addressee, Street, and Post Office Address</td> <td style='font-size:9px' width='5%'>Postage</td> <td style='font-size:9px' width='5%'>Fee</td> <td style='font-size:9px' width='5%'>Handling Charge</td> <td style='font-size:9px' width='5%'>Act. Value (if regis.)</td> <td style='font-size:9px' width='5%'>Insured Value</td> <td style='font-size:9px' width='5%'>Due Sender if COD</td> <td style='font-size:9px' width='5%'>R.R. fee</td> <td style='font-size:9px' width='5%'>S.D. fee</td> <td style='font-size:9px' width='5%'>S.H. fee</td> <td style='font-size:9px' width='5%'>Rest Del fee <br/> Remarks</td> </tr>"; //</td><td><b>Patient Name</b></td><td><b>Insurance Company</b></td><td><b>Insurance Address</b></td><td><b>Claim No</b></td><td><b>Date Of Accident</b></td></tr>"; genhtmlWC = "<table border='1' width='100%'> <tr> <td style='font-size:9px' width='3%'>Line</td> <td style='font-size:9px' width='5%'>Article Number</td> <td style='font-size:9px' width='25%'>Name of Addressee, Street, and Post Office Address</td> <td style='font-size:9px' width='5%'>Postage</td> <td style='font-size:9px' width='5%'>Fee</td> <td style='font-size:9px' width='5%'>Handling Charge</td> <td style='font-size:9px' width='5%'>Act. Value (if regis.)</td> <td style='font-size:9px' width='5%'>Insured Value</td> <td style='font-size:9px' width='5%'>Due Sender if COD</td> <td style='font-size:9px' width='5%'>R.R. fee</td> <td style='font-size:9px' width='5%'>S.D. fee</td> <td style='font-size:9px' width='5%'>S.H. fee</td> <td style='font-size:9px' width='5%'>Rest Del fee <br/> Remarks</td> </tr>"; //</td><td><b>Patient Name</b></td><td><b>Insurance Company</b></td><td><b>Insurance Address</b></td><td><b>Claim No</b></td><td><b>Date Of Accident</b></td></tr>"; // create html and pdf for groupwise provider . print per page in pdf for provider int _iCountWC = 0; int _iCountNF = 0; for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { strCasetype = ds.Tables[0].Rows[j]["CaseType"].ToString(); if (strCasetype != "WC000000000000000001") { // ONLY NF PROVIDER iRecordsPerPageNF = _iCountNF; sbFinalHTML.AppendLine(""); if (iFlag == 0) { strProvider = ds.Tables[0].Rows[j]["Provider"].ToString(); iFlag = 1; billidNF = ""; iRecordsPerPageNF = 0; } if (strProvider.Equals(ds.Tables[0].Rows[j]["Provider"].ToString())) { ++printi; //int i = 0; if (iRecordsPerPageNF == iRecordOnpageNF) { sbFinalHTML.Append(ReplaceHeaderAndFooter(genhtmlNF, "", i_pom_id)); sbFinalHTML.AppendLine("<span style='page-break-after:always'></span>"); genhtmlNF = "<table border='1' width='100%'> <tr> <td style='font-size:9px' width='3%'>Line</td> <td style='font-size:9px' width='5%'>Article Number</td> <td style='font-size:9px' width='25%'>Name of Addressee, Street, and Post Office Address</td> <td style='font-size:9px' width='5%'>Postage</td> <td style='font-size:9px' width='5%'>Fee</td> <td style='font-size:9px' width='5%'>Handling Charge</td> <td style='font-size:9px' width='5%'>Act. Value (if regis.)</td> <td style='font-size:9px' width='5%'>Insured Value</td> <td style='font-size:9px' width='5%'>Due Sender if COD</td> <td style='font-size:9px' width='5%'>R.R. fee</td> <td style='font-size:9px' width='5%'>S.D. fee</td> <td style='font-size:9px' width='5%'>S.H. fee</td> <td style='font-size:9px' width='5%'>Rest Del fee <br/> Remarks</td> </tr>"; iRecordsPerPageNF = 0; _iCountNF = 0; } if (ds.Tables[0].Rows[j]["InsDescription"] != "") { //genhtmlNF += "<tr><td style='font-size:9px'>" + (printi).ToString() + "</td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Claim Number"] + "</td><td style='font-size:9px'><b>" + ds.Tables[0].Rows[j]["Insurance Company"] + "</b><br/>" + ds.Tables[0].Rows[j]["Insurance Address"] + "</td><td style='font-size:9px' colspan=6></td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Patient Name"] + ' ' + ds.Tables[0].Rows[j]["Case #"] + "</td></tr>"; genhtmlNF += "<tr><td style='font-size:9px'>" + (printi).ToString() + "</td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Claim Number"] + "</td><td style='font-size:9px'><b>" + ds.Tables[0].Rows[j]["Insurance Company"] + "</b><br/>" + ds.Tables[0].Rows[j]["Insurance Address"] + "</b></td><td style='font-size:9px;' colspan=6> " + ds.Tables[0].Rows[j]["InsDescription"] + "</td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Case #"] + "</td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Patient Name"] + ' ' + ds.Tables[0].Rows[j]["Case #"] + "</td><div style=top:100px;left:25px;> </div></tr>"; _iCountNF++; iRecordsPerPageNF++; } else { genhtmlNF += "<tr><td style='font-size:9px'>" + (printi).ToString() + "</td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Claim Number"] + "</td><td style='font-size:9px'><b>" + ds.Tables[0].Rows[j]["Insurance Company"] + "</b><br/>" + ds.Tables[0].Rows[j]["Insurance Address"] + "</td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Case #"] + "</td><td style='font-size:9px'></td><td style='font-size:9px'></td><td style='font-size:9px'>" + ds.Tables[0].Rows[j]["Patient Name"] + ' ' + ds.Tables[0].Rows[j]["Case #"] + "</td></tr>"; _iCountNF++; iRecordsPerPageNF++; } //i = i + 1; Session["VL_COUNT"] = ds.Tables[0].Rows.Count; } } } string genHtml = ""; if (iWCCount == false && _iCountWC > 0) { genhtmlWC += "</table>"; sbFinalHTML.AppendLine(ReplaceHeaderAndFooter(genhtmlWC, billidWC, i_pom_id)); sbFinalHTML.AppendLine("<span style='page-break-after:always'></span>"); } if (_iCountNF > 0) { genhtmlNF += "</table>"; genHtml = genhtmlNF; sbFinalHTML.AppendLine(ReplaceHeaderAndFooter(genHtml, billidNF, i_pom_id)); } if (_iCountWC > 0) { // sbFinalHTML.AppendLine("<span style='page-break-after:always'></span>"); //genHtml = genhtmlWC; //sbFinalHTML.Append(ReplaceHeaderAndFooter(genHtml, billidWC )); } string strHtml = sbFinalHTML.ToString(); SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("P") + ".htm"; pdffilename = getFileName("P") + ".pdf"; string file_Path = ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(strHtml); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); string szPDFName = ""; szPDFName = szDefaultPath + pdffilename; if (szSourceFile1 == "") { szSourceFile1 = pdffilename; szSourceFile1_FullPath = szDefaultPath + szSourceFile1; szOpenFilePath = szDefaultPath + szSourceFile1; } else { szSourceFile2 = pdffilename; szSourceFile2_FullPath = szDefaultPath + szSourceFile2; } szOpenFilePath = szDefaultPath + szSourceFile1; // Page.ClientScript.RegisterClientScriptBlock(typeof(GridView), "Msg", "window.open('" + szOpenFilePath.ToString() + "'); ", true); ScriptManager.RegisterClientScriptBlock(this, GetType(), "Msg", "window.open('" + szOpenFilePath.ToString() + "'); ", true); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public void GeneratePdf(string invoiceID) {//Logging Start string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { EmployerBO objEmployerBO = new EmployerBO(); DataSet ds = objEmployerBO.GetInvoiceInfo(invoiceID, txtCompanyID.Text); string strHtml = "<table width='100%'><tr><td style='width:32%'>"; // strHtml = strHtml + "<img src='https://gogreenbills.com/images/cal.gif' alt='logo' height='150' width='140' /></td>"; strHtml = strHtml + "</td>"; strHtml = strHtml + "<td style='width:35%'><div style='float:center;'><table width='100%'><tr><td align='center' ><b>" + ds.Tables[0].Rows[0]["SZ_COMPANY_NAME"].ToString() + "</b></td></tr>"; strHtml = strHtml + " <tr><td align='center' >" + ds.Tables[0].Rows[0]["SZ_ADDRESS_STREET"].ToString() + "</td></tr>"; strHtml = strHtml + "<tr><td align='center' >" + ds.Tables[0].Rows[0]["SZ_ADDRESS_CITY"].ToString() + "," + ds.Tables[0].Rows[0]["SZ_ADDRESS_STATE"].ToString() + " " + ds.Tables[0].Rows[0]["SZ_ADDRESS_ZIP"].ToString() + "</td></tr>"; strHtml = strHtml + "<tr><td align='center' >PH." + ds.Tables[0].Rows[0]["SZ_OFFICE_PHONE"].ToString() + " FAX:" + ds.Tables[0].Rows[0]["SZ_FAX_NO"].ToString() + "</td></tr></table></div></td>"; strHtml = strHtml + "<td style='width:30%'><div style='float:right;'><table><tr><td><b>INVOICE</b></td></tr> <tr><td> </td></tr><tr><td>DATE:" + ds.Tables[1].Rows[0]["DATE"].ToString() + "</td></tr><tr><td><b>INVOICE #: " + ds.Tables[1].Rows[0]["ID"].ToString() + "</b></td></tr></table></div></td>"; //strHtml = strHtml + "<div style='float:right;width:20%'><table><tr><td><b>INVOICE</b></td></tr><tr><td>DATE:7/14/2014</td></tr><tr><td><b>INVOICE #: ABM0614 </b></td></tr></table></div>"; //strHtml = strHtml + "</div>"; strHtml = strHtml + "<br /><br /><br />"; //strHtml = strHtml + "<div style='width:100%;height: 210px;'>"; // strHtml = strHtml + "<div style='float:left;width:80%; height: 190px;'>"; //strHtml = strHtml + "<div style='float:right;width:20%; height: 190px;'>"; //strHtml = strHtml + "<table><tr><td>DT</td><td>Drug Test</td><td>21</td></tr>"; //strHtml = strHtml + "<tr><td>DTC</td><td>Drug Test Collection</td><td>0</td></tr>"; //strHtml = strHtml + "<tr><td>BAT </td><td>Breath Alcohol Test</td><td>0</td></tr>"; //strHtml = strHtml + "<tr><td>PHY </td><td>Physical Exam</td><td>0</td></tr>"; //strHtml = strHtml + "<tr><td>XRAY</td><td>Chest Xray</td><td>0</td></tr>"; //strHtml = strHtml + "<tr><td>PPD </td><td>Skin Test</td><td>0</td></tr>"; //strHtml = strHtml + "<tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr><tr></tr>"; //strHtml = strHtml + "<tr><td align='center' colspan='3'><b>Invoice June 2014 </b></td></tr>"; //strHtml = strHtml + "</table>"; //strHtml = strHtml + "</div>"; strHtml = strHtml + "</tr></table>"; strHtml = strHtml + "<table width='100%'><tr><td style='width:50%'><div style='float:left;'><table><tr><td><b>BILL TO:</b></td></tr><tr><td><b>" + ds.Tables[2].Rows[0]["SZ_EMPLOYER_NAME"].ToString() + "</b></td></tr></table></div></td>"; strHtml = strHtml + "<td style='width:50%'><div style='float:right;'> <table width='50%' align='right' >"; for (int i = 0; i < ds.Tables[3].Rows.Count; i++) { strHtml = strHtml + "<tr> <td align='right' >" + ds.Tables[3].Rows[i]["SZ_PROCEDURE_CODE"].ToString() + "</td> <td align='right' >" + ds.Tables[3].Rows[i]["SZ_CODE_DESCRIPTION"].ToString() + "</td> <td align='right' >" + ds.Tables[3].Rows[i]["COUNT"].ToString() + " </td>"; } strHtml = strHtml + "<tr><td align='Center' colspan='3'>Invoice " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month) + " " + DateTime.Now.Year + " </td></tr>"; strHtml = strHtml + "</table></div></td></tr></table>"; strHtml = strHtml + "<div style='width:100%'>"; strHtml = strHtml + "<table border='1' width='100%'>"; strHtml = strHtml + "<thead><tr><th><b>QTY</b></th><th><b>Items</b></th><th><b>First name</b></th><th><b>Last name</b></th><th><b>SSN</b></th><th><b>Date of service</b> </th><th style='width:10%'><b>Unit price</b></th><th style='width:10%'><b>Total</b></th></tr></thead>"; strHtml = strHtml + "<tbody> "; int ifirst = 0; int icount = 0; for (int i = 0; i < ds.Tables[4].Rows.Count; i++) { if (icount > 16 && ifirst != 0) { icount = 0; ifirst = 1; strHtml = strHtml + "</tbody>"; strHtml = strHtml + "</table>"; strHtml = strHtml + "<span style='page-break-before: always;'/>"; strHtml = strHtml + "<table border='1' width='100%'>"; strHtml = strHtml + "<thead><tr><th><b>QTY</b></th><th><b>Items</b></th><th><b>First name</b></th><th><b>Last name</b></th><th><b>SSN</b></th><th><b>Date of service</b> </th><th style='width:10%'><b>Unit price</b></th><th style='width:10%'><b>Total</b></th></tr></thead>"; strHtml = strHtml + "<tbody> "; } if (icount > 9 && ifirst == 0) { icount = 0; ifirst = 1; strHtml = strHtml + "</tbody>"; strHtml = strHtml + "</table>"; strHtml = strHtml + "<span style='page-break-before: always;'/>"; strHtml = strHtml + "<table border='1' width='100%'>"; strHtml = strHtml + "<thead><tr><th><b>QTY</b></th><th><b>Items</b></th><th><b>First name</b></th><th><b>Last name</b></th><th><b>SSN</b></th><th><b>Date of service</b> </th><th style='width:10%'><b>Unit price</b></th><th style='width:10%'><b>Total</b></th></tr></thead>"; strHtml = strHtml + "<tbody> "; } strHtml = strHtml + "<tr><td> " + ds.Tables[4].Rows[i]["QTY"].ToString(); strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["ITEMS"].ToString() + " </td><td> " + ds.Tables[4].Rows[i]["FIRST NAME"].ToString() + " </td>"; strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["LAST NAME"].ToString() + " </td>"; strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["SSN"].ToString() + " </td>"; strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["DOS"].ToString() + " </td>"; strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["UNIT PRICE"].ToString() + "</td>"; strHtml = strHtml + "<td> " + ds.Tables[4].Rows[i]["TOTAL"].ToString() + " </td>"; icount++; } strHtml = strHtml + "<tr><td colspan='6' style='border:none'> </td><td><b>Subtotal</b> </td><td> " + ds.Tables[5].Rows[0]["sum"].ToString() + "</td></tr>"; strHtml = strHtml + "<tr><td colspan='6' style='border:none'> </td><td><b>Total Amt </b></td><td>" + ds.Tables[5].Rows[0]["sum"].ToString() + "</td></tr>"; strHtml = strHtml + "<tr><td colspan='6' style='border:none'> </td><td><b>Balance Due</b> </td><td> " + ds.Tables[5].Rows[0]["sum"].ToString() + "</td></tr>"; strHtml = strHtml + "</tbody>"; strHtml = strHtml + "</table>"; strHtml = strHtml + "</div>"; strHtml = strHtml + "<br /> <br /><table width='100%'><tr><td align='center'><b>Please make checks payable to "; strHtml = strHtml + ds.Tables[0].Rows[0]["SZ_COMPANY_NAME"].ToString() + " "; strHtml = strHtml + ds.Tables[0].Rows[0]["SZ_ADDRESS_STREET"].ToString() + " ,"; strHtml = strHtml + ds.Tables[0].Rows[0]["SZ_ADDRESS_CITY"].ToString() + " ,"; strHtml = strHtml + ds.Tables[0].Rows[0]["SZ_ADDRESS_STATE"].ToString() + " "; strHtml = strHtml + ds.Tables[0].Rows[0]["SZ_ADDRESS_ZIP"].ToString() + " </b></td></tr></table>"; SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); objHTMToPDF.Serial = "10007706603"; objHTMToPDF.PageStyle.PageOrientation.Landscape(); string basePath = ApplicationSettings.GetParameterValue("PhysicalBasePath"); string SavePath = ((Bill_Sys_BillingCompanyObject)this.Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_NAME + "/Invoice" + "/" + invoiceID + "/"; string htmfilename = getFileName("Invoice_" + invoiceID) + ".htm"; string pdffilename = getFileName("Invoice_" + invoiceID) + ".pdf"; if (!Directory.Exists(basePath + SavePath)) { Directory.CreateDirectory(basePath + SavePath); } StreamWriter sw = new StreamWriter(basePath + SavePath + htmfilename); sw.Write(strHtml); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(basePath + SavePath + htmfilename, basePath + SavePath + pdffilename); EmployerBO obj = new EmployerBO(); int retuenVal = obj.SaveInvoiceLink(txtCompanyID.Text, invoiceID, ApplicationSettings.GetParameterValue("DocumentManagerURL") + SavePath, pdffilename); if (retuenVal != 0) { ScriptManager.RegisterClientScriptBlock((Page)this, base.GetType(), "Msg", "window.open('" + ApplicationSettings.GetParameterValue("DocumentManagerURL") + SavePath + pdffilename + "'); ", true); } else { this.usrMessage.PutMessage("error to generate invoice pdf"); this.usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_ErrorMessage); this.usrMessage.Show(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "sandeep", "<script type='text/javascript'>window.location.href='" + @"D:\temp\" + pdffilename + "'</script>"); //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
protected void btnPrint_Click(object sender, EventArgs e) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { StringBuilder sbMainData = new StringBuilder(); GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); string pdffilename = ""; Boolean flag = false; for (int i = 0; i < grdPatientSummaryReport.Items.Count; i++) { CheckBox chkDelete1 = (CheckBox)grdPatientSummaryReport.Items[i].FindControl("chkPrint"); String szCurrentCaseData = ""; if (chkDelete1.Checked) { flag = true; string strHtml = File.ReadAllText(ConfigurationManager.AppSettings["PATIENT_INFO_HTML"]); strHtml = objPDF.getReplacedString(strHtml, grdPatientSummaryReport.Items[i].Cells[0].Text, ((Bill_Sys_BillingCompanyObject)Session["BILLING_COMPANY_OBJECT"]).SZ_COMPANY_ID); sbMainData.Append(strHtml); } } if (flag) { //Generate PDF SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("P") + ".htm"; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(sbMainData.ToString()); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); // Open PDF string szDefaultPath = ApplicationSettings.GetParameterValue("FETCHEXCEL_SHEET"); string szPDFName = ""; szPDFName = szDefaultPath + pdffilename; Page.ClientScript.RegisterClientScriptBlock(typeof(GridView), "Msg", "window.open('" + szPDFName.ToString() + "'); ", true); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }