Casino

Playing slot machines is a great hobby that Casino770 members love because it's free!

What is iText®?

What is iText®?

If you look at PDF creation, you’ll find that graphical designers use desktop applications such as Adobe Acrobat or Adobe InDesign to create a document in a manual or semimanual process. In another context, PDF documents are created programmatically, using an API to produce PDFs directly from software applications, without—or with minimal—human intervention. Sometimes the document is created in an intermediary format first, and then converted to PDF. These different approaches demand different software products. The same goes for PDF manipulation. You can update a PDF manually in Adobe Acrobat, but there are also tools that allow forms to be filled out automatically based on information from a database.
iText is a tool that focuses on the automation side of things.

iText is a PDF library

iText is an API that was developed to allow developers to do the following (and much more):
  • Generate documents and reports based on data from an XML file or a database
  • Create maps and books, exploiting numerous interactive features available in PDF
  • Add bookmarks, page numbers, watermarks, and other features to existing PDF documents
  • Split or concatenate pages from existing PDF files
  • Fill out interactive forms
  • Serve dynamically generated or manipulated PDF documents to a web browser
iText is not an end-user tool. You have to build iText into your own applications so that you can automate the PDF creation and manipulation process.

When to use iText?

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.

Quick functionality overview

The diagram below shows an overview of the things you can do with PDF.

overview of possible PDF functionality

The functionality covered by iText is marked with the following dots:
bullet Supported by iText
bullet Partly supported by iText
iText’s main purpose is to create and manipulate PDF documents.

CREATING PDFS

With the Document and the PdfWriter class, you can create PDF documents from scratch from a database, an XML file, or any other data source. You can do this in three different ways:
  • using high-level objects such as Chunk, Phrase, Paragraph, List, and so on. These objects are often referred to as iText’s basic building blocks.
  • using low-level functionality. This is done with PdfContentByte, a class that consists of a series of methods that map to every operator and operand available in Adobe’s imaging model. This class also has numerous convenience methods to draw arcs, circles, rectangles and text at absolute positions.
  • Using PdfGraphics2D which is iText’s implementation of the abstract Graphics2D class in Java (not available in iTextSharp).
iText ships with a plethora of classes that support ecnryption, different image types, color spaces, fonts. There’s functionality to enhance the accessibility of the PDF file, support for the integration of Flash apps into the PDF, and so on.
iText can convert an XML or an XHTML/CSS file to PDF (using XML Worker). Converting documents from one format to another is outside the scope of iText. And no: iText does not convert Word documents to PDF!

UPDATING PDFS

You always need a PdfReader instance to access an existing document. You can use this reader in combination with PdfStamper to stamp extra content on the existing PDF document: page numbers, a watermark, annotations, and so on. PdfStamper is also the class you’ll use to fill out interactive forms. iText has almost complete support for AcroForms, but as soon as you have a form involving the XML Forms Architecture, the possibilities are limited.
You can split and merge PDF documents with PdfCopy, PdfSmartCopy, PdfCopyFields, and even using PdfImportedPage objects in combination with PdfWriter or PdfStamper.
Converting a PDF document to another format is outside the scope of iText, but you can convert a PDF to XML if the PDF was tagged and contains a structure tree. Depending on how the PDF was created, you can also extract plain text from a page.
iText can also be used to sign existing PDF documents, as well as to encrypt them.

READING PDFS

iText isn’t a PDF viewer, iText can’t convert PDF to an image, nor can iText be used to print a PDF, but the PdfReader class can give you access to the objects that form a PDF document and to the the content stream of each page. This content stream can be parsed and if the content wasn’t added as rasterized text, you can convert a page to plain text. Note that iText doesn’t do OCR.
For a full overview, please read the table of contents of the book about iText: iText in Action, second edition. You can also consult the changelogs going back to the very first versions of iText in 1998.