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
32
votes
4 answers

How do I embed fonts in an existing PDF?

Background: I have PDF's I am programmatically generating. I need to be able to send the PDF directly to a printer from the server (not through an intermediate application). At the moment I can do all of the above (generate PDF, send to printer),…
hanzworld
  • 1,289
  • 1
  • 14
  • 22
31
votes
9 answers

How to add total page number on every page with iText?

How to add the total page number on every page with iText?
trunkc
  • 6,223
  • 4
  • 34
  • 49
31
votes
5 answers

Adding an image to a PDF using iTextSharp and scale it properly

here's my code. It correctly adds the pictures I want and everything works except that the images are using their native resolution, so if the image is big it's being cropped to fit the page. Is there some way to have the picture use like a Zoom…
delete
31
votes
2 answers

how can I make a page break using itext

I want to generate a pdf using itext. I would at some point while the content was added to make a page break. I need to insert several separate conenidos dependence origin so I ask the user to do so on separate pages. Any ideas???
meyquel
  • 2,134
  • 5
  • 23
  • 42
31
votes
5 answers

Removing PDF invisible objects with iTextSharp

Is possible to use iTextSharp to remove from a PDF document objects that are not visible (or at least not being displayed)? More details: 1) My source is a PDF page containing images and text (maybe some vectorial drawings) and embedded fonts. 2)…
Hetote
  • 340
  • 4
  • 8
30
votes
4 answers

How to set a background color of a Table Cell using iText?

While it is of course possible to use BaseColor, by default, it offers very limited choices. I wonder how can i add my own custom color to the document? ... PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(new…
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
30
votes
8 answers

Java:using apache POI how to convert ms word file to pdf?

By using apache POI how to convert ms word file to pdf? I an using the following code but its not working giving errors I guess I am importing the wrong classes? import java.io.File; import java.io.FileInputStream; import…
Harinder
  • 11,776
  • 16
  • 70
  • 126
30
votes
1 answer

Getting PdfStamper to work with MemoryStreams (c#, itextsharp)

It came to me to rework old code which signs PDF files into new one, which signs MemoryStreams (byte arrays) that come and are sent by web services. Simple, right? Well, that was yesterday. Today I just can't get it to work. This is the old code,…
ADSMarko
  • 363
  • 1
  • 3
  • 8
30
votes
3 answers

Is the iTextSharp DLL free to use and redistribute with my web application project?

Is the iTextSharp DLL free to use and redistribute with my web application project which i will be selling?
Shyju
  • 214,206
  • 104
  • 411
  • 497
29
votes
1 answer

Is iText Java library free of charge or have any fees to be paid?

Are iText Java libraries to generate PDF documents free or do we have to pay for it?
Deven Shah
  • 335
  • 1
  • 3
  • 3
28
votes
3 answers

Generating header/footer with flying saucer (xHTMLRenderer) and iText

I realize this question has been asked before (I looked at all the solutions and tried them all) but I am still trying to generate a pdf document with a header and footer that repeat on every page. I am using flying saucer R8 with iText2.0.8 I have…
flyingCaffine
  • 382
  • 1
  • 4
  • 9
28
votes
3 answers

How to automate PDF form-filling in Java

I am doing some "pro bono" development for a food pantry near where I live. They are inundated with forms and paperwork, and I would like to develop a system that simply reads data from their MySQL server (which I set up for them on a previous…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
27
votes
2 answers

how can i get text formatting with iTextSharp

I am using iTextSharp to read text contents from PDF. I am able to read that also. But I am loosing text formatting like the font, color etc. Is there any way to get that formatting as well. Below is the code segment i am using to exact text -…
IrfanRaza
  • 3,030
  • 17
  • 64
  • 89
27
votes
4 answers

iTextsharp, PdfPCell.VerticalAlignment and PdfPCell.HorizontalAlignment

Im trying to figure out how to get my text inside a PdfPCell to show in the middle. I have tried many different options, like: myCell.VerticalAlignment = Element.ALIGN_MIDDLE; myCell.VerticalAlignment =…
Jimmy
  • 393
  • 1
  • 3
  • 6
27
votes
1 answer

Accessing OpenType glyph variants in iText

When building PDF documents with OpenType fonts in iText, I want to access glyph variants from within the font -- specifically tabular figures. Since OpenType glyph variants do not have Unicode indices, I am not sure how to either specify that I…
Michael Gurney
  • 291
  • 3
  • 6