When using print for my gui I want it to work lige uiputfile, where the user can deside where to place the print.

1 view (last 30 days)
Hey Matlab experts
I have a gui where I use the command print, to print my gui with all the information on it, into a pdf. Instead of it just printing a pdf and placing it next to where the gui is placed, then I want it to make a pop-up window like you get when using uiputfile, where the user can select where to place the pdf. How do I do that?
print(handles.output, '-dpdf', 'test1.pdf', '-r2000'); %What I originally used.
[FileName,PathName] = uiputfile('*.pdf','Save Print'); % This is what I tried 1/2
save([PathName,FileName],print(handles.output, '-dpdf', 'test1.pdf', '-r2000')); %2/2
  1 Comment
Mikkel Ibsen
Mikkel Ibsen on 13 Nov 2017
The only thing I can find is the command:
But that isnt good coding, but more the lack of it and trying to solve a problem you dont understand.

Sign in to comment.

Accepted Answer

Cam Salzberger
Cam Salzberger on 13 Nov 2017
Hello Mikkel,
The print command does not provide an output argument - it is what is writing the file to disk. The save command should only be used when trying to save a MAT file, not when trying to write a PDF to disk.
What you can do instead is simply provide the full-path filename as the filename input argument to the print command:
[FileName,PathName] = uiputfile('*.pdf','Save Print');
print(handles.output, '-dpdf', fullfile(PathName, FileName), '-r2000')
Also, -r2000 is likely not necessary, as the PDF should be printed in vector format. Typically you would specify PaperPosition and/or PaperSize (or other paper properties) if you were concerned about the size on the PDF.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!