Documentation of print2

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

Function Synopsis

varargout = print( varargin )

Help text

PRINT Print Figure or model. Save to disk as image or M-file.
       PRINT alone sends the current figure to your current printer.
       The size and shape of the printed output depends on the Figure's
       PaperPosition[mode] properties and your default print command 
       as specified in your PRINTOPT.M file.

     print -s
       Same as above but prints the current Simulink model.

     print -device -options 
       You can optionally specify a print device (i.e., an output format such
       as tiff or PostScript or a print driver that controls what is sent to
       your printer) and options that control various characteristics  of the
       printed file (i.e., the resolution, type of preview, Figure to print
       etc.). Available devices and options are described below.

     print -device -options filename
       If you specify a filename, MATLAB directs output to a file instead of
       a printer. PRINT adds the appropriate file extension if you do not 
       specify one.

     print( ... )
       Same as above but this calls PRINT as a MATLAB function instead of
       a MATLAB command. The difference is only in the parenthesized argument
       list. It allows the passing of variables for any of the input 
       arguments; especially useful for passing the handles of Figures and/or
       models to print and filenames.

     Note: PRINT will produce a warning when printing a figure with a
     ResizeFcn.  To avoid the warning, set the PaperPositionMode to 'auto'
     or match figure screen size in the PageSetup dialog.

       You can use the function form of PRINT, which is useful for batch 
       printing. For example, you can use a for loop to create different
       graphs and print a series of files whose names are stored in an array: 

       for i=1:length(fnames)
       -f<handle>   % Handle Graphics handle of Figure to print
       -s<name>     % Name of an open Simulink model to print
       h            % Figure or model handle when using function form of PRINT 

       print -f2    % Both commands print Figure 2 using the default driver
       print( 2 )   % and operating system command specified in PRINTOPT.

       print -svdp  % prints the open Simulink model named vdp

       <filename>   % String on the command line
       '<filename>' % String passed in when using function form of PRINT
       print -deps foo
       fn = 'foo'; print( gcf, '-deps', fn )
       Both save the current Figure to a file named 'foo.eps' in the current
       working directory. This EPS file can now be inserted in a Word 
       document or other word processor.

       Output format is specified by the device driver input argument. This
       argument always starts with '-d' and falls into one of several 
     Microsoft Windows system device driver options:
       -dwin      % Send figure to current printer in monochrome
       -dwinc     % Send figure to current printer in color
       -dmeta     % Send figure to clipboard in Metafile format
       -dbitmap   % Send figure to clipboard in bitmap format
       -dsetup    % Bring up Print Setup dialog box, but do not print
       -v         % Verbose mode, bring up the Print dialog box
                    which is normally suppressed.

     MathWorks supplied PostScript drivers:
       -dps    % PostScript for black and white printers
       -dpsc   % PostScript for color printers
       -dps2   % Level 2 PostScript for black and white printers
       -dpsc2  % Level 2 PostScript for color printers

       -deps   % Encapsulated PostScript 
       -depsc  % Encapsulated Color PostScript
       -deps2  % Encapsulated Level 2 PostScript
       -depsc2 % Encapsulated Level 2 Color PostScript

     Other MathWorks supplied formats:
       -dhpgl     % HPGL compatible with Hewlett-Packard 7475A plotter
       -dill      % Adobe Illustrator 88 compatible illustration file
       -djpeg<nn> % JPEG image, quality level of nn (Figure windows only,
                    implies -loose). E.g., -djpeg90 gives a quality level
                    of 90. Quality level defaults to 75 if nn is omitted.
       -dtiff     % TIFF with packbits (lossless run-length encoding)
                    compression (Figure windows only, implies -loose)
       -dtiffnocompression % TIFF without compression 
                    (Figure windows only, implies -loose)
       -dpng      % Portable Network Graphic 24-bit truecolor image
                    (Figure windows only, implies -loose)
       -dmfile    % M-file and MAT-file containing Handle Graphics
                    commands to re-create a Figure and its children.
                    Note: Does not save some data used by PLOTEDIT and
                    ZOOM, use HGSAVE instead. (Figure windows only)

     Other output formats are possible by using the GhostScript application
     supplied with MATLAB to convert PostScript output into a format suitable
     for many different kinds of printers. For a full listing see the online
     help for GHOSTSCRIPT, use the command 'help @printjob\ghostscript'.
     An example of some of the device drivers supported via GhostScript are:
       -dljet2p   % HP LaserJet IIP
       -dljet3    % HP LaserJet III
       -ddeskjet  % HP DeskJet and DeskJet Plus
       -dcdj550   % HP Deskjet 550C (UNIX only)
       -dpaintjet % HP PaintJet color printer
       -dpcx24b   % 24-bit color PCX file format, 3 8-bit planes
       -dppm      % Portable Pixmap (plain format)

       print -dwinc  % Prints current Figure to current printer in color
       print( h, '-djpeg', 'foo') % Prints Figure/model h to foo.jpg

     Options only for use with PostScript and GhostScript drivers:
       -loose     % Use Figure's PaperPosition as PostScript BoundingBox
       -append    % Append, not overwrite, the graph to PostScript file
       -tiff      % Add TIFF preview, EPS files only (implies -loose)
       -cmyk      % Use CMYK colors instead of RGB
       -adobecset % Use Adobe PostScript standard character set encoding

     Options for PostScript, GhostScript, Tiff, and Jpeg:
       -r<number> % Dots-per-inch resolution. Defaults to 90 for Simulink,
                    150 for Figures in Tiff and Jpeg images and when
                    printing in Zbuffer mode, 864 otherwise. 
                    Use -r0 to specify screen resolution.
       print -depsc -tiff -r300 matilda 
       Saves current Figure at 300 dpi in color EPS to matilda.eps with a
       TIFF preview (always at 72 dpi). This TIFF preview will show up on
       screen if matilda.eps is Inserted as a Picture in a Word document,
       but the EPS will be used if the Word document is printed on a 
       PostScript printer.

     Other options for Handle Graphics Figure windows:
       -noui      % Do not print UI control objects
       -painters  % Rendering for printing to be done in Painters mode
       -zbuffer   % Rendering for printing to be done in Z-Buffer mode
       A note on renderers, when printing Figures, MATLAB does not always
       use the same Renderer as on screen. This is for efficiency reasons.
       There are cases, however, where the printed output is not exactly
       like the screen representation because of this. In these instances
       specifying -zbuffer will more likely give you output that emulates
       the screen.

     For Unix and VMS users only:
       -Pprinter  % Specify the printer to use

   For more help, type the command 'doc print' at the MATLAB command line
   for a complete list of devices and options. Also, see the Using MATLAB
   Graphics manual for more information on printing.


