iText in Action: Creating and Manipulating PDF

( 1 )

Overview

Imagine a publisher who wants to "stamp" his ebooks on the fly with the name of the buyer (to discourage sharing). Such a publisher would (and we know one who does) use iText for the task. Developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation will find this book unique in content and readability. Based on ongoing examples that encourage learning "in action," they will finally understand PDF and learn how to build applications that produce professional, ...

See more details below
Other sellers (Paperback)
  • All (16) from $4.27   
  • New (9) from $12.85   
  • Used (7) from $4.27   
Sending request ...

Overview

Imagine a publisher who wants to "stamp" his ebooks on the fly with the name of the buyer (to discourage sharing). Such a publisher would (and we know one who does) use iText for the task. Developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation will find this book unique in content and readability. Based on ongoing examples that encourage learning "in action," they will finally understand PDF and learn how to build applications that produce professional, high-quality PDF documents. While the basic functionality of iText is easy to acquire, iText in Action lowers the learning curve for more advanced functionality. It explains how to use iText to create/manipulate PDF documents on-the-fly in one or more of the following situations:

  • Due to time or size, the PDF documents can't be produced manually
  • The content of the document must be calculated or based on user input.
  • The content needs to be customized or personalized.
  • The PDF content needs to be served in a web environment.
  • Documents are to be created in "batch process" mode.

