Chapters
-
Introducing PDF and iText
-
Using iText's basic building blocks
-
Adding content at absolute positions
-
Organizing content in tables
-
Table, cell, and page events
-
Working with existing PDFs
-
Making documents interactive
-
Filling out interactive forms
-
Integrating iText in your web applications
-
Brightening up your PDF with color and images
-
Choosing the right font
-
Protecting your PDF
-
PDFs inside-out
-
The imaging model
-
Page content and structure
-
PDF streams
Chapter 3:
Adding content at absolute positions
< Chapter 2: Using iText's basic building blocks
Chapter 4: Organizing content in tables >
Chapter 3 of the book iText in Action 2E covers:
- Low-level access to page content, aka direct content
- Convenience methods to write direct content
- Using the
ColumnTextobject - Reusing content with the
PdfTemplateobject
This chapter describes how to write PDF syntax directly to the content stream of the page.
It covers the basics, but quickly moves on to convenience methods that hide some of the complexity of PDF.
It also discusses the
ColumnText object, an object that allows you to add basic building blocks at absolute positions.- 3.1: Introducing the concept of direct content
- 3.1.1: Direct content layers
- 3.1.2: Graphics state and text state
- 3.1.3: A real-world database: three more tables
- 3.1.1: Direct content layers
- 3.2: Adding text at absolute positions
- 3.2.1: Convenience method: PdfContentByte.showTextAligned()
- 3.2.2: Convenience method: ColumnText.showTextAligned()
- 3.2.1: Convenience method: PdfContentByte.showTextAligned()
- 3.3: Working with the ColumnText object
- 3.3.1: Using ColumnText in text mode
- 3.3.2: Using ColumnText in composite mode
- 3.3.1: Using ColumnText in text mode
- 3.4: Creating reusable content
- 3.4.1: Image XObjects
- 3.4.2: The PdfTemplate object
- 3.4.1: Image XObjects
- 3.5: Summary
Consult the full table of contents, take a look at the
illustrations
from this chapter, or try out some of the
examples:
Figures
- Figure 3.1: Adding content using low-level methods to a page created with high-level objects
- Figure 3.2: The four content layers: 2 and 3 for the high-level objects; 1 and 4 for direct content
- Figure 3.3: Repeating the same rectangle using different graphics states
- Figure 3.4: Festival database entity relationship diagram
- Figure 3.5: Film festival timetable
- Figure 3.6: Timetable with movie time blocks
- Figure 3.7: Measuring and positioning text: width, ascent and descent of a String
- Figure 3.8: Adding text with ColumnText.showTextAligned()
- Figure 3.9: Timetable without movie titles
- Figure 3.10: The finished timetable, now with the movie titles
- Figure 3.11: Movie information, organized in columns
- Figure 3.12: Irregular columns
- Figure 3.13: Columns in composite mode
- Figure 3.14: Alignment in composite mode
- Figure 3.15: Image covering text
- Figure 3.16: Skewing an image
- Figure 3.17: Mimicking strips of film using PdfTemplate
- Figure 3.18: Adding the same PdfTemplate object using different transformations
Examples
- FestivalOpening
Keywords: Direct content, PdfContentByte, rectangle method, Text state, Basic building blocks > Image, Rotation > text rotation, Scaling > scaling images, Text state > Rendering mode, Text state > text color - GraphicsStateStack
Keywords: Current Transformation Matrix, Graphics state, Graphics state stack, rectangle method, save state / restore state, Graphics state > colors - MovieTimeTable
Keywords: Direct content, Graphics state, Lines, moveTo / lineTo, PDF syntax, Graphics state > line characteristics - MovieTimeBlocks
Keywords: Direct content, rectangle method, Basic building blocks > Rectangle, Graphics state > colors - FoobarFilmFestival
Keywords: Basefont, Kerning, Measuring a String, Text state, Chunk > width, ColumnText > showTextAligned(), Font > font metrics, PdfContentByte > showTextAligned(), Text state > Rendering mode - MovieTextInfo
Keywords: Font color, Text state, ColumnText > showTextAligned(), Rotation > text rotation, Text state > text color - MovieCalendar
Keywords: ColumnText - MovieColumns1
Keywords: ColumnText, Basic building blocks > Chunk, Basic building blocks > Phrase, ColumnText > number of lines written, ColumnText > text mode, Paragraph > extra space, Paragraph > indentation, Separators > LineSeparator - MovieColumns2
Keywords: ColumnText, Leading, Space Character ratio, ColumnText > text mode, Paragraph > extra space, Paragraph > indentation - MovieColumns3
Keywords: ColumnText, Y position, ColumnText > simulation mode, ColumnText > text mode, Y position > ColumnText cursor - MovieColumns4
Keywords: ColumnText, Leading, Y position, ColumnText > alignment, ColumnText > irregular columns, ColumnText > text mode, Y position > ColumnText cursor - ColumnMovies1
Keywords: ColumnText, Basic building blocks > Image, ColumnText > composite mode, ColumnText > simulation mode - ColumnMovies2
Keywords: ColumnText, Y position, ColumnText > alignment, ColumnText > composite mode, ColumnText > simulation mode - ImageDirect
Keywords: Basic building blocks > Image, Direct content > addImage method - ImageSkew
Keywords: Basic building blocks > Image, Direct content > addImage method, Scaling > scaling images - ImageInline
Keywords: Direct content, Basic building blocks > Image, Direct content > addImage method, Image > inline images, Scaling > scaling images - MoviePosters
Keywords: PdfTemplate, PdfTemplate, releaseTemplate method, Basic building blocks > Image, PdfTemplate > wrapped in an Image, Rectangle > rounded rectangle, Rotation > PdfTemplate rotation, Scaling > scaling images - MovieTemplates
Keywords: Direct content, PdfTemplate, Direct content > Under / over content
Content © 2010-2013 1T3XT BVBA