Cross-Reference Information

This function calls

Listing of function print2

function varargout = print( varargin )

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.16 $  $Date: 1998/10/09 22:10:43 $

%Create PrintJob object to encapsulate data and methods
pj = printjob;

    wasErr = 0;
    %Check the input arguments and flesh out settings of PrintJob objet
    [pj, devices, options ] = inputcheck( pj, varargin{:} );
    %User can find out what devices and options are supported by
    %asking for output and giving just the input argument '-d'.
    %Do it here rather then inputcheck so stack trace makes more sense.
    if strcmp( pj.Driver, '-d' )
        if nargout == 0
            disp('Supported devices are:')
            for i=1:length(devices)
                disp(['    -d' devices{i}])
            error( ' ' );
            varargout{1} = devices;
            varargout{2} = options;
        %Don't actually print anything if user is inquiring.
    pj = preparepointers( pj );
    %Validate that PrintJob state is ok, that input arguments 
    %and defaults work together.
    pj = validate( pj );

    %Handle missing or illegal filename.
    pj = name( pj );
    %If only want to setup the output, do it and early exit.
    %Currently this is a PC only thing, opens standard Windows Print dialog.
    if setup( pj )
    %Sometimes need help tracking down problems...
    if pj.DebugMode 
        disp('Debugging in PRINT, PrintJob object is:')
    %Connect to printer, possibly show dialog box to user.
    pj = start( pj );
    %Objects to print have their handles in a cell-array of vectors.
    %Each vector is for one page; all objects in that vector
    %are printed on the same page. The caller must have set their 
    %PaperPosition's up so they do not overlap, or do so gracefully.
    numPages = length( pj.Handles );
    for i = 1 : numPages
        numObjs = length( pj.Handles{i} );
        pj = positions( pj, pj.Handles{i} );
        %    for j = 1 : numObjs
        h = pj.Handles{i}(1);
        %Add object to current page

        pj.Error = 0;
        %May want to change various properties before printing depending
        %upon input arguments and state of other HG/Simulink properties.
        pj = prepare( pj, h );
        %Call the output driver and render Figure/model to device, file, or clipboard.
        %Save erroring out until we restore the objects.
           pj = render( pj, pj.Handles{i} );
           pj.Error = 1;
        %Reset the properties of a Figure/model after printing.
        pj = restore( pj, h );
        if pj.Error
            error( lasterr )
        if i < numPages
            %Start a new page for next vector of handles
            pj = newpage( pj );
    %Close connect with printer or file system.
    pj = finish( pj );
    if pj.GhostDriver
        pj = ghostscript( pj );
    elseif strcmp( pj.Driver, 'hpgl' )
        hpgl( pj )
    if pj.PrintOutput
        send( pj )
    wasErr = 1;

restorepointers( pj )

if wasErr
    error( lasterr )