All the examples are written in Java, but they can be easily adapted to .NET by developers using one of the .NET ports: iTextSharp (C#) or iText.NET (#J). While iText is a free Java library and the examples are written from the point of view of the Java developer, nine out of ten examples can be run by .NET developers with only minimal changes.

Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.

Developers looking to enhance Web and other applications with dynamic PDF document generation and/or manipulation will find this book unique in content and readability.

Read More Show Less

Product Details

  • ISBN-13: 9781932394795
  • Publisher: Manning Publications Company
  • Publication date: 12/28/2006
  • Pages: 656
  • Product dimensions: 7.40 (w) x 9.20 (h) x 1.40 (d)

Meet the Author

Bruno Lowagie has been programming since he was twelve years old. He has a degree in civil architectural engineering and is the initial developer and one of the current maintainers of iText. He works at Ghent University, Belgium.

Read More Show Less

Table of Contents


Preface     xix
Acknowledgments     xxi
About this book     xxiii
Introduction     1
iText: when and why     3
The history of iText     5
How iText was born     5
iText today     7
Beyond Java     9
iText: first contact     10
Running the examples in the book     11
Experimenting with the iText toolbox     12
An almost-true story     14
Some Foobar fiction     15
A document daydream     16
Welcoming the student     18
Producing and processing interactive documents     23
Making the dream come true     28
Summary     29
PDF engine jump-start     30
Generating a PDF document in five steps     31
Creating a new document object     32
Getting a DocWriter instance     35
Opening the document     37
Adding content     42
Closing the document     46
Manipulating existing PDF files     48
Reading an existing PDF file     49
Using PdfStamper to change document properties     54
Using PdfStamper toadd content     55
Introducing imported pages     60
Using imported pages with PdfWriter     61
Manipulating existing PDF files with PdfCopy     64
Concatenating forms with PdfCopyFields     66
Summary of the manipulation classes     67
Creating PDF in multiple passes     68
Stamp first, then copy     69
Copy first, then stamp     70
Stamp, copy, stamp     71
Summary     72
PDF: why and when     73
A document history     74
Adobe and documents     75
The Acrobat family     77
The intellectual property of the PDF specification     78
Types of PDF     79
Traditional PDF     80
Tagged PDF     80
Linearized PDF     81
PDFs preserving native editing capabilities     81
PDF types that became an ISO standard     81
PDF forms, FDF, and XFDF     83
XFA and XDP     84
Rules of thumb     84
PDF version history     85
Changing the user unit     86
PDF content and compression     88
Encryption     90
Summary      95
Basic Building Blocks     97
Composing text elements     99
Wrapping Strings in text elements     100
The atomic building block: com.lowagie.text.Chunk     101
An Array List of Chunks: com.lowagie.text.Phrase     103
A sequence of Phrases: com.lowagie.text.Paragraph     104
Adding extra functionality to text elements     105
External and internal links: com.lowagie.text.Anchor     106
Lists and ListItems: com.lowagie.text.List/ListItem     107
Automatic bookmarking: com.lowagie.text. Chapter/Section     109
Chunk characteristics     111
Measuring and scaling     111
Lines: underlining and striking through text     112
TextRise: sub- and superscript     115
Simulating italic fonts: skewing text     116
Changing font and background colors     117
Simulating bold fonts: stroking vs. filling     117
Chunks and space distribution     118
The split character     119
Hyphenation     120
Changing the Char Space ratio     121
Anchors revisited     122
Remote Goto     123
Local Goto     124
Generic Chunk functionality     125
Drawing custom backgrounds and lines     125
Implementing custom functionality     126
Building an index     127
Making a flyer (part 1)     129
Summary     134
Inserting images     135
Standard image types     136
BMP, EPS, GIF, JPEG, PNG, TIFF, and WMF     137
TIFF with multiple pages     139
Animated GIFs     139
Working with java.awt.Image     140
Byte arrays with image data     143
Raw image data     144
CCITT compressed images     145
Creating barcodes     146
Working with com.lowagie.text.pdf.PdfTemplate     147
Setting image properties     147
Adding images to the document     147
Translating, scaling, and rotating images     151
Image masks     156
Making a flyer (part 2)     158
Getting the Image instance     158
Setting the border, the alignment, and the dimensions     159
The resulting PDF     160
Summary     161
Constructing tables     162
Tables in PDF: PdfPTable     163
Your first PdfPTable     163
Changing the width and alignment of a PdfPTable     164
Adding PdfPCells to a PdfPTable     167
Special PdfPCell constructors     176
Working with large tables     178
Adding a PdfPTable at an absolute position     182
Alternatives to PdfPTable     186
Composing a study guide (part 1)     189
The data source     189
Generating the PDF     190
Summary     192
Constructing columns     193
Retrieving the current vertical position     194
Adding text to ColumnText     197
Different ways to add text to a column     197
Keeping paragraphs together     199
Adding more than one column to a page     201
Composing ColumnText with other building blocks     206
Combining text mode with images and tables     207
ColumnText in composite mode     209
Automatic columns with MultiColumnText     211
Regular columns with MultiColumnText     211
Irregular columns with MultiColumnText     213
Composing a study guide (part 2)     216
Summary     219
PDF Text and Graphics     221
Choosing the right font     223
Defining a font     224
Using the right terminology     225
Standard Type 1 fonts     226
Introducing base fonts     231
Working with an encoding     232
Class BaseFont and Type 1 fonts     233
Embedding Type 3 fonts     238
Working with TrueType fonts     239
Working with OpenType fonts     243
Composite fonts     248
What is Unicode?     248
Introducing Chinese, Japanese, Korean (CJK) fonts     251
Embedding CIDFonts     252
Using TrueType collections     254
Summary     255
Using fonts     257
Other writing directions     258
Vertical writing     258
Writing from right to left     260
Sending a message of peace (part 1)     262
Advanced typography     264
Handling diacritics     265
Dealing with ligatures     268
Automating font creation and selection     271
Getting a Font object from the FontFactory     271
Automatic font selection     276
Sending a message of peace (part 2)     279
Summary      282
Constructing and painting paths     283
Path construction and painting operators     284
Seven path construction operators     284
Path-painting operators     286
Working with iText's direct content     294
Direct content layers     295
PdfPTable and PdfPCell events     296
Graphics state operators     303
The graphics state stack     303
Changing the characteristics of a line     305
Changing the coordinate system     313
The CTM     313
Positioning external objects     316
Drawing a map of a city (part 1)     321
The XML/SVG source file     321
Parsing the SVG file     323
Summary     324
Adding color and text     325
Adding color to PDF files     326
Device colorspaces     326
Separation colorspaces     328
Painting patterns     329
Using color with basic building blocks     334
The transparent imaging model     335
Transparency groups     336
Isolation and knockout     338
Applying a soft mask to an image     340
Clipping content     341
PDF's text state     344
Text objects     344
Convenience methods to position and show text     350
The map of Foobar (part 2)     353
Summary     355
Drawing to Java Graphics2D     356
Obtaining a Java.awt.Graphics2D instance     357
A simple example from Sun's tutorial     358
Mapping AWT fonts to PDF fonts     362
Drawing glyph shapes instead of using a PDF font     365
Two-dimensional graphics in the real world     368
Exporting Swing components to PDF     368
Drawing charts with JFreeChart     371
PDF's optional content     374
Making content visible or invisible     374
Adding structure to layers     375
Using a PdfLayer     378
Optional content membership     380
Changing the state of a layer with an action     382
Optional content in XObjects and annotations     384
Enhancing the map of Foobar     385
Defining the layers for the map and the street names     386
Combining iText and Apache Batik     388
Adding tourist information to the map     389
Summary      392
Interactive PDF     393
Browsing a PDF document     395
Changing viewer preferences     396
Setting the page layout     397
Choosing the page mode     398
Viewer options     399
Visualizing thumbnails     401
Changing the page labels     402
Changing the thumbnail image     404
Adding page transitions     405
Adding bookmarks     407
Creating destinations     407
Constructing an outline tree     409
Adding actions to an outline tree     410
Retrieving bookmarks from an existing PDF file     411
Manipulating bookmarks in existing PDF files     413
Introducing actions     415
Actions to go to an internal destination     415
Actions to go to an external destination     417
Triggering actions from events     418
Adding JavaScript to a PDF document     420
Launching an application     420
Enhancing the course catalog     421
Summary     424
Automating PDF creation     425
Creating a page     426
Adding empty pages     426
Defining page boundaries      427
Reordering pages     431
Common page event functionality     432
Overview of the PdfPageEvent methods     432
Adding a header and a footer     433
Adding page X of Y     435
Adding watermarks     438
Creating an automatic slide show     440
Automatically creating bookmarks     442
Automatically creating a table of contents     443
Alternative XML solutions     445
Writing a letter on company stationery     445
Parsing a play     451
Parsing (X)HTML     456
Using HtmlWorker to parse HTML snippets     458
Enhancing the course catalog (part 2)     461
Summary     463
Creating annotations and fields     464
Introducing annotations     465
Simple annotations     465
Other types of annotations     470
Adding annotations to a chunk or image     474
Creating an AcroForm     475
Button fields     476
Creating text fields     482
Creating choice fields     486
Submitting a form     488
Choosing field names     488
Adding actions to the pushbuttons     491
Adding actions     496
Comparing HTML and PDF forms     498
Summary     500
Filling and signing AcroForms     501
Filling in the fields of an AcroForm     502
Retrieving information about the fields (part 1)     503
Filling fields     505
Retrieving information from a field (part 2)     508
Flattening a PDF file     510
Optimizing the flattening process     511
Working with FDF and XFDF files     514
Reading and writing FDFfiles     514
Reading XFDF files     517
Signing a PDF file     518
Adding a signature field to a PDF file     518
Using public and private keys     520
Generating keys and certificates     521
Signing a document     523
Verifying a PDF file     529
Summary     532
iText in web applications     533
Writing PDF to the ServletOutputStream: pitfalls     534
Solving problems related to content type-related problems     536
Troubleshooting the blank-page problem     537
Problems with PDF generated from JSP     542
Avoiding multiple hits per PDF      543
Workaround for the timeout problem     545
Putting the theory into practice     550
A personalized course catalog     550
Creating a learning agreement form     553
Reading an FDF file in a JSP page     559
Summary     561
Under the hood     562
Inside iText and PDF     563
Factors of success     563
The file structure of a PDF document     564
Basic PDF objects     569
Climbing up the object tree     570
Extracting and editing text     574
Reading a page's content stream     574
Why iText doesn't do text extraction     576
Why you shouldn't use PDF as a format for editing     578
Rendering PDF     581
How to print a PDF file programmatically     581
Printing a PDF file in a web application     583
Manipulating PDF files     584
Toolbox tools     585
The learning agreement (revisited)     587
Summary     590
Class diagrams     591
Creating barcodes     602
Open parameters     618
Signing a PDF with a smart card     621
Dealing with exceptions     624
Pdf/X, Pdf/A and tagged PDF     630
Resources     638
Index     642
Read More Show Less

Customer Reviews

Average Rating 4
( 1 )
Rating Distribution

5 Star

(0)

4 Star

(1)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Posted March 4, 2010

    Authoritative--but out of date

    This book, iText in Action, is the first edition; while it is entirely authoritative (it's written by the author of the iText package) it is somewhat out of date.

    It is out of date for two reasons: first, it only provides information for the iText 4.0.x library and earlier; the iText developers have released version 5.0 (in December 2009), and the 5.0 object model is substantially different. If your development needs are simple, you can happily use this edition with the 5.0 library--BUT, you probably won't know if your needs are simple until after you have spent some time in this book and with the 5.0 library. Far better to get the new edition in the first place.

    This edition is also out of date because Adobe has released several new versions ("flavors") of PDF: PDF/A, PDF/E, and PDF/X. The first edition of this book does not address those file types at all--if you're working with those files, this edition will provide you with little help.

    I sincerely hope that Barnes & Noble will carry the second edition--this is the standard reference work on an extremely valuable software library.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)