ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Generate pdf from text file in ASP.Net<p>Hi <a class="username" rel="PraveenS"> PraveenS</a>,</p> <p>I have checked your code and the image is exported to pdf also. Refer the below code.</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div id=&#34;newsLetterContent&#34; runat=&#34;server&#34;&gt; &lt;/div&gt; &lt;asp:Button ID=&#34;btnExport&#34; runat=&#34;server&#34; Text=&#34;Export&#34; OnClick=&#34;btnExport_Click&#34; /&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void btnExport_Click(object sender, EventArgs e) { StreamReader sr1 = new StreamReader(Server.MapPath(&#34;~/Test.txt&#34;)); string result = sr1.ReadToEnd(); sr1.Close(); newsLetterContent.InnerHtml = result; Response.ContentType = &#34;application/pdf&#34;; Response.AddHeader(&#34;content-disposition&#34;, &#34;attachment;filename=TestPage.pdf&#34;); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); newsLetterContent.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(); }</pre> <p><span style="text-decoration: underline;">test.txt</span></p> <p>&lt;p&gt;&lt;img alt="" src="http://localhost:7120/855581_DownloadBAKFile/1.jpg" style="height:363px; width:545px" /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt; &lt;p&gt; &lt;p/&gt; &lt;p&gt; &lt;p/&gt; &lt;p&gt; &lt;p/&gt; &lt;p&gt; &lt;p/&gt; &lt;p&gt; &lt;p/&gt; &lt;p&gt;&lt;img alt="" src="http://localhost:7120/855581_DownloadBAKFile/6.jpg" style="height:304px; width:456px" /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt; &lt;p&gt;Two-time World Championship bronze-medallist Sindhu advanced to the last eight of women's singles by notching up a dominating 21-13 21-15 win in 40 minutes over Chinese Taipei's Tai Tzu Ying yesterday which should serve as a good morale boost against the formidable Yihan.&lt;/p&gt;</p> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><span style="text-decoration: underline;"><img src="http://i988.photobucket.com/albums/af3/mudassarkhan/583135.gif" alt="" width="354" height="388" /></span></p>http://www.aspforums.net/Threads/583135/Generate-pdf-from-text-file-in-ASPNet/http://www.aspforums.net/Threads/583135/Generate-pdf-from-text-file-in-ASPNet/Mon, 29 Aug 2016 08:14:14 GMTGenerate pdf from text file in ASP.Net<p>Hi,</p> <p>Thanks For the reply.</p> <p>After few days of scatching i found that the code is exactly the same, but problem is my images are of highres so they are not getting displayed. When i change them to a lower resolution they appeared on pdf. Do we have any solution or alternative to reduce image resolution while creating pdf.</p> <p>&nbsp;</p> <p>Thanks</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/583135/Generate-pdf-from-text-file-in-ASPNet/http://www.aspforums.net/Threads/583135/Generate-pdf-from-text-file-in-ASPNet/Tue, 30 Aug 2016 01:09:16 GMT