In this chapter, you'll first learn the basics of printing and then you'll learn how to create a pretty complex component: TTextPrinter. The TTextPrinter component is a TComponent descendant able to print both plain text documents and Delphi source files. The TTextPrinter component even prints syntax highlighting: reserved words, directives, and comments, both single-line and block. However, several details are not implemented because the discussion of the component would be too long to fit into a single chapter, but feel free to implement these details yourself.
This chapter also shows how to use the Refactoring commands available in Delphi to restructure several parts of the TTextPrinter component in order to make it more readable and more robust.
The chapter ends with a description of the PDF file format and shows how to print, or more precisely, how to export text files to a PDF document.