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

Add a column to PdfPTable, iTextSharp

I'm creating a PDF document using iTextSharp. I see how to create a new table with a number of columns but I can't see anyway to dynamically add a new column. The problem I have is I'm not going to know the number of columns I need straight away, so…
mat-mcloughlin
  • 6,492
  • 12
  • 45
  • 62
3
votes
1 answer

Set the text above the image in pdf cell using itext

I created the pdf using iText. In that, how to set the background image to the particular PdfCell and place the text in that same cell.. I set the background image to that cell by: cell.addElement(image_green_left); In case of both text and…
Naveen Rajen
  • 105
  • 1
  • 10
3
votes
1 answer

Using itextsharp to set ocg state of existing pdf

I have spent several hours researching this and can't seem to locate the answer. I have downloaded and referenced itextsharp in my wpf .net application. (VB) What I am doing is needing to turn off a specific layer (ocg object) in an exisiting .pdf…
3
votes
1 answer

itext xmlworker with javafx htmleditor

I created a simple JavaFX (2.2) FXML project. I am trying to convert a html string to different Elements and add them to a Paragraph in my PDF document generated by iText. As HTMLWorker is deprecated, I use XMLWorker. It does seem to work with a own…
Perneel
  • 3,317
  • 7
  • 45
  • 66
3
votes
1 answer

Changing the orientation of PDF using Itext

I have done creating pdf and chart with the help of this link http://viralpatel.net/blogs/generate-pie-chart-bar-graph-in-pdf-using-itext-jfreechart/. package net.viralpatel.pdf; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import…
Vikram
  • 151
  • 1
  • 1
  • 4
3
votes
1 answer

How to embed java.awt.font to PDF

I am using iText 2.1.2 to generate PDF. I am using the java.awt.Graphics2D to draw objects in the PDF. I am also using the java.awt.font to set fonts. I would like to embed the font into the PDF. Is is possible to embed the java.awt.font into the…
3
votes
0 answers

Convert HTML2PDF and base64 images

My html content is like below: This is bold text
mylogo And i have a simple conversion…
bahtiyartan
  • 1,010
  • 10
  • 29
3
votes
4 answers

ItextSharp - Acrofields are empty

I have a PDF form with filled out fields. If I try to read the acrofields they are empty. But in the PDF I can change the values and save them. private static string GetFormFieldNamesWithValues(PdfReader pdfReader) { return string.Join("\r\n",…
Gregor Glinka
  • 71
  • 1
  • 5
3
votes
2 answers

Sign PDF with one signature, but with several signature appearances

I want to sign a pdf with one signature with appearance on every page Here is what I do: Create the stamper PdfStamper st = PdfStamper.CreateSignature(reader, new FileStream(this.outputPDF, FileMode.Create, FileAccess.Write), '\0', null,…
Svetlozar Angelov
  • 21,214
  • 6
  • 62
  • 67
3
votes
2 answers

Image not sequentialy added in pdf document itextsharp (wrong order of elements)

i am working with iTextSharp (5.4.5) for a couple of weeks now. This week, i encountered something strangew hen it comes to the order of elements in the documents. I am working on a pdf report that contains topics and images (charts). The document…
wim boone
  • 53
  • 7
3
votes
1 answer

iTextSharp read PDF with AES Encryption throws exception

I'm trying to open a PDF with itextsharp that was encrypted with AES 256 and display it. The PDF was encrypted with itextsharp as well. I'm using iTextSharp 5.5.0.0. This code works if the encryption is set to 'standard encryption'. An exception…
Dave Avatar
  • 98
  • 1
  • 9
3
votes
2 answers

itextsharp html to pdf - table border not working

I am creating a page with TinyMCE editor and I need to convert content of editor into a PDF. I am loading the editor with default content which contins

and

tags and one . I have tried to apply border to
and it is working but if…
GMD
  • 761
  • 5
  • 21
3
votes
1 answer

iTextSharp: PDF Gradient from Spot1 to Spot2

As I understand it, PDF files cannot have gradients from one ppot colour to another spot colour. Using iTextSharp, if I try this, it results in an exception when the spot colours on the gradient stops do not match. However, Adobe Illustator CS6 is…
mwhouser
  • 31
  • 1
3
votes
4 answers

Signing a PDF with an eID using PKCS#11 and iText

After following the "Signing a document using a smart card and PKCS#11" topic in http://itextpdf.com/book/digitalsignatures and creating a code sample similar to the provided one, the signed file signature is invalid in Adobe Reader, the signature…
vvolkgang
  • 471
  • 8
  • 26
3
votes
1 answer

How to append the text "Continuation of ..." at the new page, when an element got split by setKeepTogether(true)

When an Element gets moved to a new page because of a setKeepTogether(true) configuration, I need to a text "Continutation of ..." to the new page. I tried that with the PageEvent.onStartPage() but it's not allowed to call Document.add() inside a…
d0x
  • 11,040
  • 17
  • 69
  • 104
1 2 3
99
100