Questions tagged [itext]

Library to create and manipulate PDF documents in Java and C#. Use this tag for code using iText versions up to 5.5.x. For iText versions from 7.0.0 onwards a separate tag "itext7" is available. Remember to also add the tag for the language you're using.

iText is a library that allows you to create and manipulate PDF documents. It enables developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation. Developers can use iText to:

  • Serve PDF documents to a browser
  • Generate dynamic documents from XML files or databases
  • Use PDF's many interactive features
  • Add bookmarks, page numbers, watermarks, etc.
  • Split, concatenate, and manipulate PDF pages
  • Automate filling out of PDF forms
  • Add digital signatures to a PDF file

Typically, iText is used in projects that have one of the following requirements:

  • The content isn't available in advance: it's calculated based on user input or real-time database information.
  • The PDF files can't be produced manually due to the massive volume of content: a large number of pages or documents.
  • Documents need to be created in unattended mode, in a batch process.
  • The content needs to be customized or personalized; for instance, the name of the end user has to be stamped on a number of pages.

Often you'll encounter these requirements in web applications, where content needs to be served dynamically to a browser. Normally, you'd serve this information in the form of HTML, but for some documents, PDF is preferred over HTML for better printing quality, for identical presentation on a variety of platforms, for security reasons, or to reduce the file size.

iText is available in Java as well as in C#.

Official website: https://itextpdf.com/

Useful links

Important

All versions prior to iText 5 (released in December 2009) are obsolete. Commercial and AGPL licenses for iText5 are available from iText Group. According to them, older versions should no longer be used due to technical and legal issues (read the Legal section in The Best iText Questions on StackOverflow for their opinion).

About iText 4

When you look at the Change logs, you can see that iText 2.1.7 was released on July 7, 2009. It was followed by iText 5.0.0 on December 7, 2009. There was no official release of iText 3 or 4. As explained on the official web site, iText jumped from version 2.1.7 to 5.0.0 to synchronize the version numbers of iText and iTextSharp. iTextSharp was already at version 4 while iText was still on version 2.

iText 7

As iText version 7 is a complete rewrite of the API, an additional tag has been introduced to mark questions explicitly referring to iText 7 usage.

Related tags

, ,

13154 questions
3
votes
1 answer

Edit PDF online and save and form data to server

I have some PDF documents which are being displayed in the browser, with some fields already being pre-populated from the database using iTextSharp (we are running Windows Server 2008, IIS 7, SQL Server 2008, and ASP.NET 2.0/2.5 with C#). Our…
Clowerweb
  • 31
  • 1
  • 3
3
votes
1 answer

iTextSharp - Paragraph Line-Height

I'm currently working on a PDF but I am facing issues trying to increase the line-height of a Paragraph, this is the code that I have now: var tempTable = new PdfPTable(1); cell = new PdfPCell(new Paragraph("My Account",…
Dan
  • 971
  • 1
  • 8
  • 22
3
votes
1 answer

iTextSharp rotated PDF page reverts orientation when file is rasterized at print house

Using iTextSharp I am creating a PDF composed of a collection of existing PDFs, some of the included PDFs are landscape orientation and need to be rotated. So, I do the following: private static void AdjustRotationIfNeeded(PdfImportedPage…
Fluffy
  • 119
  • 3
  • 11
3
votes
1 answer

Extract Embedded XML from PDF with iTextSharp (C#)

I need to extract XML data embedded in Bankruptcy court files with C#. In PDF Reader the file looks like a typical court doc. In Notepad the XML is buried in the text. I've tried extracting the text with this and another code snippet using…
cacosta
  • 77
  • 2
  • 11
3
votes
1 answer

What is the size limit of pdf file when generated using c# code with images?

I am using web application to generate PDF file using C# code. PDF file contains .tiff images. If size of a folder containing images goes beyond 1GB then browser gets closed automatically. What is the size limit of images to generate PDF file using…
Sanket
  • 31
  • 2
3
votes
1 answer

How to add bootstrap.css to pdf document itextsharp

took as a basis for this http://dangtrung87.blogspot.com/2013/07/asp-generate-pdf-with-itextsharp.html i have next code string htmlText = RenderViewToString(this.ControllerContext, "report", null, true); htmlText =…
AndreyShiryaev
  • 175
  • 3
  • 13
3
votes
1 answer

Extract text and all Font information from pdf viewer

User will see a pdf in webbrowser Control(or any other viewer) and select the text from it then I want to find 1)Coordinates of selected text. 2)Font Size of selected text. 3)Font Color of Selected text. 4)Page Number of selected text. So that i can…
Charlie
  • 4,827
  • 2
  • 31
  • 55
3
votes
1 answer

How to maintain indentation if a paragraph takes new line in PdfPCell?

Some of my paragraph objects contain text that can be greater than the width of the cell in length. These paragraphs are also indented, but the problem is if a paragraph needs to take a new line due to text length, the indenting is not maintained on…
jbailie1991
  • 1,305
  • 2
  • 21
  • 42
3
votes
1 answer

Alternate between titles and paragraphs with itextsharp

I'm trying to write a pdf document with itextsharp but I wont to alternate between two styles: the title and the paragraph. I tryed something like this: Paragraph title= new Paragraph(); title.Alignment = Element.ALIGN_CENTER; title.Font =…
3
votes
2 answers

iTextSharp IndexOutOfRange

Keep getting IndexOutOfRangeException was unhandled exception. var sb = new StringBuilder(); var bdn = String.Format("{0}\\bdn.pdf", Application.StartupPath); var reader = new PdfReader("bdn.pdf"); var numberOfPages = reader.NumberOfPages; for (var…
3
votes
2 answers

How to add text as a header or footer?

I'm creating a pdf with iText 5 and want to add a footer. I did everything like the book "iText in action" in Chapter 14 says. There are no errors but the footer doesn't show up. Can somebody tell me what I'm doing wrong? My code: public class…
Mathias Mahlknecht
  • 281
  • 2
  • 6
  • 16
3
votes
2 answers

itextpdf HTML to PDF containing Cyrillic letters

I have asked another question about this problem but I couldn't make it work. I changed my code, so now it's something like this: import java.io.FileOutputStream; import java.io.StringReader; import com.itextpdf.text.Document; import…
Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47
3
votes
1 answer

Is is possible to create invisible XFA Form?

I want to craete a PDF with XFA data but I don't want the XFA data to be visible when the PDF is viewed, however, I want it to be reachable via following code: ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfReader reader = new…
guneykayim
  • 5,210
  • 2
  • 29
  • 61
3
votes
1 answer

iTextSharp table pushing another table to a new page

I have two tables on my PDF. The first one sometimes spans more than half the page, which forces the second to jump to a new page. Here are my definitions: 'Table Declaration Dim sglTblHdWidths(2) As Single …
Nal
  • 121
  • 2
  • 15
3
votes
0 answers

iTextSharp Exception: Cannot Access a Closed Stream

I'm using the iTextSharp library and have a problem. When I read html code I generated this exception: "EXCEPCION: No se puede obtener acceso a una secuencia cerrada" EXCEPTION: Can not access a closed sequence This is the code I use: Byte[]…
Daniel
  • 43
  • 1
  • 5