About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2008

URL: http://cxc.harvard.edu/chips4.1/print_window.py.html
AHELP for ChIPS 4.1

print_window

Context: py.chips

Synopsis

Prints the window to a file or the printer.

Syntax

print_window([ChipsId,] [filename [,attributes]])

Description

  • ChipsId - an optional ChipsId structure containing values to modify the currency state for the command.
  • filename - output file.

The print_window command prints the contents of the window to either a file or the printer. If "filename" is specified, the image is written to a file. If it is not specified, the image is sent to the user's default printer.

New in CIAO 4.1: a GUI for printing ChIPS plots. If the preference "export.printdialog" is set to true, ChIPS will open a printing dialog box when print_window is called. The dialog allows you to decide whether to send the figure to the printer or to a file, and allows you to set all the printing options available in the print_window command (e.g. output format, color scheme, page margins). Unless a filename (with optional path) is specified in the print_window call, the working directory is used as the default location.

The margins can be specified individually, along with the page orientation (portrait or landscape), the color scheme (e.g. rbg, cmyk), and the file format (e.g. postscript, jpg). A number of standard page sizes are available (e.g. letter, legal).

The size and aspect ratio of the output matches the dimensions of the window. This can be overridden using the pagewidth and pageheight attributes or the pagesize attribute. The pagewidth, pageheight, and pagesize settings currently only work with postscript and pdf file formats.

The scalewidth and scaleheight attributes scale the image with regard to the print area - either the window dimensions or the pagewidth/pageheight specification. If the image is scaled such that it's larger than the page and "keepaspect" is set to false, the image is clipped. If "keepaspect" is "true", the scaled image maintains the original aspect ratio and is scaled up until one dimension touches the margins.

The units for the margins, width, and height are determined by the "window.units" preference, unless overridden by the pageunits attribute.

Attribute Description Options Default
fonts should the font be written to the printer, if the image is going to the printer see the Booleans section of "ahelp chipsopt" true
format export file format ps|eps|pdf|png|jpg ps
orientation page layout orientation landscape|portrait portrait
colorscheme indicates the color specification scheme rgb|cmyk|cmyksep|greyscale|grayscale rgb
leftmargin size of the left margin Numerical value 0.2
rightmargin size of the right margin numerical value 0.2
topmargin size of the top margin numerical value 0.2
bottommargin size of the bottom margin numerical value 0.2
pagewidth (PS and PDF only) width of the saved file image. Overrides the window dimensions. Units taken from window.units unless overridden by export.pageunits numerical value 0.0
pageheight (PS and PDF only) height of the saved file image. Overrides the window dimensions. Units taken from window.units unless overridden by export.pageunits numerical value 0.0
pagesize (PS and PDF only) print size letter|legal|executive|A3|A4|A5 letter
pageunits Units of measure of the pagesize inches|cm|mm|pixels inches
scalewidth Factor for scaling the image width Floating point percentage value 0.0
scaleheight Factor for scaling the image height Floating point percentage value 0.0
fittopage Fits the image to the page size; aspect ratio is controlled by the "keepaspect" attribute see the Booleans section of "ahelp chipsopt" false
keepaspect Maintain aspect ratio of the image while fitting to the page? see the Booleans section of "ahelp chipsopt" true
clobber Overwrite am existing file? Boolean true|false false

Example 1

chips> print_window()

The contents of the current window are sent to the default printer.

Example 2

chips> print_window("plot")

A postscript version of the current window is created in the file plot.ps.

Example 3

chips> print_window("plot",["pagesize","letter","fittopage",1])
chips> print_window("plot",["format","png"])

A postscript version of the current window is created in the file plot.ps; it has been re-sized to fill a US letter page. The second call to print_window creates a PNG format of the window in the file plot.png.

Example 4

chips> id = ChipsId()
chips> add_window("id=FirstWindow")
chips> add_window("id=Window2")
chips> id.window = "FirstWindow"
chips> print_window(id)

Two windows are created; the second window is current after it is created. The id.window command sets the window value of the ChipsId structure to the first window. That window is then printed.

Example 5

chips> add_window("id=MyWindow1")
chips> add_window()
chips> print_window("plot1", ["format","eps"])

Two windows are created; the second window is current after it is created. That window is then printed to an EPS file named "plot1.eps".

CHANGES IN CIAO 4.1

GUI for printing ChIPS plots

If the preference "export.printdialog" is set to true, ChIPS will open a printing dialog box when print_window is called. The dialog allows you to decide whether to send the figure to the printer or to a file, and allows you to set all the printing options available in the print_window command (e.g. output format, color scheme, page margins).

Page margins changed to 0.2

The default page margins were change to .2 to account for the margin which normally exists on printers.

Bugs

See the bugs pages on the ChIPS website for an up-to-date listing of known bugs.

Last modified: December 2008



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.