Let's create a minimal PDF package.
We'll build it without any dependencies, from the ground up by creating PDF objects, streams, drawing commands, pages and a complete document.
To keep things easier, we'll use PDF's built-in Courier fonts and support only ASCII. This way, we don't have to deal with measuring proportional text and parsing and embedding TrueType fonts.
PDF is a container format that contains (among other stuff) PDF objects. Those might contain streams of data and those data might be made up by PDF drawing commands. They might also contain dictionaries writting in << >> with keys whose symbolic names start with a /.
%PDF-1.7
%...