how to get report generator to open pdf report automatically in stand alone program?

I made a GUI for image processing and analysis. It has a push button to generate a pdf report - the call back invokes the report function in Report Generator. The GUI works fine under Matlab environment - the pdf report opens automatically and I can save or print it. But when I compile the program to stand-alone executable (using deploytool) the pdf report fails to open.
I ran the stand alone program in cmd and the error message was: C:\Users\Emma\AppData\Local\Temp\...\report.pdf cannot be viewed in a compiled application. Please use an external application to open.
If I go to the temp folder the pdf report is there. My question is: how do I get the pdf file to open automatically like when I was running the program under Matlab? Do I need to package a pdf viewer or something when I deploy the code? (I've only included the .m, .fig and .rpt file when compiling).
First time asking a question here so please let me know if I should clarify more. Many thanks in advance for your help!
Emma

4 Comments

Emma - what is the line of code that you have written to open the report.pdf? Are you using open?
Thanks Geoff, Sorry I missed your comment until now...
I set the rpt file property in report explorer - by ticking " View report after generation" under General Options.
The report opens under Matlab environment but in compiled stand-alone application it doesn't. (" ....pdf cannot be viewed in a compiled application.")
I also tried using "open" in the push button call back. Again it works fine when I run the code using Matlab. In stand-alone application, I get error " Error using open. File 'report.pdf' not found".
The pdf report was saved to a random folder under AppData\Local\Temp directory, is this maybe the reason why report.pdf was not found? If that's the case, how do I tell the program to find the file? (the folder name seems to be randomly generated).
Many thanks, Emma
Oh Ok I found a way to do this. 1. In rpt file property, set directory to a specified location. 2. In the call back function, create the directory if it doesn't exist. 3. Use "open" to open the file.
Cheers.

Sign in to comment.

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Asked:

on 18 Jun 2016

Commented:

on 29 Aug 2017

Community Treasure Hunt

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

Start Hunting!