iText in Action
Creating and Manipulating PDF
Bruno Lowagie
  • November 2006
  • ISBN 9781932394795
  • 688 pages
This title is out of print and no longer for sale.

I've been using iText for over a year, but I still learnt an awful lot while reading this book.

Stephen Kitt, JavaLobby

Second edition of this book is available

Say you need a tool to add dynamic or interactive features to a PDF file and you decide to search on Google for "Java PDF." What do you think you'd find? Why, at the top of the page you'd find "iText," of course. A leading tool for programmatic creation and manipulation of PDF documents, iText is an open source Java library developed and maintained by Bruno Lowagie, the author of this book, with the help of many contributors.

While at the entry level iText is easy to learn, developers find they soon need its more advanced features. Written by the master himself, iText in Action now offers an introduction and a practical guide to the subject—you will gain a sound understanding of the Portable Document Format and how to do interesting and useful things with PDF using iText.

iText in Action introduces iText and lowers the learning curve to its advanced features. Its numerous, valuable examples unlock many of the secrets hidden in Adobe's PDF Reference. The examples are in Java but they can be easily adapted to .NET using one of iText's .NET ports: iTextSharp (C#) or iText.NET (J#).

Table of Contents show full



about this book

Part 1 Introduction

1. iText: when and why

1.1. The history of iText

1.2. iText: first contact

1.3. An almost-true story

1.4. Summary

2. PDF engine jump-start

2.1. Generating a PDF document in five steps

2.2. Manipulating existing PDF files

2.3. Creating PDF in multiple passes

2.4. Summary

3. PDF: why and when

3.1. A document history

3.2. Types of PDF

3.3. PDF version history

3.4. Summary

Part 2 Basic building blocks

4. Composing text elements

4.1. Wrapping Strings in text elements

4.2. Adding extra functionality to text elements

4.3. Chunk characteristics

4.4. Chunks and space distribution

4.5. Anchors revisited

4.6. Generic Chunk functionality

4.7. Making a flyer (part 1)

4.8. Summary

5. Inserting images

5.1. Standard image types

5.2. Working with java.awt.Image

5.3. Byte arrays with image data

5.4. Setting image properties

5.5. Making a flyer (part 2)

5.6. Summary

6. Constructing tables

6.1. Tables in PDF: PdfPTable

6.2. Alternatives to PdfPTable

6.3. Composing a study guide (part 1)

6.4. Summary

7. Constructing columns

7.1. Retrieving the current vertical position

7.2. Adding text to ColumnText

7.3. Composing ColumnText with other building blocks

7.4. Automatic columns with MultiColumnText

7.5. Composing a study guide (part 2)

7.6. Summary

Part 3 PDF text and graphics

8. Choosing the right font

8.1. Defining a font

8.2. Introducing base fonts

8.3. Composite fonts

8.4. Summary

9. Using fonts

9.1. Other writing directions

9.2. Sending a message of peace (part 1)

9.3. Advanced typography

9.4. Automating font creation and selection

9.5. Sending a message of peace (part 2)

9.6. Summary

10. Constructing and painting paths

10.1. Path construction and painting operators

10.2. Working with iText’s direct content

10.3. Graphics state operators

10.4. Changing the coordinate system

10.5. Drawing a map of a city (part 1)

10.6. Summary

11. Adding color and text

11.1. Adding color to PDF files

11.2. The transparent imaging model

11.3. Clipping content

11.4. PDF’s text state

11.5. The map of Foobar (part 2)

11.6. Summary

12. Drawing to Java Graphics2D

12.1. Obtaining a Java.awt.Graphics2D instance

12.2. Two-dimensional graphics in the real world

12.3. PDF’s optional content

12.4. Enhancing the map of Foobar

12.5. Summary

Part 4 Interactive PDF

13. Browsing a PDF document

13.1. Changing viewer preferences

13.2. Visualizing thumbnails

13.3. Adding page transitions

13.4. Adding bookmarks

13.5. Introducing actions

13.6. Enhancing the course catalog

13.7. Summary

14. Automating PDF creation

14.1. Creating a page

14.2. Common page event functionality

14.3. Alternative XML solutions

14.4. Enhancing the course catalog (part 2)

14.5. Summary

15. Creating annotations and fields

15.1. Introducing annotations

15.2. Creating an AcroForm

15.3. Submitting a form

15.4. Comparing HTML and PDF forms

15.5. Summary

16. Filling and signing AcroForms

16.1. Filling in the fields of an AcroForm

16.2. Working with FDF and XFDF files

16.3. Signing a PDF file

16.4. Verifying a PDF file

16.5. Summary

17. iText in web applications

17.1. Writing PDF to the ServletOutputStream: pitfalls

17.2. Putting the theory into practice

17.3. Summary

18. Under the hood

18.1. Inside iText and PDF

18.2. Extracting and editing text

18.3. Rendering PDF

18.4. Manipulating PDF files

18.5. Summary

Appendix A: Class diagrams

Appendix B: Creating barcodes

Appendix C: Open parameters

Appendix D: Signing a PDF with a smart card

Appendix E: Dealing with exceptions

Appendix F: Pdf/X, Pdf/A, and tagged PDF

Appendix G: Resources


What's inside

How to

  • Serve PDF 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
  • And much more

About the author

Bruno Lowagie is the original developer and one of the current maintainers of iText. He works for Ghent University and lives in Ghent, Belgium with his wife and two sons.