"be consistent" | |
PerlMonks |
Variable Width Printing on XPby T.G. Cornholio (Scribe) |
on Apr 05, 2005 at 01:39 UTC ( [id://444836]=perlquestion: print w/replies, xml ) | Need Help?? |
T.G. Cornholio has asked for the wisdom of the Perl Monks concerning the following question:
Wise Monks, I would like to develop a method of printing a given string, using a given font, in a specific amount of space. For example, print the string "Hi there" in Arial font, such that it is exactly 4.5 inches wide on the printed page. Now here's the problem. The space given may entail printing multiple pages. Frequently, this turns into something like having a single letter on each page. In this case I would like to have some kind of marks on the page to indicate where the text on this page ends and the next page begins. Aligning the two marks would recover the original spacing between letters. Everything I have considered so far seems to boil down to one of two issues:
1. I don't know how to determine the width of a particular letter or word when using a variable pitch font. Thus I don't know how to compute the overall size of the printed phrase.
2. Limited font support. I would like to have as many of the Windows fonts supported as is possible. I have considered the following methods and concluded the following. If my conclusions are incorrect, it would be great to hear about that also. Win32::Printer - Problem 1 Generate HTML and let browser print it - From my readings so far, HTML rendering may not give reproducible results across browser/printer combinations (but I could be wrong). Also, font support may not be as extensive as all the fonts available on MS Windows. Generating PDF - Both #1 and #2 above. Automating MS Word - problem #1 above. If you're wondering about the application of all of this, read on. My father is into woodworking, and he has a pantograph for his router. He would like to say "I have a piece of wood 30 x 40 inches, my phrase is (blah), use font (foo)". Then the program would take over, do the necessary calculations and print a document that he can take out to the shop. The pantograph takes 1 page at a time, thus the need for the ability to align the work across several printed pages so that variable pitch fonts don't come out looking strange on the finished work.
Back to
Seekers of Perl Wisdom
|
|