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

unable to calculate itext PdfPTable/PdfPCell height properly

I'm facing a problem while trying to generate a PdfPTable and calculate its height before adding it to a document. The method calculateHeights of PdfPTable returned the height a lot greater than the height of a page (while the table is about 1/4 of…
Anton Zvonovsky
  • 313
  • 2
  • 6
  • 16
3
votes
1 answer

iTextSharp XMLWorker Footer from html

I searched everywhere for this problem and I still can't get the working solution wrrr, it's very annoying. I use xmlworker (itextsharp 2.1) to create pdf from html. This works perfectly to me, but I need to add footer and header to each page filled…
Adam Mrozek
  • 1,410
  • 4
  • 26
  • 49
3
votes
1 answer

iText PDF Approval and Certification Signature

I am using iText for PDF signing. My PDF form has 3 signature fields. The first two fields are for approval signatures and the last field is for certification signature. Certification signature is always signed after the approval signatures and…
3
votes
0 answers

How to get rid of "document overhead" from PDF file?

I'm using iTextSharp (iTextSharp.text.pdf.PdfStamper) to add thousands of link to an existing PDF file to create a new file. The problem is that the created file is huge (for example, original size is 20m, but the created file size is 500m). I…
zhen
  • 41
  • 1
3
votes
1 answer

How to scale a page less then 1 percent?

I want to scale a full pdf-page and insert into an new document. This works fine. But i have problems with the scale-factor when the factor is less than 1%. for example with a factor of 0,5%, no scale is happening. With a factor from 0,7%, the…
3
votes
2 answers

error on trying to sign pdf using itext :Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/cert/X509CertificateHolder

I am getting the following error on trying to sign a pdf using code sample 2.2 in Bruno Lowagie's white paper: Digital Signatures for PDF Documents Exception in thread "main" java.lang.NoClassDefFoundError:…
Hubert Dear
  • 41
  • 1
  • 3
3
votes
1 answer

How to prevent the resizing of pages in PDF?

I want to have a pdf file that contains no difference between actual size vs fit to page at printing. I tried with the following example, but not works, only the width will be locked, not the height. Is there any solution? package etiq; import…
Cristi B.
  • 651
  • 7
  • 17
3
votes
1 answer

Why doesn't FontFactory.GetFont("Known Font Name", floatSize) work?

If I say: var georgia = FontFactory.GetFont("Georgia Regular", 10f); it doesn't work. When I check the state of the variable georgia, it has its Family property set to the value UNDEFINED and its FamilyName property set to Unknown. It only works if…
Water Cooler v2
  • 32,724
  • 54
  • 166
  • 336
3
votes
0 answers

How to put checkbox in pdf using iTextSharp?

I am using iTextSharp to convert html to pdf.But i am unable to put a check box in pdf.Please help. Document pdoc = new Document(PageSize.A4, 72, 72, 82, 72); MemoryStream ms = new MemoryStream(); PdfWriter writer =…
JIKKU
  • 577
  • 4
  • 9
  • 26
3
votes
1 answer

HTML to PDF Conversion of Arabic Text from Itext 5.5 and XMLWorker

I am trying to convert an HTML String with arabic Text from Itext 5.5 & XMLWorker. After conversion, Arabic Characters are displayed blank. The Code Snippet used is as follows: public class CreateArabic { public static void main(String args[])…
sheena
  • 77
  • 2
  • 6
3
votes
1 answer

How do I change font size in a rendered PDF doc in iText?

I’m using iText 2.1.7, included through the following dependency … com.lowagie itext 2.1.7 How do I change the text size of a…
Dave
  • 15,639
  • 133
  • 442
  • 830
3
votes
1 answer

Adding text to existing multipage PDF document in memorystream using iTextSharp

I am trying to add text to an existing PDF file using iTextSharp. I have been reading many posts, including the popular thread here. I have some differences: My PDF are X pages long I want to keep everything in memory, and never have a file stored…
Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182
3
votes
1 answer

English text extracted using itextpdf is not understandable

I'm trying to extract and print english text out of a pdf on console. Extraction is done through itextpdf API using PdfTextExtractor class. Text i'm getting is not understandble. May be some language issues I'm facing. My intent is to find a…
3
votes
1 answer

"Random" generated documents fail to print

We are attempting to generate documents using iText that are formed largely from "template" files - smaller PDF files that are combined together into one composite file using the PdfContentByte.addTemplate method. We then automatically and silently…
Southpaw Hare
  • 1,535
  • 3
  • 24
  • 50
3
votes
3 answers

How to resize an iTextSharp.text.Image size into my code?

I am pretty new in iText nd iTextSharp (the C# version of iText) and I have the following problem. I am inserting some jpg charts inside my PDF. These charts are rapresented by some jpg like this one: I insert it into a table of my PDF in this…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
1 2 3
99
100