The Best iText Questions on StackOverflow
$7.99
Minimum price
$8.99
Suggested price

The Best iText Questions on StackOverflow

About the Book

Since 2013, StackOverflow is the most important channel used by iText Software to answer questions about iText from developers who do not have access to Premium support. Many of these questions are answered by iText's original developer, Bruno Lowagie. Once Bruno noticed that he had answered more than 1,000 questions (resulting in a 20K+ reputation), he decided to bundle the most frequently asked, most useful and most interesting questions into a book.

The result is a book with answers to questions about PDF in general, high-level iText objects, low-level functionality, fonts, forms, page events, tables, HTML, and much more. If you have a question about iText, check out this book. If the question has been asked before, you may find the answer in this book.

This book is available for free. Just register on LeanPub and indicate that you want to purchase the book for $0. Make sure you leave your e-mail address, because this is a book that will be updated on a regular basis. More specifically: every time a series of new, interesting questions have been added. By registering for this book, you'll get a short mail informing you that you can download an updated version.

  • Share this book

  • Categories

    • Software

About the Author

iText Software
iText Software

iText® is one of the world's leading PDF libraries. It enables developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation. iText has been around as free/open source software since 2000, offering the best documented, best performing and most feature rich open source PDF engine available in Java and C#.

Bruno Lowagie is the original developer of iText. He is the author of two "iText in Action" books published by Manning. He's the CEO of the iText Group.

