Crear documentos en pdf
iText in Action
CREATING AND MANIPULATING PDF
BRUNO LOWAGIE
MANNING
Greenwich (74° w. long.)
For online information and ordering of this and other Manning books, go to www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. Cherokee Station PO Box20386 Fax: (609) 877-8256 New York, NY 10021 email: orders@manning.com ©2007 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers andsellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books they publish printed on acid-free paper, and we exert our bestefforts to that end.
Manning Publications Co. Cherokee Station Copyeditor: Tiffany Taylor PO Box 20386 Typesetter: Denis Dalinnik New York, NY 10021 Cover designer: Leslie Haimes
ISBN 1932394796 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 10 09 08 07 06
To my wife, Ingeborg
brief contents
PART 1
INTRODUCTION......................................................1
1 2 3
■
iText: when and why PDF engine jump-start PDF: why and when
3 30 73
■
■
PART 2
BASIC BUILDING BLOCKS ......................................97
4 5 6 7
■
Composing text elements 99 Inserting images 135 162 193 Constructing tables
■
■
■
Constructing columns
PART 3
PDF TEXT AND GRAPHICS ..................................221
8 9 10
■
Choosingthe right font Using fonts 257
223 283
■
■
Constructing and painting paths
vii
viii
BRIEF CONTENTS
11 12
■
Adding color and text
325 356
■
Drawing to Java Graphics2D
PART 4
INTERACTIVE PDF .............................................393
13 14 15 16 17 18
■
Browsing a PDF document
395 464 501
■
Automating PDF creation 425 Creatingannotations and fields Filling and signing AcroForms iText in web applications Under the hood 562 533
■
■
■
■
contents
preface xix acknowledgments xxi about this book xxiii
PART 1 INTRODUCTION .................................................... 1
1
iText: when and why
1.1
How iText was born Beyond Java 9
3
5
■
The history of iText 5
iText today 7
1.2
iText:first contact 10
Running the examples in the book 11 Experimenting with the iText toolbox 12
1.3
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
■
1.4
Summary
29
ix
x
CONTENTS
2
PDF engine jump-start 30
2.1 Generating a PDFdocument 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
■
2.2
Manipulating existing PDF files
■ ■
48
Reading an existing PDF file 49 Using PdfStamper to change document properties 54 Using PdfStamper to add content 55 Introducing imported pages 60 Using imported pages withPdfWriter 61 Manipulating existing PDF files with PdfCopy 64 Concatenating forms with PdfCopyFields 66 Summary of the manipulation classes 67
■ ■ ■ ■ ■
2.3
Creating PDF in multiple passes 68
Stamp first, then copy 69 Copy first, then stamp 70 Stamp, copy, stamp 71
■ ■
2.4
Summary
72
3
PDF: why and when 73
3.1 A document history 74
Adobe and documents 75 The Acrobat family...
Regístrate para leer el documento completo.