Custom PDF Reporter (What did I do wrong?)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Robert
el 19 de Jun. de 2024
Comentada: Robert
el 19 de Jun. de 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 :)
0 comentarios
Respuesta aceptada
Avni Agrawal
el 19 de Jun. de 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.
For additional information, you might find the following documentation helpful: https://www.mathworks.com/help/rptgen/ug/define-new-types-of-reporters.html#:~:text=obj.TemplateName%20%3D%20%22MyTitlePage%22%3B
I hope this helps!
Más respuestas (0)
Ver también
Categorías
Más información sobre Paragraphs, Text Strings, and Numbers 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!