フィルターのクリア

Custom PDF Reporter (What did I do wrong?)

7 ビュー (過去 30 日間)
Robert
Robert 2024 年 6 月 19 日
コメント済み: Robert 2024 年 6 月 19 日
Hi! I'm pretty new to Matlab and have my first question after struggling many hours :)
I want to create a custom reporter for my report. I read the documentation for "Define New Reporters" and "Create PDF Document Part Template Library." However, when I generate the report, I only get a blank page.
I added the properties "Title," "Author," and "Version" to "MyTitlePage.m." I unzipped the PDF template default.pdftx, added the required holes to the docpart_templates.html, and zipped it back to default.pdftx.
Which information did I miss or what did i do wrong?
Here ist my short testcode:
Main skript:
import mlreportgen.report.*
rpt = Report("myreport","pdf");
titlePage = MyTitlePage;
titlePage.Title = "Dies ist ein toller Titel";
titlePage.Author = "Me";
titlePage.Version = "1.0";
append(rpt,titlePage);
close(rpt);
rptview(rpt);
docpart_templates.html
<html>
<head>
<meta charset="utf-8" />
<title>Document Part Templates</title>
<link rel="StyleSheet" href="./stylesheets/root.css" type="text/css" />
</head>
<body>
<dplibrary>
<dptemplate name="myFirstDocPartTemp">
<hole id="Title">hole1</hole>
<hole id="Author">hole2</hole>
<hole id="Version">hole3</hole>
</dptemplate>
</dplibrary>
</body>
</html>
Thank you :)

採用された回答

Avni Agrawal
Avni Agrawal 2024 年 6 月 19 日
Hello Robert,
I understand that you are encountering an issue where a blank PDF is being generated. This seems to be happening because the "myFirstDocPartTemp" template name specified in the HTML isn't linked to your MyTitlePage.m file.
To resolve this, you should include an additional line in the method:
obj.TemplateName = "myFirstDocPartTemp";
Therefore, the method within your initialization method would be updated to look like this:
methods
function obj = MyTitlePage(varargin)
obj = obj@mlreportgen.report.Reporter(varargin{:});
obj.TemplateName = "myFirstDocPartTemp";
end
end
If you encounter further issues, please don't hesitate to reach out. After correctly setting the template name in the myTitlePage class, I was able to generate the PDF with the desired outcomes successfully.
I hope this helps!
  1 件のコメント
Robert
Robert 2024 年 6 月 19 日
Ah, thank you very much, I overlooked that. Now I can proceed. Thank you for the quick assistance!

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

その他の回答 (0 件)

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by