itextsharp

How to return PDF to browser in MVC?

风流意气都作罢 提交于 2019-11-26 04:38:43
问题 I have this demo code for iTextSharp Document document = new Document(); try { PdfWriter.GetInstance(document, new FileStream(\"Chap0101.pdf\", FileMode.Create)); document.Open(); document.Add(new Paragraph(\"Hello World\")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } document.Close(); How do I get the controller to return the pdf document to the browser? EDIT: Running this code does open Acrobat

using ITextSharp to extract and update links in an existing PDF

帅比萌擦擦* 提交于 2019-11-26 04:26:15
问题 I need to post several (read: a lot) PDF files to the web but many of them have hard coded file:// links and links to non-public locations. I need to read through these PDFs and update the links to the proper locations. I\'ve started writing an app using itextsharp to read through the directories and files, find the PDFs and iterate through each page. What I need to do next is find the links and then update the incorrect ones. string path = \"c:\\\\html\"; DirectoryInfo rootFolder = new

Getting Coordinates of string using ITextExtractionStrategy and LocationTextExtractionStrategy in Itextsharp

↘锁芯ラ 提交于 2019-11-26 04:24:15
问题 I have a PDF file that i am reading into string using ITextExtractionStrategy.Now from the string i am taking a substring like My name is XYZ and need to get the rectangular coordinates of substring from the PDF file but not able to do it.On googling i got to know that LocationTextExtractionStrategy but not getting how to use this to get the coordinates. Here is the code.. ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor

Convert arabic“unicode” content html or xml to pdf using itextsharp

纵然是瞬间 提交于 2019-11-26 03:45:20
问题 I am trying to create reports in my asp.net MVC3 application after a lot of search I found many blog posts talks about ITextSharp to convert my Html/Razor to Pdf I am trying to parse razor view to get PDf as follows public void Render(ViewContext viewContext, TextWriter writer) { var doc = new Document(); // associate output with response stream var pdfWriter = PdfWriter.GetInstance(doc, viewContext.HttpContext.Response.OutputStream); pdfWriter.CloseStream = false; viewContext.HttpContext

Reading pdf content using iTextSharp in C#

一笑奈何 提交于 2019-11-26 03:17:39
问题 I use this code to read pdf content using iTextSharp. it works fine when content is english but it doesn\'t work whene content is Persian or Arabic Result is something like this : Here is sample non-English PDF for test. َٛنا Ùٔب٘طث یؿیٛ٘ زؾا ÙÙ›ÙØ­Ù” قٛمح یٔبٕس © Karl Seguin foppersian.codeplex.com www.codebetter.com 1 1 Ùٔب٘طث َٛنا یؿیٛ٘ همانرب لوصا یسیون مرن دیلوت رتهب Ø±Ø§Ø²ÙØ§ What is the solution ? public string

Convert HTML to PDF in .NET

爷,独闯天下 提交于 2019-11-26 03:13:06
问题 I want to generate a PDF by passing HTML contents to a function. I have made use of iTextSharp for this but it does not perform well when it encounters tables and the layout just gets messy. Is there a better way? 回答1: Update: I would now recommend PupeteerSharp over wkhtmltopdf. Try wkhtmtopdf. It is the best tool I have found so far. For .NET, you may use this small library to easily invoke wkhtmtopdf command line utility. 回答2: EDIT: New Suggestion HTML Renderer for PDF using PdfSharp

Merging multiple PDFs using iTextSharp in c#.net

这一生的挚爱 提交于 2019-11-26 03:09:59
问题 Well i\'m trying to merge multiple PDFs in to one. I gives no errors while compiling. I tried to merge the docs first but that went wrong because I\'m working with tables. This is the asp.net code-behind if (Button.Equals(\"PreviewWord\")) { String eventTemplate = Server.MapPath(\"/ERAS/Badges/Template/EventTemp\" + EventName + \".doc\"); String SinglePreview = Server.MapPath(\"/ERAS/Badges/Template/PreviewSingle\" + EventName + \".doc\"); String PDFPreview = Server.MapPath(\"/ERAS/Badges

How To Remove Whitespace on Merge

旧街凉风 提交于 2019-11-26 02:38:39
问题 I have some code that takes 3 different PDF byte arrays and merges them. This code works great. The issue (some people) are having is that each PDF is considered to be a full page (if printed) even if there is only say 4 inches of content on it, thus leaving 7 inches of white space vertically. Then the middle document gets put in and may or may not have vertical white space at the end of it. Then the footer gets put on its own page as well. Here is the code: byte[] Bytes = rv.LocalReport

How to merge multiple pdf files (generated in run time)?

早过忘川 提交于 2019-11-26 02:37:42
问题 How to merge multiple pdf files (generated on run time) through ItextSharp then printing them. I found the following link but that method requires the pdf names considering that the pdf files stored and this is not my case . I have multiple reports i\'ll convert them to pdf files through this method : private void AddReportToResponse(LocalReport followsReport) { string mimeType; string encoding; string extension; string[] streams = new string[100]; Warning[] warnings = new Warning[100]; byte[

ITextSharp HTML to PDF?

拈花ヽ惹草 提交于 2019-11-26 02:28:44
问题 I\'d like to know if ITextSharp has the capability of converting HTML to PDF. Everything I will convert will just be plain text but unfortunately there is very little to no documentation on ITextSharp so I can\'t determine if that will be a viable solution for me. If it can\'t do it, can someone point me to some good, free .net libraries that can take a simple plain text HTML document and convert it to a pdf? tia. 回答1: I came across the same question a few weeks ago and this is the result