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
507
votes
26 answers

Convert HTML to PDF in .NET

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?
SandHurst
135
votes
11 answers

How to return PDF to browser in MVC?

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…
Tony Borf
  • 4,579
  • 8
  • 43
  • 51
101
votes
5 answers

iTextSharp - Sending in-memory pdf in an email attachment

I've asked a couple of questions here but am still having issues. I'd appreciate if you could tell me what I am doing wrong in my code. I run the code above from a ASP.Net page and get "Cannot Access a Closed Stream". var doc = new…
Gus Cavalcanti
  • 10,527
  • 23
  • 71
  • 104
84
votes
5 answers

ITextSharp insert text to an existing pdf

The title sums it all. I want to add a text to an existing PDF file using iTextSharp, however i can't find how to do it anywhere in the web... PS: I cannot use PDF forms.
Tony
  • 2,473
  • 3
  • 23
  • 32
83
votes
6 answers

Reading PDF content with itextsharp dll in VB.NET or C#

How can I read PDF content with the itextsharp with the Pdfreader class. My PDF may include Plain text or Images of the text.
user221185
  • 839
  • 1
  • 7
  • 3
81
votes
1 answer

Return generated pdf using spring MVC

I am using Spring MVC .I have to write a service that would take input from the request body, add the data to the pdf and returns the pdf file to the browser. The pdf document is generated using itextpdf. How can I do this using Spring MVC. I have…
Maheshwaran K
  • 1,982
  • 5
  • 19
  • 22
75
votes
5 answers

How to convert HTML to PDF using iTextSharp

I want to convert the below HTML to PDF using iTextSharp but don't know where to start:

This is some sample

Chris Haas
  • 53,986
  • 12
  • 141
  • 274
68
votes
4 answers

What is the difference between lowagie and iText?

What is the difference between lowagie and iText? Is this just version difference or an upgrade to the library. Which one is recommended to be used?
Adeeb Cheulkar
  • 1,128
  • 2
  • 10
  • 22
66
votes
12 answers

How to insert blank lines in PDF?

I am creating a PDF using iText. I want to insert blank lines between paragraphs and tables. How can I achieve this?
Thanuja
  • 661
  • 1
  • 5
  • 3
66
votes
2 answers

iTextSharp set document landscape (horizontal) A4

How can I set an A4 document in landscape (horizontal) format in iTextSharp?
Luca Romagnoli
  • 12,145
  • 30
  • 95
  • 157
65
votes
9 answers

ITextSharp HTML to PDF?

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…
Kyle
  • 10,839
  • 17
  • 53
  • 63
59
votes
7 answers

Merging multiple PDFs using iTextSharp in c#.net

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")) { …
Liquid
  • 1,871
  • 1
  • 17
  • 32
51
votes
5 answers

iText - add content to existing PDF file

I want to do the following with iText: (1) parse an existing PDF file (2) add some data to it, on the existing single page of the document (such as a timestamp) (3) write out the document I just can't seem to figure out how to do this with iText. In…
Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66
50
votes
6 answers

PDF Generation Library for Java

I know this has been asked before, but I'm still undecided on which PDF generation framework to use for my current project. My requirements on-the-fly generation of PDF documents (mainly order forms, invoices) Java based easy to layout should be…
Stefan Haberl
  • 9,812
  • 7
  • 72
  • 81
46
votes
5 answers

How can I insert an image with iTextSharp in an existing PDF?

I have an existing PDF and I can use FdFWriter to input to text boxes. It works well. Now I have an image. I have read the documentation and looked at many examples but they all create new documents and insert an image. I want to take an…
johnny
  • 19,272
  • 52
  • 157
  • 259
1
2 3
99 100