I recently wanted to print on an oddly sized and shaped piece of paper. The top of the paper had an uneven edge but the bottom was flat so I needed to feed the paper in bottom-first. The design made it clear which edge was the top, however, so I couldn't print normally or the text would appear upside down.
This example prints text upside down, starting at the X and Y coordinate needed to position the text nicely on the paper. This example probably won't be too useful as it is written (unless you happen to have a piece of very similar paper) but you can use it to see how to print upside down at given coordinates.
When you click the Print button, the program reads the text to print from a text box. It loads the desited font normally and prints a space. This serves two purposes. First, printing something initializes the printer, which is necessary before creating rotated fonts. Second, the program examines teh Printer.Y property before and after printing the space to see how much vertical space to leave between lines.
Next the program sets the X and Y coordinates for the first line of text. Those were chosen for the piece of paper.
The code then saves the printer's device context (hDC), creates a font rotated 180 degrees, and selects the font into the printer.
The program loops through the lines of text, printing each. After each line, the code moves the Y coordinate for the next line up by the line spacing amount.
After it prints all of the text, the code restores the printer's original font and calls the EndDoc method to send the results to the printer.
|