- Report (Report): Main container.
- Chapter (Chapter): Top-level divisions (like report chapters).
- Section (Section): Sub-divisions under chapters.
- Figure (Figure): Used to embed plots/figures with optional captions.
Error producing PDF Reports and Figures from Script files?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
1) I keep getting the following error(s) when trying to produce a "PDF" report (1.1-(rptgen.utils.FOPProxy, fop = newFOPImpl(h, fopOutputStream, basePath, locale, extraFonts)and also (1.2-(rptgen.utils.FOPProxy, foToPDFImpl(h, foPath, pdfPath, locale, extraFonts, cleanupFonts). I also get another error with (1.3-(close(rpt)). This seems to happen only for PDF's but not HTML, any ideas anyone?
2) I'm lost for producing figures in my report where and how do I reference my figure/plot? I have 2 plots on the same graph/figure let's say (h1 and h2). Do I reference it as fig=figure(h1,h2) and does the code fit into the section classes respectively? I'm a little unclear on how to organise the report (ch, fig, sect) etc
My current version is R2017b.
Cheers, Frank
0 commentaires
Réponses (1)
Aniket
le 8 Mai 2025
Regarding the first issue, the error seems to be sporadic in R2017b. I am not able to reproduce it in R2019b and later. Hence I recommend upgrading MATLAB to the latest version.
The only workaround for releases prior to R2019b is to generate HTML/word report, and then convert them to PDF.
For the second issue, when generating reports using the Report Generator, figures and plots should be referenced and added to the report using DOM (Document Object Model) or Report API constructs, not directly via figure(h1, h2)
Please find below the steps to plot multiple figures:
1. Creating and Referencing Figures
If you have two plots (e.g., h1 and h2) on the same figure, the code looks like:
fig = figure;
h1 = plot(x1, y1);
hold on;
h2 = plot(x2, y2);
hold off;
This creates a single figure with two plots.
2. Adding Figure to Report
Use the Report API like this:
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('MyReport','pdf');
chapter = Chapter('Title','My Results');
% Add section
sect = Section('Title','My Plot Section');
% Capture the figure
img = Figure(fig);
img.Caption = 'This is a combined plot of h1 and h2';
% Add figure to section
append(sect, img);
% Add section to chapter and chapter to report
append(chapter, sect);
append(rpt, chapter);
close(rpt);
rptview(rpt);
3. Organizing Your Report
Please find more details regarding Report Generation from the following documentation: https://www.mathworks.com/help/rptgen/report-generator-development.html
0 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!