I'm working on a simple PDF generator to run on an 8-bit processor with a TCP/IP stack and web server. I've been reading through v1.3 of the PDF reference on my computer to understand the basics before I really dig in with the printed v1.6 that's on the way.
I understand the format well enough that I have code to generate a one-page document, use multiple fonts, and draw text at selected locations on the screen. I'm surprised that there isn't a simple way to have text centered or right-justified, though. I've spent a few hours today searching and haven't found an answer.
Am I missing some sort of transform, or method of stroking the text into an object that I then adjust the alignment on? I took a look at how PDFlib does it, and they appear to manually calculate the width using tables of character widths for each of the 14 built-in fonts.
I guess I can emulate that behavior, but it would seem that the PDF reader would have a much more accurate measurement for the width of a string than I would by measuring each character (what about kerning?).
So, any tricks or ideas I can use? And if I have to keep a table of character (glyph?) widths, where can I find the AFM files for the standard 14 fonts, and how hard will it be to extract the widths?
I understand the format well enough that I have code to generate a one-page document, use multiple fonts, and draw text at selected locations on the screen. I'm surprised that there isn't a simple way to have text centered or right-justified, though. I've spent a few hours today searching and haven't found an answer.
Am I missing some sort of transform, or method of stroking the text into an object that I then adjust the alignment on? I took a look at how PDFlib does it, and they appear to manually calculate the width using tables of character widths for each of the 14 built-in fonts.
I guess I can emulate that behavior, but it would seem that the PDF reader would have a much more accurate measurement for the width of a string than I would by measuring each character (what about kerning?).
So, any tricks or ideas I can use? And if I have to keep a table of character (glyph?) widths, where can I find the AFM files for the standard 14 fonts, and how hard will it be to extract the widths?