itextsharp

Fill PDF Form with Itextsharp

别说谁变了你拦得住时间么 提交于 2019-12-12 08:48:31
问题 I am trying to fill up a form with ITextsharp, and trying out the following code to get all the fields in the pdf: string pdfTemplate = @"c:\Temp\questionnaire.pdf"; PdfReader pdfReader = new PdfReader(pdfTemplate); StringBuilder sb = new StringBuilder(); foreach (var de in pdfReader.AcroFields.Fields) { sb.Append(de.Key.ToString() + Environment.NewLine); } But the foreach loop is always null count. Do I need to do something to file itself as I have tried the example from here and it works

Add table into existing PDF using iTExtsharp

余生颓废 提交于 2019-12-12 08:00:54
问题 I have one PDF in that there is one table that table is dynamic and I want to add another table below to that table dynamically in my existing PDF. Is there any way to add the table in existing PDF at specific place that existing table(that is not at the end of document) is completed then I want to add my table. How can I add? Please suggest me some good way. As you can see below image. Thanks, 回答1: By far the easiest way to do this is to create a new PDF with the desired table at the desired

how to keep the same format on pdf after write in another one [closed]

不想你离开。 提交于 2019-12-12 06:50:02
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . My code Read the text from Pdf and write it in another Pdf with some modifications ,, but the format is not the same in the second Pdf ,,, so how can I keep the same format and style ? my code is : string newFile

Current number page and document's number page

好久不见. 提交于 2019-12-12 06:46:47
问题 I'm trying to make a PDF document with iTextSharp. I don't know how to make a header with "currentPageNumber/documentsNumberOfPages" like that : Follow-up question For the moment, based on the original answers, I have this : public class StockComp : iTextSharp.text.pdf.PdfPageEventHelper { PdfTemplate templateNumPage; public string Header { get; set; } public override void OnOpenDocument(PdfWriter writer, Document document) { templateNumPage = writer.DirectContent.CreateTemplate(30, 250); }

ITextSharp - How to know if a table will go to a next page?

依然范特西╮ 提交于 2019-12-12 06:44:27
问题 I am writing into a document multiple tables using ITextSharp. How to know if a table will go to a next page, so then I could remove a certain cell? P.S. I am using table.KeepTogether = true; . 回答1: You can use ColumnText in simulation mode to find out if elements fit a specific rectangle. See also How to fit a String inside a rectangle? For instance: ColumnText ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(36, 36, 559, 806); ct.AddElement(table); int status = ct.Go(true); I

how to format paragraph string to show content left, Right or middle of pdf document using iTextsharp ' vb

萝らか妹 提交于 2019-12-12 06:39:38
问题 how to format paragraph string to show content left, Right or middle of pdf document using iTextsharp in visual basic and absolute position on the document. Thanks as per suggestion by Bruno Lowagie I am using Dim table As New PdfPTable(3) table.setWidthPercentage(100) table.addCell(getCell("Text to the left", PdfPCell.ALIGN_LEFT)) table.addCell(getCell("Text in the middle", PdfPCell.ALIGN_CENTER)) table.addCell(getCell("Text to the right", PdfPCell.ALIGN_RIGHT)) document.add(table) Public

Adding new page in itextsharp will overlap with header

試著忘記壹切 提交于 2019-12-12 06:21:14
问题 I am using iTextSharp version 5.4.5.0. I have a problem while adding new page using document.NewPage() method. When I will use above method to add new page, the content of this new page will overlap with my header section. I have created my header table in OnEndPage() method of PdfPageEventHelper class. Here is the code for my header in OnEndPage event: PdfPTable table = new PdfPTable(1); table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin; PdfPTable

Read javascript from pdf using iTextSharp

半世苍凉 提交于 2019-12-12 05:45:22
问题 I have a script that runs after the pdf-file has been loaded and that populates some form fields in the pdf. I assume it is some kind of javascript running behind the scene. In the javascript code some values are stored that I need to retrieve. I use iTextSharp to work with the pdf-file. Is it possible to read the javascript code or the values so I can work with them in my c# code somehow? 回答1: Modified from this SO answer: var pdfReader = new PdfReader(infilename); using (MemoryStream

iTextSharp PDF form field validation

江枫思渺然 提交于 2019-12-12 05:39:53
问题 Is is possible to add validation to PDF form fields via iTextSharp. I currently generate a PDF document, fill editable form fields with values from my database and present the document to the user in a webpage. PdfReader pdfReader = new PdfReader(template); PdfStamper pdfStamper = new PdfStamper(pdfReader, writeStream); AcroFields pdfFormFields = pdfStamper.AcroFields; pdfFormFields.SetField("field1", myobj.field1value); ... pdfStamper.Close(); I'd like to be able to dynamically add

How to use a c# Image object in itextSharp

馋奶兔 提交于 2019-12-12 05:39:20
问题 Is there any solution to convert a c# Image object to an iTextSharp compatible image to be used inside the pdf. 回答1: Yes. The class iTextSharp.text.Image has a method called GetInstance() that has 18 overloads, 3 of which accept a System.Drawing.Image . iTextSharp.text.Image.GetInstance(System.Drawing.Image, iTextSharp.text.BaseColor); iTextSharp.text.Image.GetInstance(System.Drawing.Image, iTextSharp.text.BaseColor, Bool); iTextSharp.text.Image.GetInstance(System.Drawing.Image, System