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.[Solved] Unicode characters display when converting HTML to PDF in ASP.Net<p>Hi <a class="username" rel="KatieNgoc"> KatieNgoc</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;%@ Page Title=&#34;&#34; Language=&#34;C#&#34; MasterPageFile=&#34;~/MasterPage.master&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;Default.aspx.cs&#34; Inherits=&#34;_Default&#34; %&gt; &lt;asp:Content ID=&#34;Content1&#34; ContentPlaceHolderID=&#34;head&#34; runat=&#34;Server&#34;&gt; &lt;/asp:Content&gt; &lt;asp:Content ID=&#34;Content2&#34; ContentPlaceHolderID=&#34;ContentPlaceHolder1&#34; runat=&#34;Server&#34;&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; &lt;/asp:Content&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <pre class="brush: csharp">using System.IO; using iTextSharp.text; using iTextSharp.text.pdf;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></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/&#34; + Path.GetFileName(&#34;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); if (chkAgree.Checked) { pdfDoc.Add(ptrue); } else { pdfDoc.Add(pfalse); } pdfDoc.Add(new Paragraph(chkAgree.Text)); 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)); pdfDoc.Close(); stream.Close(); } }</pre> <p>&nbsp;You need to remove below two line of code.</p> <blockquote><cite>KatieNgoc says:</cite> <div class="line number63 index62 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);</code></div> <div class="line number64 index63 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">PdfWriter.GetInstance(pdfDoc, Response.OutputStream);</code></div> </blockquote> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/911478/Solved-Unicode-characters-display-when-converting-HTML-to-PDF-in-ASPNet/https://www.aspforums.net:443/Threads/911478/Solved-Unicode-characters-display-when-converting-HTML-to-PDF-in-ASPNet/Tue, 27 Aug 2019 00:58:53 GMT