MATLAB Function Reference
  Go to function:
    Search    Help Desk 
print, printopt    Examples   See Also

Create hardcopy output

Syntax

Description

print and printopt produce hardcopy output. All arguments to the print command are optional. You can use them in any combination or order.

print sends the contents of the current Figure, including bitmap representations of any user interface controls, to the printer using the device and system print command defined by printopt.

print -devicetype specifies a device type, overriding the value returned by printopt. The Devices section lists all supported device types.

print -options specifies print options that modify the action of the print command. (For example, the -noui option suppresses printing of user interface controls.) The Options section lists available options.

print filename directs the output to the file designated by filename. If filename does not include an extension, print appends an appropriate extension, depending on the device (e.g., .eps). If you omit filename, print sends the file to the default output device (except for -dmeta and -dbitmap, which place their output on the clipboard).

[pcmd,dev] = printopt returns strings containing the current system-dependent print command and output device. printopt is an M-file used by print to produce the hardcopy output. You can edit the M-file printopt.m to set your default printer type and destination.

pcmd and dev are platform-dependent strings. pcmd contains the command that print uses to send a file to the printer. dev contains the device option for the print command. Their defaults are platform dependent.

Platform
pcmd
dev
UNIX
lpr -r -s
-dps2
VMS
PRINT/DELETE
-dps2
Windows
COPY /B %s LPT1:
-dwin
Macintosh
(not applicable)
-dps2

Devices

The table below lists device types supported by MATLAB's built-in drivers. Generally, Level 2 PostScript files are smaller and render more quickly when printing than Level 1 PostScript files. However, not all PostScript printers support Level 2, so determine the capabilities of your printer before using those devices. Level 2 PostScript is the default for UNIX, VAX/VMS, and Macintosh computers. You can change this default by editing the printopt.m file.

The TIFF image format is supported on all platforms by almost all word processors for importing images. JPEG is a lossy highly compressed format that is supported on all platforms for image processing and for inclusion into HTML documents on the World Wide Web. To create these formats, MATLAB renders the Figure using the Z-buffer rendering method and the resulting pixmap is then saved to the specified file. You can specify the resolution of the image using the -r resolution switch.

Device
Description
-dps
Level 1 black and white PostScript
-dpsc
Level 1 color PostScript
-dps2
Level 2 black and white PostScript
-dpsc2
Level 2 color PostScript
-deps
Level 1 black and white Encapsulated PostScript (EPS)
-depsc
Level 1 color Encapsulated PostScript (EPS)
-deps2
Level 2 black and white Encapsulated PostScript (EPS)
-depsc2
Level 2 color Encapsulated PostScript (EPS)
-dhpgl
HPGL compatible with HP 7475A plotter
-dill
Adobe Illustrator 88 compatible illustration file
-dmfile
M-file, and MAT-file when appropriate, containing Handle Graphics commands to re-create the Figure and its children
-dtiff
24-bit RGB TIFF with packbits compression (Figures only)
-dtiffn
24-bit RGB TIFF with no compression (Figures only)
-djpeg
Baseline JPEG image, quality factor defaults to 75 (Figures only)
-djpegnn
Baseline JPEG image with nn (0-100) quality factor (Figures only)

This table lists additional devices supported via the Ghostscript post-processor, which converts PostScript files into other formats. (This feature is not available on Macintosh systems.)

Device
Description
-dlaserjet
HP LaserJet
-dljetplus
HP LaserJet+
-dljet2p
HP LaserJet IIP
-dljet3
HP LaserJet III
-ddeskjet
HP DeskJet and DeskJet Plus
-ddjet500
HP Deskjet 500
-dcdjmono
HP DeskJet 500C printing black only
-dcdjcolor
HP DeskJet 500C with 24 bit/pixel color and high-quality color (Floyd-Steinberg) dithering
-dcdj500
HP DeskJet 500C
-dcdj550
HP Deskjet 550C
-dpaintjet
HP PaintJet color printer
-dpjxl
HP PaintJet XL color printer
-dpjetxl
HP PaintJet XL color printer
-dpjxl300
HP PaintJet XL300 color printer
-ddnj650c
HP DesignJet 650C
-dbj10e
Canon BubbleJet BJ10e
-dbj200
Canon BubbleJet BJ200
-dbjc600
Canon Color BubbleJet BJC-600 and BJC-4000
-dln03
DEC LN03 printer
-depson
Epson-compatible dot matrix printers (9- or 24-pin)
-depsonc
Epson LQ-2550 and Fujitsu 3400/2400/1200
-deps9high
Epson-compatible 9-pin, interleaved lines (triple resolution)
-dibmpro
IBM 9-pin Proprinter
-dbmp256
8-bit (256-color) BMP file format
-dbmp16m
24-bit BMP file format
-dpcxmono
Monochrome PCX file format
-dpcx16
Older color PCX file format (EGA/VGA, 16-color)
-dpcx256
Newer color PCX file format (256-color)
-dpcx24b
24-bit color PCX file format, three 8-bit planes
-dpbm
Portable Bitmap (plain format)
-dpbmraw
Portable Bitmap (raw format)
-dpgm
Portable Graymap (plain format)
-dpgmraw
Portable Graymap (raw format)
-dppm
Portable Pixmap (plain format)
-dppmraw
Portable Pixmap (raw format)

