iText in action
Book information
Description
With iText, one can transform PDF documents into live, interactive applications quickly and easily. This free and open source library for Java and .NET is the leading tool of its kind, and was primarily developed and maintained by Bruno Lowagie, the author of this book.iText in Action, Second Edition offers an introduction and a practical guide to iText and the internals of PDF. While at the entry level iText is easy to learn, there's an astonishing range of things you can do once you dive below the surface. This book lowers the learning curve and, through numerous innovative and practical examples, unlocks the secrets hidden in Adobe's PDF Reference.This totally revised new edition introduces the new functionality added to iText in recent releases, and it updates all examples from JDK 1.4 to Java 5. The examples are in Java but they can be easily adapted to.NET. 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. iText in Action, Second Edition......Page 1 brief contents......Page 8 contents......Page 10 preface......Page 18 preface to the first edition......Page 20 acknowledgments......Page 22 Who should read this book?......Page 24 Creating PDF documents......Page 25 Under the hood......Page 26 Software requirements and downloads......Page 27 about the title......Page 29 about the cover illustration......Page 30 Creating PDF documents from scratch......Page 32 Introducing PDF and iText......Page 34 1.1 Things you can do with PDF......Page 35 1.2 Working with the examples in this book......Page 37 1.3 Creating a PDF document in five steps with iText......Page 39 1.3.1 Creating a new Document object......Page 40 1.3.2 Getting a PdfWriter instance......Page 43 1.3.3 Opening the Document......Page 44 1.3.4 Adding content......Page 46 1.3.5 Closing the Document......Page 48 1.4 Summary......Page 50 Using iText’s basic building blocks......Page 51 2.1 Illustrating the examples with a real-world database......Page 52 2.2 Adding Chunk, Phrase, Paragraph, and List objects......Page 53 2.2.1 The Chunk object: a String, a Font, and some attributes......Page 54 2.2.2 The Phrase object: a List of Chunks with leading......Page 56 2.2.3 Paragraph object: a Phrase with extra properties and a newline......Page 61 2.2.4 Distributing text over different lines......Page 65 2.2.5 The List object: a sequence of Paragraphs called ListItem......Page 68 2.2.6 The DrawInterface: vertical position marks, separators, and tabs......Page 72 2.3 Adding Anchor, Image, Chapter, and Section objects......Page 77 2.3.1 The Anchor object: internal and external links......Page 78 2.3.2 Chapter and Section: get bookmarks for free......Page 80 2.3.3 The Image object: adding raster format illustrations......Page 82 2.3.4 Summary......Page 87 Adding content at absolute positions......Page 88 3.1.1 Direct content layers......Page 89 3.1.2 Graphics state and text state......Page 91 3.1.3 A real-world database: three more tables......Page 93 3.2.1 Convenience method: PdfContentByte.showTextAligned()......Page 98 3.2.2 Convenience method: ColumnText.showTextAligned()......Page 101 3.3 Working with the ColumnText object......Page 105 3.3.1 Using ColumnText in text mode......Page 106 3.3.2 Using ColumnText in composite mode......Page 112 3.4.1 Image XObjects......Page 115 3.4.2 The PdfTemplate object......Page 118 3.5 Summary......Page 123 Organizing content in tables......Page 124 4.1.1 Your first PdfPTable......Page 125 4.1.2 PdfPTable properties......Page 126 4.2 Changing the properties of a cell......Page 129 4.2.1 PdfPCell in text mode......Page 130 4.2.2 PdfPCell in composite mode......Page 138 4.3.1 Repeating headers and footers......Page 143 4.3.2 Splitting tables......Page 144 4.3.3 Memory management for LargeElement implementations......Page 146 4.4.1 Working with writeSelectedRows()......Page 147 4.4.2 Wrapping tables in columns......Page 150 4.5 Summary......Page 152 Table, cell, and page events......Page 153 5.1.1 Implementing the PdfPTableEvent interface......Page 154 5.1.2 Implementing the PdfPCellEvent interface......Page 156 5.1.3 Combining table and cell events......Page 159 5.2 Events for basic building blocks......Page 164 5.2.1 Generic Chunk functionality......Page 165 5.2.3 Chapter and Section events......Page 169 5.2.4 Page order and blank pages......Page 172 5.3 Overview of the page boundaries......Page 173 5.3.1 The media box......Page 174 5.3.2 The crop box......Page 176 5.3.3 Other page boundaries......Page 178 5.4.1 Adding a header and a footer......Page 179 5.4.2 Solving the “page X of Y” problem......Page 181 5.4.3 Adding a watermark......Page 183 5.4.4 Creating a slideshow......Page 185 5.5 Summary......Page 186 Manipulating existing PDF documents......Page 188 Working with existing PDFs......Page 190 6.1.1 Retrieving information about the document and its pages......Page 191 6.1.2 Reducing the memory use of PdfReader......Page 194 6.2 Copying pages from existing PDF documents......Page 195 6.2.1 Importing pages......Page 196 6.2.2 Scaling and superimposing pages......Page 198 6.2.3 N-up copying and tiling PDF documents......Page 201 6.3.1 Adding content at absolute positions......Page 204 6.3.2 Creating a PDF in multiple passes......Page 206 6.3.3 Adding company stationery to an existing document......Page 207 6.3.4 Inserting pages into an existing document......Page 209 6.3.5 Filling out a PDF form......Page 210 6.4 Copying pages with PdfCopy......Page 217 6.4.1 Concatenating and splitting PDF documents......Page 218 6.4.2 PdfCopy versus PdfSmartCopy......Page 220 6.4.3 Concatenating forms......Page 222 6.5 Summary......Page 223 Making documents interactive......Page 225 7.1.1 Document-navigation actions......Page 226 7.1.2 Explicit destinations......Page 230 7.1.3 JavaScript in PDF documents......Page 233 7.1.4 More actions......Page 236 7.2.1 Creating bookmarks for a new document......Page 239 7.2.2 Retrieving bookmarks from an existing document......Page 241 7.2.3 Adding bookmarks to an existing document......Page 243 7.2.4 Concatenating documents with bookmarks......Page 244 7.2.5 Open parameters......Page 245 7.3.1 Text annotations......Page 246 7.3.2 Link annotations......Page 251 7.3.3 File attachments......Page 253 7.3.4 Stamp, line, and rectangle annotations......Page 255 7.4.1 Triggering JavaScript from a button......Page 257 7.4.2 Showing and hiding an annotation......Page 258 7.4.3 A popup triggered by a button that doesn’t need to be pushed......Page 260 7.4.4 Additional actions......Page 262 7.4.5 A PDF calculator......Page 263 7.5 Summary......Page 265 Filling out interactive forms......Page 267 8.1 Introducing AcroForms......Page 268 8.2.1 Radio fields and radio buttons......Page 269 8.2.2 Check boxes......Page 271 8.2.3 Pushbuttons......Page 272 8.3.1 Creating text fields......Page 275 8.3.2 Filling out text fields......Page 278 8.3.3 Text fields and fonts......Page 280 8.4 Selecting options with choice fields......Page 283 8.4.1 Creating lists and combo boxes......Page 284 8.5 Refining the form-filling process......Page 286 8.5.1 Choosing field names......Page 287 8.5.2 Optimizing the filling process......Page 288 8.5.3 Partial form flattening......Page 289 8.5.4 Customized form flattening......Page 291 8.6 Introducing the XML Forms Architecture (XFA)......Page 295 8.6.1 Static XFA forms......Page 296 8.6.2 Dynamic XFA forms......Page 301 8.7 Preserving the usage rights of Reader-enabled forms......Page 306 8.7.1 Reader-enabling a form using Adobe Acrobat......Page 307 8.7.2 Filling out Reader-enabled forms using iText......Page 308 8.8 Summary......Page 309 Essential iText skills......Page 312 Integrating iText in your web applications......Page 314 9.1.1 The five steps of PDF creation in a web application......Page 315 9.1.2 Troubleshooting web applications......Page 317 9.1.3 Generating a PDF from a JSP page......Page 322 9.2.1 Adding a submit button to an existing form......Page 324 9.2.2 Filling out a form on the server side......Page 329 9.2.3 FDF and XFDF in web applications......Page 330 9.3 JavaScript communication between HTML and PDF......Page 335 9.4 Creating basic building blocks from HTML and XML......Page 338 9.4.1 Parsing HTML......Page 339 9.4.2 Parsing XML......Page 343 9.5 Summary......Page 346 Brightening your document with color and images......Page 348 10.1.1 Device colors......Page 349 10.1.2 Spot colors......Page 351 10.1.3 Painting patterns......Page 352 10.1.4 Transparency......Page 356 10.2 Overview of supported image types......Page 360 10.2.1 JPEG, JPEG2000, GIF, PNG, BMP, WMF, TIFF, and JBIG2......Page 361 10.2.2 Creating a raw image......Page 363 10.2.3 CCITT compressed images......Page 364 10.2.4 Creating barcodes......Page 365 10.2.6 Compressing images......Page 369 10.2.7 Images consisting of multiple pages or frames......Page 371 10.3.1 Images and transparency......Page 372 10.3.2 Masking images......Page 375 10.3.3 Clipping images......Page 376 10.4 Summary......Page 379 11.1 Getting fonts from a file......Page 380 11.1.1 Font files and their extensions......Page 381 11.1.2 Type 1 fonts......Page 383 11.1.3 TrueType and OpenType fonts......Page 384 11.2 Examining font types from a PDF perspective......Page 385 11.2.1 Simple fonts......Page 386 11.2.2 Composite fonts......Page 388 11.3.1 Overview of the Font classes......Page 390 11.3.2 Type 3 fonts......Page 392 11.3.3 CJK fonts......Page 394 11.3.4 Writing from right to left......Page 397 11.3.5 Advanced typography......Page 400 11.4 Automating font creation and selection......Page 404 11.4.1 Getting a Font from the FontFactory......Page 405 11.4.2 Automatic font selection......Page 408 11.5 Summary......Page 410 Protecting your PDF......Page 411 12.1.1 The info dictionary......Page 412 12.1.2 The Extensible Metadata Platform (XMP)......Page 414 12.2.1 Compression levels......Page 416 12.2.2 Compressing and decompressing existing files......Page 417 12.3.1 Creating a password-encrypted PDF......Page 418 12.3.2 Public-key encryption......Page 421 12.4.1 Creating an unsigned signature field......Page 426 12.4.2 Signing a PDF......Page 427 12.4.3 Adding multiple signatures......Page 430 12.4.4 Verifying the signatures in a document......Page 433 12.4.5 Creating the digest and signing externally......Page 434 12.4.6 CRLs, OCSP, and timestamping......Page 436 12.4.7 PDF Advanced Electronic Signatures (PAdES) profiles......Page 440 12.5 Summary......Page 441 Under the hood......Page 442 PDFs inside-out......Page 444 13.1.2 The history of PDF......Page 445 13.1.3 PDF as an ISO standard......Page 449 13.1.4 PDF/X, PDF/A, PDF/E, PDF/UA, and other types of PDF......Page 450 13.2.1 Basic PDF objects......Page 455 13.2.2 The PDF file structure......Page 457 13.2.3 Climbing up the object tree......Page 463 13.3 Exploring the root of a PDF file......Page 465 13.3.1 Page layout, page mode, and viewer preferences......Page 466 13.3.2 Pages and page labels......Page 472 13.3.3 Outlines, destinations, and names......Page 477 13.3.4 AcroForms revisited......Page 478 13.4 Summary......Page 482 The imaging model......Page 483 14.1 Examining the content stream......Page 484 14.2.1 Constructing paths......Page 485 14.2.2 Painting and clipping paths......Page 487 14.2.3 Convenience methods to draw shapes......Page 490 14.3 Overview of the graphics state methods......Page 491 14.3.1 Line characteristics......Page 492 14.3.2 Colors......Page 495 14.3.3 Changing the coordinate system......Page 497 14.3.4 Affine transformations using Java......Page 501 14.4.1 Text state operators......Page 502 14.4.2 Text-positioning and text-showing operators......Page 503 14.4.3 Convenience methods for text......Page 507 14.5 Using java.awt.Graphics2D......Page 508 14.5.1 Drawing content to PdfGraphics2D......Page 509 14.5.2 Drawing text to PdfGraphics2D......Page 514 14.6 Summary......Page 523 15.1 Making content visible or invisible......Page 524 15.1.1 Optional content groups......Page 525 15.1.2 Adding structure to layers......Page 526 15.1.3 Optional content membership......Page 531 15.1.4 Changing the state of a layer with an action......Page 532 15.1.5 Optional content in XObjects and annotations......Page 534 15.2.1 Object data......Page 537 15.2.2 Section 508 and accessibility......Page 539 15.2.3 Adding structure......Page 542 15.3.1 Examining the content stream with PRTokeniser......Page 545 15.3.2 Processing content streams with PdfContentStreamProcessor......Page 548 15.3.3 Extracting text with PdfReaderContentParser and PdfTextExtractor......Page 550 15.3.4 Finding text margins......Page 554 15.3.5 Extracting images......Page 555 15.4 Summary......Page 556 16.1 Finding and replacing image and font streams......Page 557 16.1.1 Adding a special ID to an Image......Page 558 16.1.2 Resizing an image in an existing document......Page 559 16.1.3 Listing the fonts used......Page 560 16.1.4 Replacing a font......Page 562 16.2.1 File attachment annotations......Page 564 16.2.2 Document-level attachments......Page 566 16.2.3 Go to embedded file action......Page 567 16.2.4 PDF packages, portable collections, or portfolios......Page 569 16.3.1 Movie annotations......Page 576 16.3.2 3D annotations......Page 577 16.3.3 Embedding Flash into a PDF......Page 579 16.3.4 Establishing communication between Flex and PDF......Page 586 16.4 Summary......Page 589 A.1.2 Presentations (PDF documents)......Page 594 A.5 Other publications......Page 595 B.1.2 iText in Action links......Page 596 B.3.2 Fonts......Page 597 B.4.2 Movie links......Page 598 A......Page 600 B......Page 601 C......Page 602 D......Page 603 F......Page 604 H......Page 606 I......Page 607 M......Page 608 O......Page 609 P......Page 610 R......Page 612 S......Page 613 T......Page 614 V......Page 615 Z......Page 616 Back cover......Page 617
Similar books
Информатика: конспект лекций
TXT
Исполнительный Робот, или Головоломки для программистов (Демо)
RAR
Спортивное программирование. Сборник рецептов для программирующих на С++
Сборник задач и упражнений по языку С++
Информатиканың қолданбалы есептері пәні бойынша
Учебное пособие по вычислительной технике и информационным технологиям
DOC
Microsoft Office: от начинающего пользователя до профессионала. Часть 1. Microsoft Office для пользователя
MOBI
Microsoft Office: от начинающего пользователя до профессионала. Часть 1. Microsoft Office для пользователя
FB2