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.Display Binary Image on digital signature acrofield in PDF using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="JennyD6856">JennyD6856</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;div&gt; &lt;div class=&#34;tools&#34;&gt; &lt;a href=&#34;#colors_sketch&#34; data-tool=&#34;marker&#34;&gt;Marker&lt;/a&gt; &lt;a href=&#34;#colors_sketch&#34; data-tool=&#34;eraser&#34;&gt; Eraser&lt;/a&gt; &lt;/div&gt; &lt;br /&gt; &lt;canvas id=&#34;colors_sketch&#34; width=&#34;500&#34; height=&#34;200&#34;&gt;&lt;/canvas&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:HiddenField ID=&#34;hfImageData&#34; runat=&#34;server&#34; /&gt; &lt;asp:Button ID=&#34;btnSave&#34; Text=&#34;Save&#34; runat=&#34;server&#34; UseSubmitBehavior=&#34;false&#34; OnClick=&#34;Save&#34; OnClientClick=&#34;return ConvertToImage(this)&#34; /&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdn.rawgit.com/mobomo/sketch.js/master/lib/sketch.min.js&#34; type=&#34;text/javascript&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#39;#colors_sketch&#39;).sketch(); $(&#34;.tools a&#34;).eq(0).attr(&#34;style&#34;, &#34;color:#000&#34;); $(&#34;.tools a&#34;).click(function () { $(&#34;.tools a&#34;).removeAttr(&#34;style&#34;); $(this).attr(&#34;style&#34;, &#34;color:#000&#34;); }); }); function ConvertToImage(btnSave) { var base64 = $(&#39;#colors_sketch&#39;)[0].toDataURL(); $(&#34;[id*=hfImageData]&#34;).val(base64); __doPostBack(btnSave.name, &#34;&#34;); }; &lt;/script&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using iTextSharp.text; using iTextSharp.text.pdf;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports iTextSharp.text Imports iTextSharp.text.pdf</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) { string base64 = Request.Form[hfImageData.UniqueID].Split(&#39;,&#39;)[1]; byte[] bytes = Convert.FromBase64String(base64); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bytes); pdfDoc.Add(img); pdfDoc.Close(); Response.ContentType = &#34;application/pdf&#34;; Response.AddHeader(&#34;content-disposition&#34;, &#34;attachment;filename=ImageExport.pdf&#34;); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs) Dim base64 As String = Request.Form(hfImageData.UniqueID).Split(&#34;,&#34;c)(1) Dim bytes As Byte() = Convert.FromBase64String(base64) Dim pdfDoc As Document = New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F) Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream) pdfDoc.Open() Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(bytes) pdfDoc.Add(img) pdfDoc.Close() Response.ContentType = &#34;application/pdf&#34; Response.AddHeader(&#34;content-disposition&#34;, &#34;attachment;filename=ImageExport.pdf&#34;) Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.Write(pdfDoc) Response.End() End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/jjn9AZE.gif" alt="" width="407" height="397" /></p>https://www.aspforums.net:443/Threads/157564/Display-Binary-Image-on-digital-signature-acrofield-in-PDF-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/157564/Display-Binary-Image-on-digital-signature-acrofield-in-PDF-using-C-and-VBNet-in-ASPNet/Thu, 08 Aug 2019 05:59:23 GMT