Table of Contents

  • introduction
    • Why StackOverflow?
    • Acknowledgments
    • How to use this book?
  • Questions about PDF in general
    • What is the difference between iText, JasperReports and Adobe LC?
    • Does a PDF file have styles, headers and footers?
    • How to extract a page number from a PDF file?
    • How to disable the save button and hide the menu bar in Adobe Reader?
    • How to close a PDF file to recreate it? (File in use problem)
    • How to hide the Adobe floating toolbar when showing a PDF in browser?
    • Why are PDF files different even if the content is the same?
    • Why do PDFs change when processing them?
    • How to find out if a PDF file compressed or not?
    • How to protect a PDF with a username and password?
    • How to encrypt PDF using a certificate?
    • How to protect an already existing PDF with a password?
    • How to allow page extraction when setting password security?
    • How do I rotate a PDF page to an arbitrary angle?
    • What is the size limit of pdf file?
    • Can I change the page count by changing internal metadata?
    • How to get the page number of an arbitrary PDF object?
    • Where is the origin (x,y) of a PDF page?
    • How should I interpret the coordinates of a rectangle in PDF?
  • Getting started
    • How to generate and design PDFs with iText or iTextSharp?
    • Argument not specified in iTextSharp
    • How to create a complex PDF document?
    • How to align two paragraphs to the left and right on the same line?
    • How to align a label versus its content?
    • how to match the size of graphics with the size of a page?
    • How to set the page size to Envelope size with Landscape orientation?
    • How to use the full size of a page?
    • How to create a document with unequal page sizes?
    • How to change the line spacing of text?
    • Does anyone have any idea how TabStop works?
    • How to strike through text using iText?
    • How to underline text with a dotted line?
    • How to add a full line break?
    • How to create a custom dashed line separator?
    • How can I generate a PDF/UA compatible PDF with iText?
  • Fonts
    • How to use the font Verdana in PdfStamper?
    • Why doesn’t FontFactory.GetFont() work for all fonts?
    • Why aren’t my fonts getting registered?
    • How to use Cyrillic characters in a PDF?
    • Why is iText embedding a font even when I specify not to embed?
    • How to identify a single font that can print all the characters in a string?
    • How to change the font color and size when using FontSelector?
    • How to create Persian content in PDF?
    • How to solve an UnsupportedCharsetException when using itext-asian.jar?
    • How to choose the optimal size for a font?
    • How to restrict the number of characters on a single line?
    • How to calculate the height of an element?
    • How to calculate/set font line distance?
    • Why can’t I set the font of a Phrase?
    • How to use two different colors in a single String?
    • How to apply color to Strings in a Paragraph?
    • How to introduce a custom font weight?
    • How to make a single letter bold within a word?
    • How to introduce superscript?
    • How to allow a Unicode subscript symbol in a PDF without using setTextRise()?
    • How to display indian rupee symbol?
    • Why isn’t the Rupee symbol showing?
    • How to use System Font in iTextSharp with VB.net?
    • Do I need a license for Windows fonts when using iText?
    • How to get a font from an array?
  • Images
    • How to add multiple images into a single PDF?
    • How to get the image DPI in PDF?
    • Why aren’t images added sequentially?
    • How to add text to an image?
    • How to draw lines on an image?
    • How to preserve high resolution images in PDF?
    • How to add JPEG images that are multi-stage filtered (DCTDecode and FlateDecode)?
    • How to avoid an exception when importing a TIFF file?
    • How to show an image with large dimensions across multiple pages?
    • How to give an image rounded corners?
    • How to convert colored images to black And white?
    • How to make an image a qualified mask candidate in itext?
    • How to create unique images with Image.getInstance()?
    • How to generate 2D barcode as vector image?
    • How to change a background Image into a watermark by altering the opacity?
  • Absolute positioning of text
    • How to write a Zapfdingbats character at a specific location on a page?
    • How to reduce redundant code when adding content at absolute positions?
    • How to truncate text within a bounding box?
    • How to continue an ordered list on a second page?
    • Why does ColumnText ignore the horizontal alignment?
    • How to fit a String inside a rectangle?
    • Why does using ColumnText result in “The document has no pages” exception?
    • How to divide a page in N parts so we can fill each with a different source?
    • How to rotate a single line of text?
    • How to rotate a paragraph?
    • How to draw a rectangle around multiline text?
    • What is causing syntax errors in a page created with iText?
    • How to adapt the position of the first line in ColumnText?
  • Absolute positioning of lines and shapes
    • How to add a border to a PDF page?
    • How to create a PDF with a Cartesian grid?
    • Why does the cell background color affect the color of other lines?
    • How do I set parameters back to the default value?
    • How to add a shading pattern to a custom shape?
  • Tables
    • How to right-align text in a PdfPCell?
    • How to use multiple fonts in a single cell?
    • How to change width of single column of table?
    • How to introduce a rowspan?
    • How to maintain a paragraph’s indentation inside a table cell?
    • What is the PdfPTable.DefaultCell property used for?
    • How to draw a borderless table in iTextSharp?
    • Why doesn’t getDefaultCell() .setBorder(PdfPCell.NO_BORDER) have any effect?
    • How to define spacing and leading in PdfPCells?
    • How can I convert a CSV file to a table with a repeating header row?
    • How to create a table based on a two-dimensional array?
    • How to nest tables without extending the inner table?
    • How to add an inner table surrounded by text?
    • How to resize an Image to fit it into a PdfPCell?
    • How to display barcodes in a matrix-like structure?
    • How to split a row over multiple pages?
    • How does a PdfPCell’s height relate to the font size?
    • How to add a table to the bottom of the last page?
    • How do setMinimumSize() and setFixedSize() interact?
    • How to get the rendered dimensions of text?
    • How to tell iText how to clip text to fit in a cell?
    • How to resize a PdfPTable to fit the page?
    • What’s an easy to print “first right, then down”?
    • How to invoke a page break for nested tables?
    • How to make a footer stick to bottom of every pdf page?
    • How to add continue on next page / continued from next page to a table?
  • Table events
    • How to use a dotted line as a cell border?
    • How to create a table with rounded corners?
    • How to introduce rounded cells with a background color?
    • How to set background image in PdfPCell in iText?
    • How to get text and image in the same cell?
    • Is it possible to attach multiple layout events to a PdfPCell?
    • How to precisely position an image on top of a PdfPTable?
    • Why is my cell event not triggered?
  • Page events
    • How to add text as a header or footer?
    • How to add a rectangle to every page of a document?
    • How can I add an image to all pages of my PDF?
    • How to set a fixed background image for all my pages?
    • Why do I get a System.StackOverflowException in the OnEndPage() event handler?
    • How to introduce multiple PdfPageEventHelper instances?
    • How to check for an event and remove it?
    • How to add a text to the left and to the right in a header?
    • How to add a table as a header?
    • How to create a table with 2 rows that can be used as a footer?
    • How to generate a report with dynamic header in PDF using itextsharp?
    • How to add a page number in the header of a PDF/A Level A file?
    • How to rotate a page while creating a PDF document?
    • How to draw a line every 25 words?
    • How to add a border to a paragraph?
    • How to change the color of pages?
  • Parsing XML and XHTML
    • Why is it so difficult to convert XML to PDF?
    • How to adjust the page height to the content height?
    • How to set line spacing when using XML Worker?
    • How to add external CSS while generating PDF?
    • How to do HTML to XML conversion to generate closed tags?
    • How to make a particular sub-string Bold when converting HTML to PDF?
    • How to parse multiple HTML files into a single PDF
    • How to add a rich Textbox (HTML) to a table cell?
    • How to get particular html table contents to write it in PDF?
    • Why doesn’t CSS and RowSpan work?
    • Why is XMLWorker parsing slow?
    • How to export Vietnamese text to PDF using iText?
    • Certain HTML entities (arrows) are not rendered in PDF
    • How to set RTL direction for Hebrew when converting HTML to PDF?
    • How to convert Arabic HTML to PDF?
  • Inspect a PDF with iText
    • Why do I get an “InvalidPdfException: PDF header signature not found”?
    • How to Get PDF page width and height?
    • Why is the page size of a PDF always the same, no matter if it’s landscape or portrait?
    • How to get the UserUnit from a PDF file?
    • How can I read Roman page numbers?
    • How do I get an object if I have its indirect reference?
    • How to read PDFs created with an unknown random owner password?
    • How to get values from comment annotations?
    • How can I find the border color of a field?
    • How to read bookmark titles?
    • How to read bookmarks?
    • How To find internal links in a PDF file?
    • How to extract embedded streams?
  • Manipulating existing PDFs
    • How to update a PDF without creating a new PDF?
    • How to add an image watermark to a PDF file?
    • How to add a watermark to a page with an opaque image?
    • How to watermark PDFs using text or images?
    • How to extend the page size of a PDF to add a watermark?
    • Why does PdfStamper create a file with 0 bytes?
    • How to add blank pages to an existing PDF in java?
    • Adding blank pages while concatenating several PDFs in iText using PdfSmartCopy
    • How to position text relative to page?
    • How can I crop the pages of an existing PDF document?
    • How to rotate a page 90 degrees?
    • How to crop out a part of PDF file?
    • How to rotate and scale pages in an existing PDF?
    • How to shrink pages in an existing PDF?
    • How to fix the orientation of a PDF page in order to scale it?
    • How to reuse a page from one PDF document into another PDF document?
    • How to merge documents correctly?
    • How to add a cover page to an existing PDF document?
    • Why does the function to concatenate / merge PDFs cause issues in some cases?
    • How to merge PDFs from ByteArayOutputStreams?
    • How to merge PDFs and add bookmarks?
    • How to create a TOC when merging documents?
    • How to reorder pages in an existing PDF file?
    • How to reorder the pages of a PDF file?
    • How to set the OCG state of an existing PDF?
    • How to change the order of Optional Content Groups?
    • How to create a PDF with font information and embed the actual font while merging the files into a single PDF?
    • How to decrypt a PDF document with the owner password?
    • How do I add XMP metadata to each page of an existing PDF?
    • How to move the content inside a rectangle inside an existing PDF?
    • How to load a PDF from a stream and add a file attachment?
  • Interactive forms
    • How to fill out a pdf file programmatically? (AcroForm technology)
    • How to fill out a pdf file programmatically? (Dynamic XFA)
    • Is it safe to remove XFA?
    • How to flatten a XFA PDF Form using iTextSharp?
    • How to tell iText which fields to flatten first?
    • How to merge forms from different files into one PDF?
    • How to save an .xfdf file as a .pdf file?
    • How to edit a PDF embedded in the browser and save the PDF directly to server?
    • How to send a ‘success’ response back to Acrobat Reader from a java servlet?
    • Why do I get an error saying that “use of extended features is no longer available”?
    • How to fill XFA form using iText without breaking usage rights?
    • How to deal with missing characters in the default font of a text field?
    • How to make sure a check box is printed?
    • How to check a check box?
    • How to distribute the radio buttons of a radio field across multiple PdfPCells?
    • How to find out which fields are required?
    • How to make a field not required?
    • How to get the number of characters in a field?
    • How to align AcroFields?
    • How to change the text color of an AcroForm field?
    • How to get the color properties of an AcroForm field?
    • How to find the absolute position and dimension of a field?
    • How to move an AcroForm field?
    • How to continue field output on a second page?
    • How to add a table on a form (and maybe insert a new page)?
    • How to add an image to an AcroForm field?
    • How to format a field as a percentage?
    • How to add a hidden text field?
    • How to send a file to the server through a PDF?
    • How to add a text field to an existing pdf template
    • How can I add a new AcroForm field to a PDF?
    • How to underline a portion of text in a text field?
    • Why are the AcroFields in my document empty?
    • How to create a pushbuttonfield with double byte character text?
    • How to define the data encoding when submitting a PDF form using AcroForm technology?
  • Actions and annotations
    • How to create hierarchical bookmarks?
    • How can I add titles of chapters in ColumnText?
    • How to create a link to a specific page number?
    • How to insert a “linked rectangle” with iText?
    • How to add a maps with a pointer to a PDF?
    • How to create a clickable polygon or path?
    • How do I insert a hyperlink to another page with iTextSharp in an existing PDF?
    • How to add a printable or non-printable bitmap stamp to a PDF?
    • How to create a pop-up a window to display images and text?
    • How to stamp image on existing PDF and create an anchor?
    • How to set the BaseUrl of an existing PDF document?
    • How to set zoom level to pdf using iTextSharp?
    • How to change the properties of an annotation?
    • How to create a link to launch an external program?
    • How to attach files to a PDF?
    • How to delete attachments in PDF using iText?
    • How to create a JavaScript action to open the attachments panel?
    • How to add an onMouseOver javaScript action to a TextField?
    • How to define multiple actions for a PushbuttonField?
    • How to add an “In Reply To” annotation?
    • How to get the author of a “free text” annotation?
    • How to change the author name for comments?
    • How to change the color of a circle annotation?
  • Extracting text from PDFs
    • How to remove text from a PDF?
    • How to create and apply redactions?
    • What are the extra characters in the font name of my PDF?
    • How to extract text and anchor information from a PDF?
    • How to read text from a specific position?
    • How to use a text extraction strategy after applying a location extraction strategy?
    • Why can’t I extract text added using a Type3 font correctly from a PDF?
    • How to get the co-ordinates of an image?
    • How to check if a font is bold?
    • Why is the text I extract from an English PDF page garbled?
  • General questions about iText
    • Unit Testing and Automated Testing Questions
    • How to set initial view properties?
    • Why do I get a “Could not find PdfGraphics2D” error?
    • Why can’t I compile the iText source code?
    • Why do I get a BouncyCastle NoClassDefFoundError?
    • How to change the spacing between words and characters?
    • How to add / delete / retrieve information from a PDF using a custom property?
    • How to create an uncompressed PDF file?
    • How to detect if PDF has compressed xref table in Java?
    • How to increase the accuracy of measurements in iTextSharp?
    • How to prevent the resizing of pages in PDF?
    • How to hyphenate text?
    • How to get the current page count?
    • When is the content flushed to a PDF File by itextsharp?
    • How to convert PdfStamper to a byte array?
    • How to create a new PDF file if a file name already exists?
    • How can I serve a PDF to a browser without storing a file on the server side?
    • Why do I get a “getOutputStream() has already been called for this response” error in JSP?
  • Legal questions
    • What is the difference between Lowagie and iText?
    • Can iText 2.1.7 or earlier be used commercially?
    • Can I use iText without respecting the AGPL license?
    • Is iText Java library free of charge or are there any fees to be paid?
    • Can I bundle iText with my non-commercial software?
    • When does Bruno Lowagie act like “kind of a dick”?
  • To be continued…

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub