time | Calls | line |
---|
| | 1 | function varargout = print( varargin )
|
| | 2 | % PRINT Print or save a figure or model.
|
| | 3 | % A subset of the available options is presented below. For more details
|
| | 4 | % see <a href="matlab:helpview([docroot '/matlab/ref/print.html'])" />the documentation</a>.
|
| | 5 | %
|
| | 6 | % PRINT, by itself, prints the current figure to your default printer.
|
| | 7 | % Use the -s option to print the current model instead of the current figure.
|
| | 8 | % print % print the current figure to the default printer
|
| | 9 | % print -s % print the current model to the default printer
|
| | 10 | %
|
| | 11 | % PRINT(filename, formattype) saves the current figure to a file in the
|
| | 12 | % specified format. Vector graphics, such as PDF ('-dpdf'), and encapsulated
|
| | 13 | % PostScript ('-depsc'), as well as images such as JPEG ('-djpeg') and PNG ('-dpng')
|
| | 14 | % can be created. Use '-d' to specify the formattype option
|
| | 15 | % print(fig, '-dpdf', 'myfigure.pdf'); % save to the 'myfigure.pdf' file
|
| | 16 | % The full list of formats is <a href="matlab:helpview([docroot '/matlab/ref/print.html#inputarg_formattype'])" />documented here</a>.
|
| | 17 | %
|
| | 18 | % PRINT(printer, ...) prints the figure or model to the specified printer.
|
| | 19 | % Use '-P' to specify the printer option.
|
| | 20 | % print(fig, '-Pmyprinter'); % print to the printer named 'myprinter'
|
| | 21 | %
|
| | 22 | % PRINT(resize,...) resizes the figure to fit the page when printing.
|
| | 23 | % The resize options are valid only for figures, and only for page
|
| | 24 | % formats (PDF, and PS) and printers. Specify resize as either
|
| | 25 | % '-bestfit' to preserve the figure's aspect ratio or
|
| | 26 | % '-fillpage' to ignore the aspect ratio.
|
| | 27 | %
|
| | 28 | % <a href="matlab:helpview([docroot '/matlab/ref/print.html'])" />The documentation</a> contains additonal details and examples, including how to
|
| | 29 | % specify the figure or model to print, adjust the output size and
|
| | 30 | % resolution, save to the clipboard, and specify the renderer to use.
|
| | 31 | %
|
| | 32 | % See also SAVEAS, PRINTPREVIEW, SAVEFIG, EXPORTGRAPHICS, COPYGRAPHICS.
|
| | 33 |
|
| | 34 | % Copyright 1984-2019 The MathWorks, Inc.
|
| | 35 |
|
2.988 | 12 | 36 | drawnow; % give changes a chance to be processed
|
| | 37 |
|
0.219 | 12 | 38 | [pj, inputargs] = LocalCreatePrintJob(varargin{:});
|
| | 39 |
|
| | 40 | %Check the input arguments and flesh out settings of PrintJob
|
0.289 | 12 | 41 | [pj, devices, options ] = inputcheck( pj, inputargs{:} );
|
| | 42 |
|
| | 43 | % Process printing operation for simulink figure
|
0.109 | 12 | 44 | if handleSimulinkPrinting(pj)
|
| | 45 | return
|
< 0.001 | 12 | 46 | end
|
| | 47 |
|
| | 48 | %User can find out what devices and options are supported by
|
| | 49 | %asking for output and giving just the input argument '-d'.
|
| | 50 | %Do it here rather then inputcheck so stack trace makes more sense.
|
< 0.001 | 12 | 51 | if strcmp( pj.Driver, '-d' )
|
| | 52 | if nargout == 0
|
| | 53 | disp(getString(message('MATLAB:uistring:print:SupportedDevices')))
|
| | 54 | for i=1:length(devices)
|
| | 55 | disp([' -d' devices{i}])
|
| | 56 | end
|
| | 57 | else
|
| | 58 | varargout{1} = devices;
|
| | 59 | varargout{2} = options;
|
| | 60 | end
|
| | 61 | %Don't actually print anything if user is inquiring.
|
| | 62 | return
|
< 0.001 | 12 | 63 | end
|
| | 64 |
|
| | 65 | %Validate that PrintJob state is ok, that input arguments
|
| | 66 | %and defaults work together.
|
0.128 | 12 | 67 | pj = validate( pj );
|
| | 68 |
|
| | 69 | %Handle missing or illegal filename.
|
| | 70 | %Save possible name first for potential use in later warning.
|
0.022 | 12 | 71 | pj = matlab.graphics.internal.name( pj );
|
| | 72 |
|
| | 73 | %Sometimes need help tracking down problems...
|
< 0.001 | 12 | 74 | if pj.DebugMode
|
| | 75 | disp(getString(message('MATLAB:uistring:print:PrintJobObject')))
|
| | 76 | disp(pj)
|
< 0.001 | 12 | 77 | end
|
| | 78 |
|
0.005 | 12 | 79 | matlab.graphics.internal.prepareFigureForPrint(pj.Handles{1});
|
0.016 | 12 | 80 | matlab.ui.internal.UnsupportedInUifigure(pj.Handles{1});
|
| | 81 |
|
| | 82 | %If handled via new path just return from here, otherwise fall through
|
7.135 | 12 | 83 | pj = alternatePrintPath(pj);
|
< 0.001 | 12 | 84 | if pj.donePrinting
|
< 0.001 | 12 | 85 | if pj.RGBImage
|
| | 86 | varargout(1) = {pj.Return};
|
< 0.001 | 12 | 87 | end
|
0.002 | 12 | 88 | return;
|
| | 89 | end
|
| | 90 | end
|
Other subfunctions in this file are not included in this listing.