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

Why is my PDF being generated as blank?

I am using ItextSharp and c#, asp.net MVC to generate a PDF report. However, when I generate the report the PDF comes back as blank (apart from a header which is working fine). I would love your input. The code that generates the report is as…
Daniel Casserly
  • 3,552
  • 2
  • 29
  • 60
3
votes
1 answer

ITextSharp/Pdftk: place Base64 Image from Web on PDF as Pseude-Signature

I am trying to conceptualize a way to get base64 image onto an already rendered PDF in iText. The goal is to have the PDF save to disk then reopen to apply the "signature" in the right spot. I haven't had any success with finding other examples…
MizAkita
  • 1,115
  • 5
  • 21
  • 52
3
votes
2 answers

Alignment issue with multiline text form fields in iTextSharp

I have written an application to programatically fill out a form in a PDF template from a database and save the result to disk. Everything is working correctly apart from any multi-line text fields which are not rendering as expected. They should be…
Steve
  • 2,988
  • 2
  • 30
  • 47
3
votes
1 answer

Drawing circle on existing PDF using itextsharp c#

I got some troubles drawing circle on an existing pdf, I found a code to add text on existing PDF, I tried to adapt it to draw circle but the result is just a blank page Does anyone have an idea how to fix this? My code: string oldFile =…
Json
  • 153
  • 2
  • 7
  • 17
3
votes
1 answer

How to display "✔" when signature is valid with iTextSharp?

I need to do a signature in pdf like this when trusted certificate: When certificate is unknown origin then display a "?". I can do the signature, but not display "✔" or "?".
David
  • 923
  • 8
  • 19
3
votes
0 answers

Attach Generated PDFTK/iTextSharp PDF to MemoryStream to Mail

I have a PDF being generated by PDFTK (PDFToolkit). I am trying to add the ReturnedPDF which gets saved to the downloads folder to a MailMessage in C#. The PDF downloads with no problem; however, attaching isn't going so well. var pdfContents =…
MizAkita
  • 1,115
  • 5
  • 21
  • 52
3
votes
1 answer

Making editable cells of a table readonly having Scroll Bar with itext

Please find the below code. public class MakingFieldReadOnly implements PdfPCellEvent { /** The resulting PDF. */ public static final String RESULT1 = "text_fields.pdf"; /** The resulting PDF. */ public static final String RESULT2 =…
Shahid
  • 33
  • 4
3
votes
2 answers

How to add border to paragraph in itext pdf library in java?

I have created a paragraph in using itext pdf library in java. I have to add border to paragraph, not to the whole document. How to do it ?
Amit Das
  • 1,077
  • 5
  • 17
  • 44
3
votes
1 answer

How to directly print a PDF dynamically created with iTextSharp using asp.net c#?

I have looked around a lot and i cant seem to find a way that works for me. I am creating a website, and I have two buttons, a Download button (which works fine) and a Print button that should print the PDF (or even just open the PDF in adobe with…
Krytix
  • 67
  • 2
  • 8
3
votes
2 answers

Exception when converting tiff file to pdf file with iText

When I try to convert a tiff file to pdf file by using itextpdf 5.5.5, the following exception occurs: java.lang.RuntimeException: Scanline must begin with EOL code word. at …
hecatcat
  • 41
  • 4
3
votes
0 answers

iTextSharp error Invalid nested tag body found, expected closing tag script

I am getting the following error when trying to generate PDF after converting a Pie Chart to Image. Can someone advise what is wrong in my HTML file? **Additional information: Invalid nested tag body found, expected closing tag script.** The…
TheKingPinMirza
  • 7,924
  • 6
  • 51
  • 81
3
votes
1 answer

Change AcroFields order in existing PDF with iText?

I have a pdf with text form fields at are layered one on top of the other. When I fill the fields via iText and flatten the form, the form field that I had created on top of the other form field is now on the bottom. For instance, I have a text…
Matt
  • 33
  • 5
3
votes
1 answer

Get the original content from a signed pdf

I would like to know how I could get the original content from a signed pdf document using iText java library or another one. Thanks UPDATE 1: Possible example: PdfReader reader = new PdfReader(PATH_TO_PDF); AcroFields fields =…
Eduardo
  • 1,169
  • 5
  • 21
  • 56
3
votes
3 answers

Problem matching Code128A Barcodes generated with iTextSharp vs. Barcode.4NET

First of all, I'm kinda new to the barcode formats and what I do know, I've learned from Wikipedia. We have some barcodes generated by an existing app that uses the Barcode.4NET library. The barcode is in Code 128A format. The code to generate them…
CMPalmer
  • 8,571
  • 5
  • 40
  • 49
3
votes
2 answers

iText RadioGroup/RadioButtons across multiple PdfPCells

I'd like to make a PdfPTable with multiple rows in it. In each row I'd like to have a Radio button in the first cell and descriptive text in the second cell. I'd like all the radio buttons to be a part of the same radio group. I've used…
corestruct00
  • 105
  • 8