How to create a PDF report with for-loop in Reporter Generator?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tong Wang
el 18 de Jun. de 2018
Comentada: Tong Wang
el 19 de Jun. de 2018
The format of every page in my report is identical, task of report is to load a different image in every page, i tried following code to create 5 blank chapters, but it seems doesn't work.
NumberImage = 5;
for i = 1: NumberImage
ch(i) = Chapter();
ch(i).Layout.Landscape = 1;
end
It would be great, if i can get some tips from you.
0 comentarios
Respuesta aceptada
Rahul Singhal
el 18 de Jun. de 2018
Below is a sample code to create a new landscape chapter for every image and add them to the report:
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report("My Report","pdf");
NumberImage = 5;
for i = 1: NumberImage
% Create a landscape chapter
ch = Chapter("Images");
ch.Layout.Landscape = true;
% Add image to the chapter
add(ch, Image(which("b747.jpg")));
% Add chapter to the report
add(rpt,ch);
end
close(rpt);
rptview(rpt);
If your use case is just to add different images in the same landscape mode, and not to create multiple chapter for that, you can just create a single chapter before the loop, add all the images to that chapter in the loop, and then add the chapter to the report after the loop.
Hope this helps!
5 comentarios
Rahul Singhal
el 18 de Jun. de 2018
You will have to process the matrix to either display the image in a MATLAB figure window or to write it in an image file before adding it to the report.
- If you can display the image in the MATLAB figure window, from the matrix, using the image function (See https://www.mathworks.com/help/matlab/ref/image.html ), you can use mlreportgen.report.Figure reporter to include the figure window snapshot in the report.
- If you can write it in an external image file using imwrite function (See https://www.mathworks.com/help/matlab/ref/imwrite.html ), you can use the mlreportgen.dom.Image by providing the path of the output image file to include in the report.
Más respuestas (0)
Ver también
Categorías
Más información sobre Images, Figures, Axes, Equations, MATLAB Code, and MATLAB Variables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!