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
15
votes
3 answers

Generation of PDF from HTML with non-Latin characters using ITextRenderer does not work

This is the 2nd day I spend investigating with no results. At least now, I am able to ask something very specific. I am trying to write a valid HTML code that contains some non-Latin characters in a PDF file using iText and more specifically using…
alexandros
  • 644
  • 1
  • 7
  • 16
14
votes
5 answers

How to set the cell width in itextsharp pdf creation

How can I set cell width and height in itextsharp pdf cell ceration using c#. I just use cell.width = 200f; But it should display the error message. width can not be set. What should I do?..
Fernando
  • 358
  • 3
  • 8
  • 21
14
votes
5 answers

split huge 40000 page pdf into single pages, itextsharp, outofmemoryexception

I am getting huge PDF files with lots of data. The current PDF is 350 MB and has about 40000 pages. It would of course have been nice to get smaller PDFs, but this is what I have to work with now :-( I can open it in acrobat reader with some delay…
tomsv
  • 7,207
  • 6
  • 55
  • 88
14
votes
8 answers

Embedding DLL's into .exe in in Visual C# 2010

I'm working on a C# program that uses iTextSharp.dll and WebCam_Capture.dll. When I build the program, it creates executable in the debug folder and it also copies these two dll's to the debug folder as expected. I want to merge them into a single…
Mehmed
  • 141
  • 1
  • 1
  • 3
14
votes
2 answers

How can I remove all images/drawings from a PDF file and leave text only in Java?

I have a PDF file that's an output from an OCR processor, this OCR processor recognizes the image, adds the text to the pdf but at the end places a low quality image instead of the original one (I have no idea why anyone would do that, but they…
Maurício Linhares
  • 39,901
  • 14
  • 121
  • 158
14
votes
1 answer

PDF-Forms with Unicode chars

I am currently struggling with withing a PDF form created from a LibreOffice document. I created it like suggested in the book "iText in Action" and am now trying to pre-fill the embedded form with a few values, that can contain Unicode chars. This…
Mik86
  • 161
  • 1
  • 6
14
votes
1 answer

Dynamic sized multi line TextBox field in a PDF

I have created a document in an open office with a multi-line form field: The issue I am having is when the dynamic content exceeds the initial size of the multi-line text box: Sure I can re-size the Text Box in the original template but the…
wal
  • 17,409
  • 8
  • 74
  • 109
14
votes
7 answers

Vector graphics in iText PDF

We use iText to generate PDFs from Java (based partly on recommendations on this site). However, embedding a copy of our logo in an image format like GIF results in it looking a bit strange as people zoom in and out. Ideally we'd like to embed the…
Marcus Downing
  • 10,054
  • 10
  • 63
  • 85
14
votes
2 answers

How can you find a problem with a programmatically generated PDF?

My group has been using the itext-sharp library and C#/.NET to generate custom, dynamic PDFs. For the most part, this process is working great for our needs. The one problem we can run into during development/testing is layout issues which can cause…
Swoop
  • 1,423
  • 4
  • 18
  • 34
14
votes
1 answer

Creating XFA Form and Embedding it to a regular PDF

I have a PDF which doesn't contain XFA data. What I want to do is, create a XFA Form template programmatically (not by using Adobe LiveCycle or similar program) and then embed it to the PDF, then fill the XFA Form. Is this possible? Or do I have to…
guneykayim
  • 5,210
  • 2
  • 29
  • 61
14
votes
4 answers

Opening password-protected pdf file with iTextSharp

I'm making an application that should display PDFs with password. This is my code: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { string filePath =…
Artemis
  • 413
  • 3
  • 10
  • 24
14
votes
2 answers

Image alignment in text?

Using iTextSharp i'm trying to align an image so that it gets embedded in a paragraph. I can do it like this: iTextSharp.text.Image image; image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP; document.Add(image); document.Add(new Paragraph("Large…
Kyle
  • 17,317
  • 32
  • 140
  • 246
14
votes
2 answers

PDF - Remove White Margins

I would like to know a way to remove white margins from a PDF file. Just like Adobe Acrobat X Pro does. I understand it will not work with every PDF file. I would guess that the way to do it, is by getting the text margins, then cropping out of…
jacktrades
  • 7,224
  • 13
  • 56
  • 83
13
votes
2 answers

Page X of Y issue

I tried 3 different ways of displaying Page numbers, OnCloseDocument content is not displaying in the page, none of them worked. My Intention is displaying Page numbers like this 1 of 10 2 0f 10 .............. ............ 10 of 10 on each…
Brad
  • 229
  • 2
  • 4
  • 12
13
votes
3 answers

PDF text extraction using iText

We are doing research in information extraction, and we would like to use iText. We are on the process of exploring iText. According to the literature we have reviewed, iText is the best tool to use. Is it possible to extract text from pdf per line…
rogelie
  • 131
  • 1
  • 1
  • 3