PSDraw Module

The PSDraw module provides simple print support for Postscriptprinters. You can print text, graphics and images through this module.

  • class PIL.PSDraw.PSDraw(fp=None)[源代码]
  • Sets up printing to the given file. If file is omitted,sys.stdout is assumed.

    • begindocument(_id=None)[源代码]
    • Set up printing of a document. (Write Postscript DSC header.)

    • end_document()[源代码]

    • Ends printing. (Write Postscript DSC footer.)

    • image(box, im, dpi=None)[源代码]

    • Draw a PIL image, centered in the given box.

    • line(xy0, xy1)[源代码]

    • Draws a line between the two points. Coordinates are given inPostscript point coordinates (72 points per inch, (0, 0) is the lowerleft corner of the page).

    • rectangle(box)[源代码]

    • Draws a rectangle.

参数:box
A 4-tuple of integers whose order and function is currentlyundocumented.

Hint: the tuple is passed into this format string:

  1. %d %d M %d %d 0 Vr
  • setfont(font, size)[源代码]
  • Selects which font to use.

参数:

  1. - **font** A Postscript font name
  2. - **size** Size in points.
  • text(xy, text)[源代码]
  • Draws text at the given position. You must usesetfont() before calling this method.