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
23
votes
5 answers

Getting Coordinates of string using ITextExtractionStrategy and LocationTextExtractionStrategy in Itextsharp

I have a PDF file that i am reading into string using ITextExtractionStrategy.Now from the string i am taking a substring like My name is XYZ and need to get the rectangular coordinates of substring from the PDF file but not able to do it.On…
user3664608
  • 333
  • 1
  • 3
  • 12
23
votes
8 answers

iText/BouncyCastle ClassNotFound org.bouncycastle.asn1.DEREncodable and org.bouncycastle.tsp.TimeStampTokenInfo

I'm trying to use iText Java. When you run the example "how to sign" the following error occurs: Caused by: java.lang.ClassNotFoundException: org.bouncycastle.tsp.TimeStampTokenInfo According "Getting Started with iText - How to sign a PDF using…
Cobaia
  • 1,503
  • 3
  • 22
  • 41
23
votes
3 answers

iTextSharp Creating a Footer Page # of #

I'm trying to create a footer on each of the pages in a PDF document using iTextSharp in the format Page # of # following the tutorial on the iText pages and the book. Though I keep getting an exception on cb.SetFontAndSize(helv, 12); - object…
Rob
23
votes
3 answers

Bold a single word within a sentence with iTextSharp

Is it possible to bold a single word within a sentence with iTextSharp? I am trying to bold several individual words without having to break the string into individual phrases. I want to this type of out put Eg:REASON(S) FOR CANCELLATION: See…
Neeraj
  • 486
  • 5
  • 10
  • 22
23
votes
5 answers

Convert Pdf file pages to Images with itextsharp

I want to convert Pdf pages in Images using ItextSharp lib. Have any idea how to convert each page in image file
Prithvi Raj Nandiwal
  • 3,122
  • 3
  • 22
  • 34
22
votes
4 answers

How to add new fonts to Itext using java

when I want to use a font is iText I do the following: protected final static Font FONT_SIZE_11_BOLD = new Font(Font.HELVETICA, 11f, Font.BOLD); and then I can use it whereever I want, as follows: monthSize11 = new Chunk(month,…
Luixv
  • 8,590
  • 21
  • 84
  • 121
22
votes
2 answers

How to add a blank page to a pdf using iTextSharp?

I am trying to do something I thought would be quite simple, however it is not so straight forward and google has not helped. I am using iTextSharp to merge PDF documents (letters) together so they can all be printed at once. If a letter has an odd…
Russell
  • 17,481
  • 23
  • 81
  • 125
22
votes
4 answers

how to set width for PdfPCell in ItextSharp

i want set width for PdfpCell in Table, i want design this i Write this code PdfPCell cell; PdfGrid tableHeader; PdfGrid tmpTable; PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100,…
Pouya
  • 1,908
  • 17
  • 56
  • 78
21
votes
3 answers

Set page margins with iTextSharp

I have a template PDF file that has a a PDF form field embedded in. I am using PdfStamper to fill out these fields. In addition, I would like to be able to change the margins for generated PDF. is there any way I can modify the page margins on the…
Tyler Schroeder
  • 730
  • 3
  • 6
  • 14
21
votes
3 answers

Render PDF in iTextSharp from HTML with CSS

Any idea how to render a PDF using iTextSharp so that it renders the page using CSS. The css can either be embedded in the HTML or passed in separately, I don't really care, just want it to work. Specific code examples would be greatly…
Adam Haile
  • 30,705
  • 58
  • 191
  • 286
21
votes
4 answers

Extracting image from PDF with /CCITTFaxDecode filter

I have a pdf that was generated from scanning software. The pdf has 1 TIFF image per page. I want to extract the TIFF image from each page. I am using iTextSharp and I have successfully found the images and can get back the raw bytes from the…
Kahu
  • 211
  • 1
  • 2
  • 3
21
votes
6 answers

iText – HTML to PDF - Image is not displayed in PDF

I have a html page with text, image and I am parsing the HTML content to iText to generate the PDF. In the generated PDF,Included images are not getting displayed and , only the text is getting displayed. If I pass the absolute path like…
Deiva
  • 295
  • 2
  • 4
  • 5
21
votes
2 answers

iTextSharp units

Anyone knows what unit system does iTextSharp uses? My first assumption would be pixels but I'm not sure about it. Thanks! EDIT: Sorry to not being more specific, and thanks for letting me know. I'm talking about units for measures in the PageSize…
Sebastian
  • 1,491
  • 6
  • 20
  • 29
20
votes
1 answer

ITextSharp: Set table cell border color

How do I set the border color of a table cell. here is the code i have: // create and define table var table = new PdfPTable(8); table.HorizontalAlignment = Element.ALIGN_CENTER; //table.HeaderRows = 1; // the cell object PdfPCell cell; var f =…
Luke101
  • 63,072
  • 85
  • 231
  • 359
20
votes
1 answer

A good guide book or API doc for iTextSharp?

Can anyone suggest me a a nice book or API document for iTextSharp , I have been struggling while understanding the lib and have resorted to a hit and try methodology which is extremely irritating and time consuming.
Nikshep
  • 2,117
  • 4
  • 21
  • 30