This table summarizes additional devices available on Windows systems.

Device
Description
-dwin
Use Windows printing services (black and white)
-dwinc

Use Windows printing services (color)
-dmeta
Copy to clipboard in Enhanced Windows metafile format (color)
-dbitmap
Copy to clipboard in Windows bitmap (BMP) format (color)
-dsetup
Display Print Setup dialog box, but do not print
-v
Verbose mode to display Print dialog box (suppressed by default)

This table summarizes additional devices available on Macintosh systems.

Device
Description
-dpict
Create PICT file
-v
Verbose mode to display Print dialog box (suppressed by default)

Options

This table summarizes printing options that you can specify when you enter the print command.

Option
Description
-tiff
Add color TIFF preview to Encapsulated PostScript
-loose
Use loose bounding box for EPS and PS devices
-cmyk
Use CMYK colors in PostScript instead of RGB
-append
Append to existing PostScript file without overwriting
-rnumber
Specify resolution in dots per inch
-adobecset
Use PostScript default character set encoding
-Pprinter
Specify printer to use (UNIX only)
-fhandle
Handle of a Figure graphics object to print (current Figure by default; see gcf)
-swindowtitle
Name of SIMULINK system window to print (current system by default; see gcs)
-painters
Render using painter's algorithm
-zbuffer
Render using Z-buffer
-noui
Suppress printing of user interface controls

Paper Sizes

MATLAB supports a number of standard paper sizes. You can select from the following list by setting the PaperType property of the Figure or selecting a supported paper sizes from the print dialog box:

Property Value
Size (Width-by-Height)
usletter
8.5-by-11 inches
uslegal
11-by-14 inches
tabloid
11-by-17 inches
A0
841-by-1189mm
A1
594-by-841mm
A2
420-by-594mm
A3
297-by-420mm
A4
210-by-297mm
A5
148-by-210mm
B0
1029-by-1456mm
B1
728-by-1028mm
B2
514-by-728mm
B3
364-by-514mm
B4
257-by-364mm
B5
182-by-257mm
arch-A
9-by-12 inches
arch-B
12-by-18 inches
arch-C
18-by-24 inches
arch-D
24-by-36 inches
arch-E
36-by-48 inches
A
8.5-by-11 inches
B
11-by-17 inches
C
17-by-22 inches
D
22-by-34 inches
E
34-by-43 inches

Printing Tips

This section includes information about specific printing issues.

Troubleshooting MS-Windows Printing

If you encounter problems such as segmentation violations , general protection faults, application errors, or the output does not appear as you expect when using MS-Windows printer drivers, try the following:

Printing Thick Lines on Windows95

Due to a limitation in Windows95, MATLAB is set up to print lines as either:

If you create lines that are thicker than one pixel and use nonsolid line styles, MATLAB prints these lines with the specified line style, but one pixel wide (i.e., as thin lines).

However, you can change this behavior so that MATLAB prints thick, styled lines as thick, solid lines by editing your matlab.ini file, which is in your Windows directory. In this file, find the section:

and in this section change the assignment,

to

then restart MATLAB.

Printing MATLAB GUIs

You can generally obtain better results when printing a Figure window that contains MATLAB uicontrols by setting these key properties:

Notes on Printing Interpolated Shading with PostScript Drivers

MATLAB can print Surface objects (such as graphs created with surf or mesh) using interpolated colors. However, only Patch objects that are composed of triangular faces can be printed using interpolated shading.

Printed output is always interpolated in RGB space, not in the colormap colors. This means, if you are using indexed color and interpolated face coloring, the printed output can look different from what is displayed on screen. See "Interpolating in Indexed vs. Truecolor" in the Using MATLAB Graphics manual for an illustration of each type of interpolation.

PostScript files generated for interpolated shading contain the color information of the graphics object's vertices and require the printer to perform the interpolation calculations. This can take an excessive amount of time and in some cases, printers may actually "time-out" before finishing the print job. One solution to this problem is to interpolate the data and generate a greater number of faces, which can then be flat shaded.

To ensure that the printed output matches what you see on the screen, print using the -zbuffer option. To obtain higher resolution (for example, to make text look better), use the -r option to increase the resolution. There is, however, a trade-off between the resolution and the size of the created PostScript file, which can be quite large at higher resolutions. The default resolution of 150 dpi generally produces good results. You can reduce the size of the output file by making the Figure smaller before printing it and setting the Figure PaperPositionMode to auto, or by just setting the PaperPosition property to a smaller size.

Note that in some UNIX environments, the default lpr command cannot print files larger than 1 Mbyte unless you use the -s option, which MATLAB does by default. See the lpr man page for more information.

Example

This example prints a surface plot with interploted shading. Setting the current Figure's (gcf) PaperPositionMode to auto enables you to resize the Figure window and print it at the size you see on the screen. See Options and the previous section for information on the -zbuffer and -r200 options.

See Also

orient, figure

See the Using MATLAB Graphics manual for detailed information about printing in MATLAB.



[ Previous | Help Desk | Next ]