Azzera filtri
Azzera filtri

Custom PDF Reporter (What did I do wrong?)

7 visualizzazioni (ultimi 30 giorni)
Robert
Robert il 19 Giu 2024
Commentato: Robert il 19 Giu 2024
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 :)

Risposta accettata

Avni Agrawal
Avni Agrawal il 19 Giu 2024
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 Commento
Robert
Robert il 19 Giu 2024
Ah, thank you very much, I overlooked that. Now I can proceed. Thank you for the quick assistance!

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by