Convert HtmlToPDF in ASP.net & iTextshrap
Convert Web Page to PDF in ASP.net & iTextshrap
Step 1
Download iTextSharp dll from below link's
Download iTextSharp dll
iTextsharp_Dll Download
Step 2
Create a sample website in .net . Add reference the downloaded dll .
Step 3
Create a page and design you report in this web page and put one button for Export to pdf .
Step 4
C#
Add namespaces below .
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using System.Text;
Copy and Paste below code in Export Button click event .
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
VB
Add namespaces below .
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Copy and Paste below code in Export Button click event .
Step 5
Run your website and click on Export Button and enjoy....
Step 1
Download iTextSharp dll from below link's
Download iTextSharp dll
iTextsharp_Dll Download
Step 2
Create a sample website in .net . Add reference the downloaded dll .
Step 3
Create a page and design you report in this web page and put one button for Export to pdf .
Step 4
C#
Add namespaces below .
using System.IO;
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using System.Text;
Copy and Paste below code in Export Button click event .
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
VB
Add namespaces below .
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Copy and Paste below code in Export Button click event .
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
Me.Page.RenderControl(hw)
Dim sr As New StringReader(sw.ToString())
Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 100.0F, 0.0F)
Dim htmlparser As New HTMLWorker(pdfDoc)
PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
pdfDoc.Open()
htmlparser.Parse(sr)
pdfDoc.Close()
Response.Write(pdfDoc)
Response.[End]()
Step 5
Run your website and click on Export Button and enjoy....
1xbet korean | legalbet.co.kr
ReplyDelete1xbet 제왕 카지노 korean | 카지노사이트 legalbet.co.kr. 1xbet korean. 2021. 1xbet korean 2. 22. 23. 24. 25. 26. 27. 28. 29.