Thread Subject: Save figure within GUI not working

Subject: Save figure within GUI not working

From: Amir

Date: 10 Jul, 2008 17:36:06

Message: 1 of 2

Hi. I have a GUI that contains a plot, which I'm trying to
be able to save as a PDF at the click of a button. It isn't
working perfectly, however. A PDF is created with the
correct plot and all, but the position/size of the plot in
the PDF isn't fullscreen (as if I created it from the
Matlab command window), rather the same shape/size as it is
on the GUI.

Here is the code I use:

function saveasPDF_Callback(hObject, eventdata, handles)
 [f p]=uiputfile('*.pdf','Save as PDF');
 newFig=figure;
 axesObject2=copyobj(handles.axes1,newFig);
 print(newFig,'-dpdf',[p f]);


Any ideas? Thanks!

Subject: Save figure within GUI not working

From: Richard Quist

Date: 17 Jul, 2008 00:29:02

Message: 2 of 2

"Amir " <amirschricker.DELETE@DELETE.gmail.DELETE.com> wrote
in message <g55ha6$itc$1@fred.mathworks.com>...
> Hi. I have a GUI that contains a plot, which I'm trying to
> be able to save as a PDF at the click of a button. It isn't
> working perfectly, however. A PDF is created with the
> correct plot and all, but the position/size of the plot in
> the PDF isn't fullscreen (as if I created it from the
> Matlab command window), rather the same shape/size as it is
> on the GUI.
>
> Here is the code I use:
>
> function saveasPDF_Callback(hObject, eventdata, handles)
> [f p]=uiputfile('*.pdf','Save as PDF');
> newFig=figure;
> axesObject2=copyobj(handles.axes1,newFig);
> print(newFig,'-dpdf',[p f]);
>
>
> Any ideas? Thanks!

Check the PaperPositionMode property of your figure. If it's
set to 'auto' then the output should sized to match the
figure's (newFig) width and height (based on the 3rd and 4th
values of the figure's Position property). If the
PaperPositionMode property is set to 'manual' then the
output should be sized based on the value of the figure's
PaperPosition property.

--

Richard Quist
Software Developer
The MathWorks, Inc.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
print gui Ayush Upadhyay 16 Jun, 2011 00:19:09
print gui Vu Hiep 27 Feb, 2009 08:56:05
pdf Richard Quist 16 Jul, 2008 20:30:12
paperposition Richard Quist 16 Jul, 2008 20:30:12
print Richard Quist 16 Jul, 2008 20:30:12
gui Amir 10 Jul, 2008 13:40:13
save as pdf Amir 10 Jul, 2008 13:40:13
rssFeed for this Thread

Contact us at files@mathworks.com