Drawing Shapes

Since you now understand how to use fonts, it's time to add a little graphical flare to the PDF. With just a few functions, you can make lines, rectangles, circles, polygons, arcs, and more. There are numerous factors you can adjust, including the line width and color.

The only thing you really need to understand about drawing shapes in PDFs is that the process takes two steps: defining the path and then stroking it. This may sound familiar to anyone who has used a vector-based graphics program such as Adobe Illustrator. First you define a path by identifying points along it—a line requires two, a rectangle four, and a circle a whole, whole lot. Defining the path (or clipping path as its formally called) does not actually create ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.