Generate PDF report with images and table

87 ビュー (過去 30 日間)
Ali razi
Ali razi 2022 年 1 月 25 日
コメント済み: Ali razi 2022 年 1 月 25 日
In the code below I want to generate a PDF report that I wish it will have two images next to each other and below them a table.
I get this error “
Unable to perform assignment because dot indexing is not supported for variables of this type.
Error in temp1 (line 22)
img1.Width = '3in';
Why and how can I fix it? I presume it will appear also in the img2
Code:
close all;
clear all;
clc;
import mlreportgen.report.*
import mlreportgen.dom.*
Name = {'A';'B';'C';'D';'E'};
codeA = [8;3;8;0;4];
Height = [1;8;4;7;8];
Weight = [6;2;1;4;5];
T = table(Name,codeA,Height,Weight)
ImageOri = imread('rice.png');
x1 = 0;
y1 = 75;
Iroi = imbinarize(imcrop(ImageOri,[x1,y1,150,150]));
rpt = Document('test', 'pdf');
img1 = ImageOri;
img1.Width = '3in';
img1.Height = [];
img2 = IRoi;
img1.Width = '3in';
img1.Height = [];
add(rpt,figure)
add(rpt,T);
close(rpt);
rptview(rpt);

回答 (1 件)

Rahul Singhal
Rahul Singhal 2022 年 1 月 25 日
Hi Ali,
The DOM Image object should be created directly with the image file path, and not with the imread content. For e.g.,
img1 = Image('rice.png');
Also, you can refer to this example on how to place two images side by side: https://www.mathworks.com/help/rptgen/ug/side-by-side-images.html
Thanks,
Rahul
  3 件のコメント
Rahul Singhal
Rahul Singhal 2022 年 1 月 25 日
Yes, you can write out the processed image in an image file using imwrite and then create the DOM Image object with the image file path.
Ali razi
Ali razi 2022 年 1 月 25 日
Thanks. maybe in future version there will be a direct solution

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by