itextsharp

How to read contents of specific page from PDF using itextsharp APIs

删除回忆录丶 提交于 2019-12-23 16:05:44
问题 How to read contents of specific page from PDF using itextsharp APIs Can anybody redirect me to the correct direction? Thanks in advance! 回答1: The following code only extracts text, if that is what you are looking for. PdfReader pdfReader = new PdfReader(documentPath); ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy(); //Extract text from the page. string txt = PdfTextExtractor.GetTextFromPage(pdfReader, page, its); // Convert the extracted text into

Converting iTextSharp.text.Image back to System.Drawing.Image

时光总嘲笑我的痴心妄想 提交于 2019-12-23 15:41:16
问题 I am trying to convert object of type iTextSharp.text.Image back to System.Drawing.Image. Here is a chunk of code that is not working: System.Drawing.Image img = System.Drawing.Image.FromStream(new MemoryStream(itextImg.RawData)); I could be going about this all wrong, but I won't know unless I consult the experts, and after two hours of fruitless searching online, I am finally posting it myself as a question. 回答1: I'm pretty sure that will work occasionally, but will fail in the general case

Vertical alignment not working in composite mode

六眼飞鱼酱① 提交于 2019-12-23 11:56:44
问题 The following should work according to the documentation but it's not working for me. Am I missing something? PdfPTable rs1 = new PdfPTable(1); PdfPCell c = new PdfPCell(); Paragraph p = new Paragraph("some text to align"); c.AddElement(p); c.VerticalAlignment = Element.ALIGN_MIDDLE; rs1.AddCell(c); rs1.AddCell("more text"); return rs1; 回答1: Ah. You need to set the PdfCell's vertical alignment, not the paragraph. PdfPCell c = new PdfPCell(); c.setVerticalAlignment(Element.ALIGN_MIDDLE); ...

Where can I find an iText xml reference?

风流意气都作罢 提交于 2019-12-23 10:57:12
问题 I am evaluating the use of RazorPDF as our reporting solution. For some reason, I cannot find any iText XML reference, beside a few examples. There are plenty of example for the Java or C# API, but nothing regarding the XML itself. Does such reference exists or do I have to figure it our from the examples? 回答1: Please read Where can I find itext.dtd? I'm the original developer of iText and I'm also the one who once upon a time, long ago, wrote the DTD for the iText XML files. That was even

Why am I getting “Cannot access a closed Stream” here?

邮差的信 提交于 2019-12-23 09:04:41
问题 Stack trace looks like [ObjectDisposedException: Cannot access a closed Stream.] System.IO.__Error.StreamIsClosed() +53 System.IO.MemoryStream.Read(Byte[] buffer, Int32 offset, Int32 count) +11411219 System.Web.Mvc.FileStreamResult.WriteFile(HttpResponseBase response) +81 System.Web.Mvc.FileResult.ExecuteResult(ControllerContext context) +168 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 after invoking //Byte[]

iTextSharp: reading radio button, check box states from a non-form PDF

梦想与她 提交于 2019-12-23 05:58:55
问题 I have a pdf document (created by a 3rd party using RealObjects PDFreactor), which is not a form . I'm trying to extract information from that PDF using iTextSharp. I'm able to extract all the plain text (using SimpleTextExtractionStrategy ), but there is some information that is represented with radio buttons, which does not come across in the plain text extracted. I'm a complete beginner with iTextSharp, so I might be overlooking something very simple. PdfReader.AcroForm returns null, and

iTextSharp MVC View to PDF

拈花ヽ惹草 提交于 2019-12-23 05:29:05
问题 I'm having a little trouble with my TextReader when trying to parse the html string I want to convert to PDF when using iTextSharp. Function ViewDeliveryNote(ByVal id As Integer) As FileStreamResult 'Memory buffer Dim ms As MemoryStream = New MemoryStream() 'the document Dim document As Document = New Document(PageSize.A4) 'the pdf writer PdfWriter.GetInstance(document, ms) Dim wc As WebClient = New WebClient Dim htmlText As String = wc.DownloadString("http://localhost:59800/Warehouse

error in generating pdf using iTextSharp

我是研究僧i 提交于 2019-12-23 05:22:11
问题 this is my controller class:- public class PlantHeadController : Controller { private WOMSEntities2 db = new WOMSEntities2(); // // GET: /PlantHead/ Document doc = new Document(); static String[] tt=new String[20]; public ActionResult Index() { ViewBag.productCode = new SelectList(db.Product, "ID","code"); return View(); } public void Convert() { PdfWriter.GetInstance(doc, new FileStream((Request.PhysicalApplicationPath + "\\Receipt3.pdf"), FileMode.Create)); doc.Open(); PdfPTable table = new

error in generating pdf using iTextSharp

↘锁芯ラ 提交于 2019-12-23 05:22:11
问题 this is my controller class:- public class PlantHeadController : Controller { private WOMSEntities2 db = new WOMSEntities2(); // // GET: /PlantHead/ Document doc = new Document(); static String[] tt=new String[20]; public ActionResult Index() { ViewBag.productCode = new SelectList(db.Product, "ID","code"); return View(); } public void Convert() { PdfWriter.GetInstance(doc, new FileStream((Request.PhysicalApplicationPath + "\\Receipt3.pdf"), FileMode.Create)); doc.Open(); PdfPTable table = new

Writing content of HTML table into PDF doc using iTextSharp in asp.net

こ雲淡風輕ζ 提交于 2019-12-23 05:17:09
问题 I have an HTML table stored in a string. I want to write that string into a PDF document using iTextSharp library. Please suggest the approach. Below is the table I want to write in a PDF file <table> <tr> <th>test</th><td>  </td><td>ABCD</td><td>  </td><td>  </td><td>  </td> </tr><tr> <th>test 2</th><td>  </td><td>XYZ</td><td>  </td><td>  </td><td>  </td> </tr> </table> 回答1: Its is possible. try this. //HTMLString = Pass your Html , fileLocation = File Store Location public void converttopdf