Chapter 15. Page content and structure
This chapter covers
- Making content optional
- Working with marked content
- Parsing PDF files
The previous chapter was devoted entirely to page content; you learned how to add content the PDF way and the Java way. We’ll continue discussing content in this chapter. We’ll add operators and operands to make part of the content optional. We’ll use marked content to add custom parameters to graphical objects, to make the content accessible for the visually impaired, and to store the structure of the document. Finally, we’ll make a fair attempt at parsing a PDF document and extracting content from a page.
All the content you’ve added to a page so far was either visible or it was invisible, whether because it was clipped or because the rendering mode was set to invisible. Beginning with PDF 1.5, you can also add optional content: content that can be selectively viewed or hidden by document authors or consumers.
Graphics and text that can be made visible or invisible dynamically are grouped in an optional content group (OCG). Content that belongs to a certain group is visible when the group is on, and invisible when the group is off. Figure 15.1 demonstrates this functionality.