Reading PDF content with itextsharp dll in VB.NET or C#

using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.IO; public string ReadPdfFile(string fileName) { StringBuilder text = new StringBuilder(); if (File.Exists(fileName)) { PdfReader pdfReader = new PdfReader(fileName); for (int page = 1; page <= pdfReader.NumberOfPages; page++) { ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); text.Append(currentText); } pdfReader.Close(); } return … Read more

iTextSharp – Sending in-memory pdf in an email attachment

Have you tried: PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream); // Build pdf code… writer.CloseStream = false; doc.Close(); // Build email memoryStream.Position = 0; mm.Attachments.Add(new Attachment(memoryStream, “test.pdf”)); If my memory serves me correctly, this solved a similar problem in a previous project. See http://forums.asp.net/t/1093198.aspx

How to return PDF to browser in MVC?

Return a FileContentResult. The last line in your controller action would be something like: return File(“Chap0101.pdf”, “application/pdf”); If you are generating this PDF dynamically, it may be better to use a MemoryStream, and create the document in memory instead of saving to file. The code would be something like: Document document = new Document(); MemoryStream … Read more

Convert HTML to PDF in .NET [closed]

EDIT: New Suggestion HTML Renderer for PDF using PdfSharp (After trying wkhtmltopdf and suggesting to avoid it) HtmlRenderer.PdfSharp is a 100% fully C# managed code, easy to use, thread safe and most importantly FREE (New BSD License) solution. Usage Download HtmlRenderer.PdfSharp nuget package. Use Example Method. public static Byte[] PdfSharpConvert(String html) { Byte[] res = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)