ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Export Page to PDF with CheckBox and Image at Buttom using iTextSharp in ASP.Net<p>Hi <a class="username" rel="KatieNgoc"> KatieNgoc</a>,</p> <p>Refer below sample code.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;div&gt; &lt;asp:Image ID=&#34;Image1&#34; ImageUrl=&#34;~/Files/E-Sign.png&#34; runat=&#34;server&#34; Height=&#34;100px&#34; Width=&#34;100px&#34; /&gt; &lt;br /&gt; &lt;div runat=&#34;server&#34; id=&#34;pnlDetails&#34;&gt; &lt;p&gt; 1. Get A Discount On A New Walk In Tub&lt;/p&gt; &lt;p&gt; Walk in tubs are a perfect addition for seniors living with mobility challenges or anyone worried about fall related injuries. Statistics tell us that falls happen in your bathroom more than any other room in the home.&lt;/p&gt; &lt;p&gt; In fact two-thirds of all bathroom injuries happen near the shower or bath-tub, according to The Center for Disease Control. Most falls typically happen when your stepping over the tub, slipping on a wet floor or when leaning on a glass door that wasn&#39;t designed to support your weight&lt;/p&gt; &lt;p&gt; A Walk-in tub is an investment in your future a simple modification to your bathroom can change your life. Keeping your independence and dignity, plus peace of mind for your loved ones all ad up to a better quality of life. Right now, Walk-in tub manufacturers all over the country are offering big senior discounts. Visit the walk-in tub website to find discounts and get a free quote on a new Walk-in tub.&lt;/p&gt; &lt;/div&gt; &lt;asp:CheckBox Text=&#34;I Agree&#34; runat=&#34;server&#34; ID=&#34;chkAgree&#34; /&gt; &lt;asp:Button ID=&#34;btnSave&#34; Text=&#34;Save&#34; runat=&#34;server&#34; OnClick=&#34;Save&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.IO; using iTextSharp.text.pdf; using iTextSharp.text;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.IO Imports iTextSharp.text.pdf Imports iTextSharp.text</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Save(object sender, EventArgs e) { using (FileStream stream = new FileStream(Server.MapPath(&#34;~/Files/&#34;) + &#34;ImageExport.pdf&#34;, FileMode.Create)) { String[] texts = { chkAgree.Text }; string filePath = &#34;~/Files/E-Sign.png&#34;; byte[] bytes = File.ReadAllBytes(Server.MapPath(filePath)); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f); PdfWriter.GetInstance(pdfDoc, stream); pdfDoc.Open(); string FONT = &#34;c:/windows/fonts/WINGDING.TTF&#34;; string checkBox = &#34;\u00fe&#34;; string uncheckBox = &#34;o&#34;; BaseFont bf = BaseFont.CreateFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); iTextSharp.text.Font f = new iTextSharp.text.Font(bf, 12); Paragraph ptrue = new Paragraph(checkBox, f); Paragraph pfalse = new Paragraph(uncheckBox, f); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bytes); pdfDoc.Add(img); iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc); hw.Parse(new StringReader(pnlDetails.InnerText)); if (chkAgree.Checked) { pdfDoc.Add(ptrue); } else { pdfDoc.Add(pfalse); } pdfDoc.Add(new Paragraph(chkAgree.Text)); pdfDoc.Close(); stream.Close(); } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs) Using stream As FileStream = New FileStream(Server.MapPath(&#34;~/Files/&#34;) &amp; &#34;ImageExport.pdf&#34;, FileMode.Create) Dim texts As String() = {chkAgree.Text} Dim filePath As String = &#34;~/Files/E-Sign.png&#34; Dim bytes As Byte() = File.ReadAllBytes(Server.MapPath(filePath)) Dim pdfDoc As Document = New Document(PageSize.A4, 10F, 10F, 10F, 10F) PdfWriter.GetInstance(pdfDoc, stream) pdfDoc.Open() Dim FONT As String = &#34;c:/windows/fonts/WINGDING.TTF&#34; Dim checkBox As String = &#34;&thorn;&#34; Dim uncheckBox As String = &#34;o&#34; Dim bf As BaseFont = BaseFont.CreateFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED) Dim f As iTextSharp.text.Font = New iTextSharp.text.Font(bf, 12) Dim ptrue As Paragraph = New Paragraph(checkBox, f) Dim pfalse As Paragraph = New Paragraph(uncheckBox, f) Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(bytes) pdfDoc.Add(img) Dim hw As iTextSharp.text.html.simpleparser.HTMLWorker = New iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc) hw.Parse(New StringReader(pnlDetails.InnerText)) If chkAgree.Checked Then pdfDoc.Add(ptrue) Else pdfDoc.Add(pfalse) End If pdfDoc.Add(New Paragraph(chkAgree.Text)) pdfDoc.Close() stream.Close() End Using End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/511957/Export-Page-to-PDF-with-CheckBox-and-Image-at-Buttom-using-iTextSharp-in-ASPNet/https://www.aspforums.net:443/Threads/511957/Export-Page-to-PDF-with-CheckBox-and-Image-at-Buttom-using-iTextSharp-in-ASPNet/Wed, 04 Sep 2019 01:25:55 GMT