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

Java iText sign PDF with external signature - container size estimation

When using iText to sign PDF document with external signature, I have to prepare empty signature container first: PdfReader reader = new PdfReader(src); FileOutputStream os = new FileOutputStream(dest); PdfStamper stamper =…
user1563721
  • 1,373
  • 3
  • 28
  • 46
3
votes
2 answers

Add multiple images into a single pdf file with iText using java

I have the following code but this code add only the last image into pdf. try { filePath = (filePath != null && filePath.endsWith(".pdf")) ? filePath : filePath + ".pdf"; Document document = new Document(); …
aurelianr
  • 538
  • 2
  • 12
  • 35
3
votes
1 answer

iTextSharp XMLWorkerHelper and Images for HTML to PDF

Bottom line is I'm using iTextSharp to write out HTML to a PDF -- with an image. Right now, I'm at the latest version of iTextSharp which is 5.5.5.0. I have access to Bruno's book, and I'm using the methodology spelled out by demo.iTextSupport.com…
Dan7el
  • 1,995
  • 5
  • 24
  • 46
3
votes
1 answer

Put text on top of an image?

I would need to insert images in a pdf and then put text on top of the image at certain coordinates. Is this possible with iTextSharp?
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
3
votes
1 answer

HTML to PDF with base64 images throws FileNotFoundException

I'm using itextpdf-5.0.6.jar (Java 8) and when I try to export html code with base64 image tag I get file not found exception. if I remove the image tag everything works great! I found few solutions about overriding image tag processor but most of…
Lior Bachar
  • 103
  • 2
  • 8
3
votes
1 answer

Generating Persian and English PDF using iText on Android

I'm using iText 5.5.5 to generate a PDF file containing Persian and English characters, simultaneously. So, I used the following code: document.open(); Paragraph p1 = new Paragraph(); BaseFont myFont =…
user1922137
3
votes
1 answer

Does one need to have a license for fonts if we are using ttf files in itext?

I understand that itext does not come with any of the font libraries and you need to provide the font library . The pdf once generated, will be viewed by Acrobat and assuming , it is the standard fonts, adobe would have support for it. My questions…
vsingh
  • 6,365
  • 3
  • 53
  • 57
3
votes
1 answer

Signature defined. Must be closed in PdfSignatureAppearance

I am getting the below error when signing a pdf. The error is “Signature defined. Must be closed in PdfSignatureAppearance.” I am able to sign the pdf for the first time. It creates a pdf file in output folder with the signature in the first page.…
Venu
  • 43
  • 1
  • 1
  • 4
3
votes
1 answer

embaded images are breaked between pdf pages in flaying-saucer

I have some problem with images (all images are embedded in html as base64 strings). I use css img {page-break-inside: avoid;} and it helps but not always. In some cases the same image can be processed correctly where in other situation is…
user3333010
  • 113
  • 2
  • 9
3
votes
1 answer

itext: Change font size of XMLWorker-parsed element

I'm adding Elements from an ElementList to a PdfPCell. These elements can be anything from simple text phrases to bulletpoint lists. However, the font with which these elements are printed to the pdf is too big size. So, my question is: How to…
Steve Waters
  • 3,348
  • 9
  • 54
  • 94
3
votes
4 answers

Is there a free component to convert arabic html to pdf?

I need to take an HTML page in Arabic and convert it to a PDF. itextsharp doesn't work. Here is some example HTML with Arabic in it.
Mariam
  • 533
  • 2
  • 12
  • 22
3
votes
2 answers

C# Asp.net RazorPdf / iTextSharp image from base64

I'm using MvcRazorToPdf in my Asp.net MVC5 project to create pdfs from model. That works fine, but I want to include an image from a base64 string, because I don't want to save the generated image. System.Drawing.Image img =…
anguish
  • 458
  • 1
  • 7
  • 27
3
votes
0 answers

Adding multiple pdf files to an existing one using itextsharp

I am trying to read some pdf files page by page and add the pages to an existing pdf using itextsharp. Here is my solution: string path2 = Server.MapPath("~/2.pdf"); PdfReader reader = null; iTextSharp.text.Document document = null; PdfCopy…
Hamid Reza
  • 2,913
  • 9
  • 49
  • 76
3
votes
1 answer

What is wrong with GoDaddy's timestamp server and iTextSharp?

I am using the iTextSharp library to sign PDF documents. When I use the standard TSAClientBouncyCastle class to get time stamp from GoDaddy's server (http://tsa.starfieldtech.com), the response is an empty stream. At the same time, it perfectly…
3
votes
2 answers

Itext, table width changes when splitted in new page

I'm using iText 5.3.4 with Eclipse Kepler. I have a bill table, normally it would not have more than one page, but for testing pourposes i've been checking it's behaviour and I'm facing a weird problem, table width changes when page changes: My…
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109