I'm having errors closing documents with the Matlab Report Generator.

조회 수: 23 (최근 30일)
Robert Brumer
Robert Brumer 2017년 9월 11일
댓글: YTChow 2025년 1월 5일
I saw that there was another user with a similar error, but the answer to that question was not applicable to the problem I'm having.
I want to output a large number of plots as figures in a multi-page PDF. Tools from the file exchange did not work, as they require Ghostscript to be installed and I am planning to distribute the final product. Some users suggested using the report generator, which I am doing with a programmatic approach. Prior to the following code, figures with subplots are generated and then saved as .png files in a temporary folder.
import mlreportgen.dom.*
d = Document(PDFFullName,'pdf');
d.StreamOutput = true;
open(d);
P = d.CurrentPageLayout;
P.PageMargins.Header = '0in';
P.PageMargins.Footer = '0in';
P.PageMargins.Top = '0in';
P.PageMargins.Bottom = '0in';
P.PageMargins.Left = '0in';
P.PageMargins.Right = '0in';
Figs = dir('Temp\*.png');
Figs = {Figs(:).name};
for i = 1:length(Figs)
Fig = ['Temp\Fig_' num2str(i) '.png'];
TempPlot = Image(Fig);
TempPlot.Style = {ScaleToFit};
append(d,TempPlot);
end
close(d)
Occasionally, this works perfectly. Most of the time, I get the following error:
Error using mlreportgen.dom.Document/close
Error closing document package: Could not commit changes: Could not rename the temporary package to final
location: Permission denied Permission denied
The PDF file is generated, but it has a size of 0 kb and cannot be opened. Often when this happens I end up with a folder in the same directory that has a name consisting of apparently random letters and numbers. I've tried messing around with a bunch of different parameters and have not been able to determine anything that makes it consistently work or consistently not work.
  댓글 수: 2
Kiren SK
Kiren SK 2019년 8월 19일
any resolution ?? . i am getting the same error for polyspace report generation from command line
YTChow
YTChow 2023년 10월 13일
any resolution ?? . i am getting the same error for polyspace report generation from command line
Burt my Error Message is "fl:filesystem:PathNotFound"

댓글을 달려면 로그인하십시오.

답변 (2개)

Helper
Helper 2017년 9월 14일
Hi Robert,
Regarding the document close error, there should be a ‘*_FO’ directory created in the working directory when a report was created. If the creation of that report failed for some reason, that directory is remained and prevents additional reports using the same name. Deleting that directory might resolve this issue.
  댓글 수: 5
Moein Siadaty
Moein Siadaty 2025년 1월 4일
Dear YTChow
I added all the files required for the report generation. but it send the following error:
Error using mlreportgen.report.internal.Document/close
Error closing document package: fl:filesystem:PathNotFound.
Error in mlreportgen.report.ReportBase/close
Error in AFRAHVAC/reportgeneratorPushed (line 3055)
Error in appdesigner.internal.service.AppManagementService/executeCallback (line 172)
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
Error using appdesservices.internal.interfaces.model.AbstractModel/executeUserCallback (line 282)
Error while evaluating Button PrivateButtonPushedFcn.
could you help me to solve this problem?
YTChow
YTChow 2025년 1월 5일
I almost forgot how to solve this problem.Maybe u can delete all the generator files,and rerun the MATLAB as administrator.

댓글을 달려면 로그인하십시오.


Matlab User
Matlab User 2021년 7월 1일
If you have a speciail character in the file/folder path, this error may occur. I had experienced this error when I used "[" in the file path. After removing "[", the issue was solved.

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by