wie kann man mit Matlab Report Generator ein Fußzeile erstellen , die die aktuelle Datum (linksbündig), Seite Nummer (Center)und Uhrzeit(rechtsbündig) beinhaltet
2 次查看(过去 30 天)
显示 更早的评论
function Creat_head_foot(report,Page)
import mlreportgen.report.*
import mlreportgen.dom.*
currentLayout = report.getReportLayout;
%Create a page header definition for the PDF document.
pdfheader = PDFPageHeader();
%Create a DOM Paragraph object and make it center aligned and bold. Set its font size to 12pt. Append it to the PDFPageHeader object.
p = Paragraph('Simulation von SDR mit Anwendung von BPSK');
p.Style = [p.Style, {HAlign('center'), Bold(true),Italic(true),FontSize('8pt')}];
append(pdfheader, p);
%Assign the created pdfheader object to the PageHeaders of the current page layout.
currentLayout.PageHeaders = pdfheader;
pdffooter = PDFPageFooter();
%Append a horizontal rule to the pdffooter object.
append(pdffooter, HorizontalRule());
%Append an image to the pdffooter object. Use the DOM ScaleToFit format to scale the image to fit in the page. Assign the created pdffooter object to the PageFooters of the current page layout.
pagePara = Paragraph("");
%pagePara.WhiteSpace = "preserve";
pagePara.HAlign = "center";
dateText=datestr(now, 'dd-mm-yyyy');
timeText=datestr(now, 'hh:mm:ss');
tableStyle = {Border('none'),RowSep('none'), ColSep('none'),...
Width('100%')};
% Create a style to center the text in all cells
cellStyle = {HAlign('center'), VAlign('middle')};
% Create a table with two rows and two columns
t = Table({dateText,Page,timeText }); %
% Apply the styles
t.Style = tableStyle;
t.TableEntriesHAlign='left';
t.TableEntriesStyle = cellStyle;
currentLayout.PageFooters = pdffooter;
currentLayout.PageMargins.Bottom = '0.5in';
currentLayout.PageMargins.Footer = '0.4in';
1 个评论
Prateekshya
2023-8-18
I understand that you are trying to generate a MATLAB Report with some specific orientation to the footer. However, this is a generic query and the MATLAB Documentation itself can be of a great help. Hence, please specify the exact issue that you are facing which will help me to understand the problem better.
回答(1 个)
Pavan Sahith
2023-11-15
Hello Khaled,
I understand that you want to know how to create a footer with Matlab Report Generator that contains the current date (left aligned), page number (center) and time (right aligned).
To achieve that, consider trying the following method that I came across in MATLAB answers forum.
1. Import all functions from the package 'mlreportgen.dom'.
2. Open a PDF document for writing with the "Document" function.
3. Create the objects 'left', 'center', and 'right' that correspond to the text that will appear on each part of the footer. Specifically, 'left' is a 'Paragraph' object containing ‘date’, 'center' is a 'Paragraph' object containing the page number, and 'right' is a 'Paragraph' object containing the time
4. Create a 'PDFPageFooter' object from the default template. Append both a 'HorizontalRule' object, and a 'Table' object which has the 'left', 'center', and 'right' objects as entries.
5. Create a 'PDFPageLayout' object and append the footer to this object.
Please refer to the similar question, which will help you
'How can I add a custom footer to my MATLAB Report Generator report?' https://in.mathworks.com/matlabcentral/answers/373581
Please refer to the MathWorks documentation to know more.
- 'Create Page Footers and Headers' - https://in.mathworks.com/help/rptgen/ug/add-page-footers-and-headers.html
- 'mlreportgen.dom.PDFPageFooter class' - https://in.mathworks.com/help/rptgen/ug/mlreportgen.dom.pdfpagefooter-class.html
Hope that helps
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!