Chapter 3. Adding content at absolute positions

 

This chapter covers

  • Low-level access to page content, aka direct content
  • Convenience methods for writing direct content
  • Using the ColumnText object
  • Reusing content with the PdfTemplate object

In chapter 1, you learned that there are different ways to add content to a document when generating a PDF file from scratch. In chapter 2, you learned to add high-level objects to a Document. Now you’re going to learn an approach that’s totally different: you’ll add content to a page using methods that are referred to as low-level operations because they write PDF syntax directly to the content stream of the page.

A complete overview of the PDF operators and operands will follow in chapter 14. This chapter will cover the basics, but will quickly move on to convenience methods that hide some of the complexity of PDF. We’ll also unleash the power of the ColumnText object, an object that allows you to add basic building blocks at absolute positions.

We’ll start with an example that mixes the high-level and low-level approaches.

3.1. Introducing the concept of direct content

As a first example, you’ll use high-level objects to create a postcard inviting people to the movie that will open the Foobar Film Festival; then you’ll add extra content at absolute positions in the document using low-level methods.

3.2. Adding text at absolute positions

3.3. Working with the ColumnText object

3.4. Creating reusable content

3.5. Summary

sitemap