How to print figure generated by GUI?

I have created a GUI that outputs a figure with some text on it. The figure is set up using the following code:
figure(1)
set(1, 'units', 'pixels', 'pos', [0 0 612.48 792.627])
axis off
set(gca,'Position',[0.1 0.1 0.1 0.1],'units','pixels') % Margin
set(gca, 'XTick', [])
set(gca, 'YTick', [])
The text is placed on the figure using text(). After a pushbutton is pushed, the figure is displayed. The issue that I am having is I am trying to have the pushbottom not only display the figure but also print the figure after it is displayed. The figure title is 'Figure 1'. I have tried to put print('Figure 1','-fillpage') in the push button but that gives the following error message:
Problem sending file to output device, system returned error :
lpr: The printer or class does not exist.
I have also tried to manually print the figure from the file menu, but this gives the same error as above. Is what I am trying to do possible or would I have save and print the figure every time?
Thanks in advance for any help!

Respuestas (1)

John BG
John BG el 28 de Jul. de 2016
try the following
printdlg
you should see an empty figure frame, and after that your system should show the printer dialog for you to go ahead with the print: choose device, configure settings, ..
do you reach the printer dialog of your local system?
John

5 comentarios

Urjitam Ujit
Urjitam Ujit el 28 de Jul. de 2016
I added the 'printdlg' to the code for the push button. It brings up the printer dialog, allowing me to change the orientation printer, and margin. However, if I click print from that window, I still receive the same error message as before about the printer or class not existing.
Another issue I have with the printdlg, is that it does not allow me to adjust the margins, if i change their value and click away it resets back to what the original value was. Do you know anyway I can change this or have the figure print to fill the page?
John BG
John BG el 28 de Jul. de 2016
can you print fine from other applications than MATLAB?
for instance open a document with Word or the text editor and try to print, do you manage?
Urjitam Ujit
Urjitam Ujit el 29 de Jul. de 2016
yes i can print from other programs. if i type just print() at in the pushbutton, MATLAB prints, however it prints the GUI figure instead of the figure that is displayed after the pushbutton is activated. even when i type print() at the command line MATLAB prints but again its is the GUI figure. The only time i get the error about the printer or class not existing is when i try to print from the presented figure's file menu through print preview after filling the page.
John BG
John BG el 29 de Jul. de 2016
1.- Is it your computer? or university? or work?
2.- If yours, do you share it with others?
3.- have you recently opened the folders where MATLAB program are installed?
4.- In what folder have you installed MATLAB?
5.- Because, from what you write, it only happens in a specific situation, try reinstalling MATLAB.
6.- What R version do you have? R2012 R2015a R2015b R2016a?
5.- In any case you lose nothing by putting through a service request to MATHWORKS
you may need the serial number handy
cannot help any further on this print problem.
Regards
John BG
Urjitam Ujit
Urjitam Ujit el 29 de Jul. de 2016
thank you very much for your effort in helping me resolve this problem! I have put in a service request to Matworks.

Iniciar sesión para comentar.

Categorías

Más información sobre Printing and Saving en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Jul. de 2016

Comentada:

el 29 de Jul. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by