public ActionResult Result() { string htmlString = renderViewString.Result(); string baseUrl = ""; string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); string pdf_align = "Justify"; SelectPdf.PdfTextHorizontalAlign pdfTextAlign = (SelectPdf.PdfTextHorizontalAlign)Enum.Parse(typeof(SelectPdf.PdfTextHorizontalAlign), pdf_align, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString, baseUrl); SelectPdf.PdfFont font = doc.AddFont(SelectPdf.PdfStandardFont.Helvetica); //font.Size =7; //doc.AddFont(new System.Drawing.Font("Verdana", 20)); // save pdf document var FolderName = (@"C:\Xelshekruleba\" + name.ToString()); if (!Directory.Exists(FolderName)) { Directory.CreateDirectory(FolderName); } var filePath = FolderName + '\\' + "" + name + ".pdf"; doc.Save(filePath); //System.Diagnostics.Process.Start(filePath); return(null); }
public ActionResult DisruptAutoInvoice(List <DisruptInvoice> SendInvoice) { string DocName = "DisruptInvoiceBalance"; var path = System.IO.Path.GetTempPath(); var fileName = DocName + ".pdf"; var var = System.IO.Path.Combine(path, fileName); bool isFromDiller = false; string htmlString = RenderViewAsString("Utils", "~/Views/Utils/DisruptInvoiceBalance.cshtml", SendInvoice, isFromDiller); string baseUrl = ""; // collection["TxtBaseUrl"]; string pdf_page_size = "A4"; // collection["DdlPageSize"]; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait";// collection["DdlPageOrientation"]; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); string pdf_align = "Justify";// collection["DdlPageOrientation"]; SelectPdf.PdfTextHorizontalAlign pdfTextAlign = (SelectPdf.PdfTextHorizontalAlign)Enum.Parse(typeof(SelectPdf.PdfTextHorizontalAlign), pdf_align, true); int webPageWidth = 1024; int webPageHeight = 0; SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString, baseUrl); var FolderName = (@"C:\JuridicalInvoice\DisruptInvoice\" + DateTime.Now.ToString("dd-MM-yyyy")); if (!Directory.Exists(FolderName)) { Directory.CreateDirectory(FolderName); } var name = SplitAddresName("DigitalTv Invoice " + SendInvoice.Select(s => s.Invoices_Code).FirstOrDefault()); doc.Save(FolderName + '\\' + name); return(null); }
private bool GenerateHTML_TO_PDF(string HtmlString, bool ResponseShow, string Path, bool SaveFileDir, string QuoteNumber) { try { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); // save pdf document //if (!SaveFileDir) // doc.Save(Response, ResponseShow, Path); //else // doc.Save(Path); string FileName = Path + "/" + QuoteNumber + ".pdf"; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } else { if (File.Exists(FileName)) { File.Delete(FileName); } } doc.Save(FileName); doc.Close(); return(true); } catch { return(false); } }
private void GenerateHTML_TO_PDF(string HtmlString, bool ResponseShow, string FileName, bool SaveFileDir) { try { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); doc.Save(FileName); string FilePath = FileName; WebClient User = new WebClient(); Byte[] FileBuffer = User.DownloadData(FilePath); if (FileBuffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", FileBuffer.Length.ToString()); Response.BinaryWrite(FileBuffer); } //if (FileName != "") // doc.Save(FileName); doc.Close(); } catch (Exception ex) { lblMsg.Text = _objBOUtiltiy.ShowMessage("danger", "Danger", ex.Message); } }
private void GenerateHTML_TO_PDF(string HtmlString, bool ResponseShow, string FileName, bool SaveFileDir) { try { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; SelectPdf.PdfMargins margin = new SelectPdf.PdfMargins(1, 1, 1, 1); // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; converter.Options.MarginBottom = 100; converter.Options.MarginTop = 75; //converter.Options.MarginBottom=margin; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); //doc.AddPage(pageSize, margin, pdfOrientation);\ // save pdf document if (!SaveFileDir) { doc.Save(Response, ResponseShow, FileName); } else { doc.Save(FileName); } doc.Close(); } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex); } }
private void GenerateHTML_TO_PDF(string HtmlString, bool ResponseShow, string FileName, bool SaveFileDir) { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); // save pdf document if (!SaveFileDir) { doc.Save(Response, ResponseShow, FileName); } else { doc.Save(FileName); } // close pdf document doc.Close(); }
private bool GenerateHTML_TO_PDF1(string HtmlString, bool ResponseShow, string Path, bool SaveFileDir, string QuoteNumber) { try { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); // save pdf document //if (!SaveFileDir) // doc.Save(Response, ResponseShow, Path); //else // doc.Save(Path); string FileName = Path + "/" + QuoteNumber + ".pdf"; if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } else { if (File.Exists(FileName)) { File.Delete(FileName); } } doc.Save(FileName); //doc.Close(); //doc.Save(FileName); string FilePath = FileName; WebClient User = new WebClient(); Byte[] FileBuffer = User.DownloadData(FilePath); if (FileBuffer != null) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", FileBuffer.Length.ToString()); Response.BinaryWrite(FileBuffer); } //if (FileName != "") // doc.Save(FileName); doc.Close(); return(true); } catch { return(false); } }
private void GenerateHTML_TO_PDF(string HtmlString, bool ResponseShow, string FileName, bool SaveFileDir) { try { string pdf_page_size = "A4"; SelectPdf.PdfPageSize pageSize = (SelectPdf.PdfPageSize)Enum.Parse(typeof(SelectPdf.PdfPageSize), pdf_page_size, true); string pdf_orientation = "Portrait"; SelectPdf.PdfPageOrientation pdfOrientation = (SelectPdf.PdfPageOrientation)Enum.Parse(typeof(SelectPdf.PdfPageOrientation), pdf_orientation, true); int webPageWidth = 1024; int webPageHeight = 0; // instantiate a html to pdf converter object SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; converter.Options.WebPageWidth = webPageWidth; converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(HtmlString, ""); doc.Save(FileName); // save pdf document //if (!SaveFileDir) // doc.Save(Response, ResponseShow, FileName); //else // doc.Save(FileName); string FilePath = FileName; WebClient User = new WebClient(); Byte[] FileBuffer = User.DownloadData(FilePath); //if (FileBuffer != null) //{ // Response.ContentType = "application/pdf"; // Response.AddHeader("content-length", FileBuffer.Length.ToString()); // Response.BinaryWrite(FileBuffer); //} doc.Close(); } catch (Exception ex) { lblTitle.Text = "Warning!"; lblTitle.ForeColor = System.Drawing.Color.Red; message.ForeColor = System.Drawing.Color.Red; message.Text = "Sorry,Something went wrong, please contact administrator"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } }