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

Adding watermark to razorpdf mvc

I am using the following code to generate pdf in mvc using itext with razorpdf producer @model myModel.Models.Examform @{ Layout = null; } Hello This code works…
3
votes
2 answers

Getting Image DPI in PDF files using iText

I 'm trying to get information about scanned images that are saved into PDF files through iText (using Java). Using the answer and comments, I got width and height (either through Matrix, or through BufferedImage). The idea was to use the answer…
Finik
  • 35
  • 1
  • 3
3
votes
2 answers

Failed to read fields from Dynamic PDF form using iTextSharp

I have used simple dynamic pdf form which generated from Adobe LiveCycle designer and trying to read the field using iTextSharp 5.0/5.5 version using following code. string pdfTemplate = @"c:\ExpandingTextBox.pdf"; PdfReader…
Surendra Chatakondu
  • 315
  • 1
  • 4
  • 14
3
votes
0 answers

iTextSharp and embedded fonts

I have an existing PDF (source PDF) with some text using font ARIAL. I need to convert source PDF to PDF/A-1b. For this, I just create a new PDF/a-1b, set necessary xmp and copy page from the standard PDF (using getImportedPage in a loop). But I…
C.Serge
  • 91
  • 1
  • 6
3
votes
1 answer

Combine two PDF-a documents using ITextSharp

hoping that someone can see the flaw in my code to merge to PDF-a documents using ITextSharp. Currently it complains about missing metadata which PDF-a requires. Document document = new Document(); MemoryStream ms = new MemoryStream(); using…
Wouter
  • 152
  • 7
3
votes
2 answers

How to add cells vertically

Here we have a requirment. In a table, we need to add cells vertically. For example, a table may be like this. Name Age Name Age Jim 11 Lily 9 Lucy 8 Tom 6 Lile 12 Leo 13 Firstly, it will add cells in the first column, when the…
Sun Robin
  • 583
  • 4
  • 13
3
votes
2 answers

Saving com.itextpdf.text.Image as a image file

Is there a way to save the com.itextpdf.text.Image file as a jpg file on the file system ? Barcode39 code39 = new Barcode39(); code39.setCode(barcode); code39.setStartStopText(false); image39 = code39.createImageWithBarcode(cb, null,…
Adarsh
  • 3,613
  • 2
  • 21
  • 37
3
votes
2 answers

iTextSharp custom paper size

I'm using iTextsharp library to create PDF files. I can declare for A4 Landscape paper like this: Dim pdfTable As New PdfPTable(9) pdfTable.WidthPercentage = 100 Dim pdfDoc As New Document(PageSize.A4.Rotate()) I'm wondering how I can set Height…
Narazana
  • 1,940
  • 15
  • 57
  • 88
3
votes
1 answer

Why does maven build fails on dowloading itext from incorrect repo?

I am downloading certain dependency from external repository. So I have added following repository tag to my pom.xml cdatoolsrelease cdatools.com-releases
ntstha
  • 1,187
  • 4
  • 23
  • 41
3
votes
1 answer

Load PDF from Memory ASP.Net

I am using ITextSharp to generate pdf on the fly and then saving it to disk and display it using Frame. The Frame has an attribute called src where I pass the generated file name. This all is working fine what I want to achieve is passing the…
Sandhurst
  • 31
  • 2
3
votes
2 answers

How can I remove blank page from PDF in iText

I want to remove a blank page from a PDF generated using the iText library in Java. How do I do it?
Tushar Ahirrao
  • 12,669
  • 17
  • 64
  • 96
3
votes
1 answer

Set BaseUrl of an existing Pdf Document

We're having trouble setting a BaseUrl using iTextSharp. We have used Adobes Implementation for this in the past, but we got some severe performance issues. So we switched to iTextSharp, which is aprox 10 times faster. Adobe enabled us to set a base…
Chrisi
  • 371
  • 3
  • 15
3
votes
1 answer

How to get the ascending or descending height of a font that uses 'Text figures'

I'm having a problem with Text figures (see Wikipedia) in a PDF document created with itextsharp. The distances between the baseline and the lowest point of a number (e.g. 9) is NOT the same as the normal descender height of a font. With the…
rudy
  • 185
  • 2
  • 11
3
votes
4 answers

Itextsharp PDFPTable how to make a border around entire table

I'm building a table via a database in Itextsharp with PDFPTable, and the requirements are that no rows/cells in the table have a top or bottom bottom border, but the left and right sides of each cell have a black border (in other words, each column…
Rekson
  • 1,293
  • 3
  • 12
  • 13
3
votes
1 answer

Populate dynamic XFA pdf form itext

I have a XFA based pdf form that we need to be populate using java. Can you suggest the best approach. I was able to generate the xfa xml for the pdf using iText. public void readXfa(String srcPdfFilename, String destXMLFilename) throws IOException,…
bhrt
  • 72
  • 1
  • 2
  • 12