Print Div Contect To PDF in Asp.Net C# Step By Step | ProgrammingGeek



Print Div Contect To PDF in Asp.Net C# Step By Step | ProgrammingGeek

Print Div Contect To PDF in Asp.Net C# Step By Step | ProgrammingGeek

Usually we need to print or export to pdf of a portion of a web page or a specific content. If you face this situation and you need to print or export div content to pdf in asp.net this tutorial is for you. This tutorial teach you how to print or export div content into pdf in asp.net using C# step by step. You can also learn how to export a div tag that include GridView with record in asp.net c#.
Noted that its allowed to print div tag with GridView and label control. But you can not
print div content with executable control like button and textbox etc.

Noted that you must add references of ItextSharp. dll file what you can download from the link given below.
To download ItextSharp dll file go to this link
https://drive.google.com/file/d/1Y7FR4Z4_0oXExnFgmJrjTTDWzzmePLZs/view?usp=sharing

Complete CRUD Operation in Asp.Net C# With SQL Server Step By Step
https://youtu.be/I5cWkoMeQIY

//To print div tag into pdf you should add a method
public override void VerifyRenderingInServerForm(Control control)
{

}
//Visual Studio Code
protected void Button6_Click(object sender, EventArgs e)
{
Response.ContentType = “Application/pdf”;
Response.AddHeader(“Content-Disposition”, “attachement; filename=YourFileName.pdf”);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
DivToPrint.RenderControl(hw);
Document doc = new Document(PageSize.A4,50f,50f,100f,30f);
HTMLWorker htw = new HTMLWorker(doc);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
StringReader sr = new StringReader(sw.ToString());
htw.Parse(sr);
doc.Close();
Response.Write(doc);
Response.End();

}
——
This channel ProgrammingGeek covers all the programming tutorial related with .Net- C#, linq, VB, SQL, Android, HTML, CSS, jQuery, Crystal Report and Microsoft Report.
So, Please subscribe and keep in touch.
https://www.youtube.com/c/ProgrammingGeek/playlists

Visit my page in Facebook
https://www.facebook.com/programminggeek7
——

More Tags
#ExportDivContectToPDFInAspNet #PrintDivToPdfAspNet #ProgrammingGeek
programminggeek,export div to pdf in asp.net c#,print div to pdf in asp.net c#,export div content to pdf in asp.net,print div into pdf,print gridview to pdf in asp.net c#,how to print div with gridview in asp.net c#,print div to pdf,visual studio code,print div content,how to export div content to pdf,asp.net tutorial,asp.net div to pdf,print div content using jquery,export div tag to pdf

Comments are closed.