|On this page…|
This example shows how to edit a stylesheet cell to number the upper-right side of all pages in the generated report.
Define a basic stylesheet cell in the Header Content cell group with a condition of right.
Open a PDF stylesheet in the Report Explorer.
Double-click Header Content (under Pagination and General Styles) in the Options pane in the middle.
Click Position - Right in the Properties pane on the right.
Set the header content to the current page number by selecting Page number from the Append template selection list.
This example shows how to include an image in the center of the header of each page in a PDF report, excluding the report's title page and the first page of each chapter. You do this by editing default header content for a PDF stylesheet. This example uses the report setup file mfile-report.rpt.
You can use any bitmap or jpeg file as image content. You must know the size of the image so that you can allow enough room for it in the header. This example uses the sample_logo.bmp image, which is shown here.
Note: PDF reports only support bitmap (.bmp), jpeg (.jpg), and Scalable Vector Graphics (.svg) images.
To include this image file in the center of each header in the body of a PDF report:
Open mfile-report.rpt by entering the following at the MATLAB® command prompt:
Create a custom stylesheet.
Select Tools > Edit Stylesheet in the menu bar of the Report Explorer.
Click New FO (PDF) in the Properties pane on the right.
As the Display name, enter Logo stylesheet for PDF.
As Description, enter Company logo in center of header.
Save the stylesheet as logo_stylesheet.rgs in a folder on your MATLAB path.
Open the cell group for editing.
Scroll through the Options pane on the left to the Pagination and General Styles folder.
Double-click Header Content in the Options pane.
Click Body page – Center from the list of cells in the Properties pane on the right.
The Properties pane appears as shown.
Delete the text in the Value (XML) field.
Select Graphic from the Append template selection list and click Append.
The Properties pane on the right shows the XML code that tells the File Converter to include the graphic.
By default, the name of the graphic is logo.bmp. Change all instances of this name to sample_logo.bmp in the Value (XML) field.
Save the stylesheet.
Make sure that the amount of room available in the header is large enough to accommodate the image file.
In the Options pane in the middle, double-click Region Before Extent, which is in the Pagination and General Styles folder.
By default the value for the height of the header is 0.4 inch. Replace this value with 1.0in.
Save the stylesheet.
Generate the report with the new styles.
Select mfile-report.rpt in the Outline pane on the left.
In the selection lists under the Report Format and Stylesheet area of the Properties pane on the right:
Specify Acrobat (PDF) for File format
Specify Logo stylesheet for PDF.
Click Report on the toolbar to generate the report.
This example shows how to:
Generate an XML source file without converting it to a supported report format
Make section headers in a report larger
Change the report page orientation to landscape
Change the report paper type to A4
Create a custom stylesheet by editing an existing stylesheet to change the appearance of the wsvar-report report, which is provided with the MATLAB Report Generator™ software.
Generate a source file for the report.
Open the report by entering the following command in the MATLAB Command Window:
In the Report Format and Stylesheet area of the Properties pane, change the format to DocBook (no transform).
Check the If report already exists, increment to prevent overwriting check box.
Select File > Report to generate the report.
The report-generation process creates an XML source file in the MATLAB Editor.
Convert the report to PDF format.
Select Tools > Convert Source File from the Report Explorer menu bar to open the File Converter.
From the Source file selection list, enter wsvar-report0.xml.
From the File format selection list, select Acrobat (PDF).
From the Stylesheet selection list, select Unnumbered Chapters and Sections.
Click Convert File.
The MATLAB Report Generator software converts the XML source file for wsvar-report to PDF format, and then opens the PDF document.
Make the report headers more prominent.
In the File Converter, click Edit.
The Report Explorer displays the Unnumbered Chapters and Sections stylesheet.
In the Properties pane on the right, enter Custom Large Section Headers as the stylesheet name.
Enter the description No chapter and section numbering, larger section titles.
In the Outline pane on the left, select the Custom Large Section Headers stylesheet.
In the Options pane in the middle, select Section Title Level 1 Properties.
In the Properties pane on the right, click Add to current stylesheet.
The Section Title Level 1 Properties data item appears in the Outline pane on the left as a child of the Custom Large Section Headers stylesheet.
In the Properties pane on the right, select the Font Size attribute.
The Properties pane on the right displays an XML expression specifying font size as a multiple of the Body Font Size attribute.
Click Edit as string.
The MATLAB Report Generator software converts the XML expression to a simple string, which appears in a pane labeled Value.
Enter the value 18pt.
The size of the font is now fixed at 18 points, rather than being a multiple of the body font size attribute.
Select File > Save to save the stylesheet.
Save the stylesheet as customheader.rgs, in a folder in your MATLAB path.
The customheader.rgs stylesheet appears as an available stylesheet in the Options pane in the middle of the Report Explorer. It also appears as an option in the File Converter.
Use the new stylesheet to convert the current XML source file.
In the Stylesheet Editor: Main Properties pane on the right, click Send to File Converter
The File Converter appears, with the customheader.rgs stylesheet selected.
Click Convert file.
Change page orientation and paper type.
On the File Converter Properties pane, click Edit.
In the Options pane on the left, double-click the Page Orientation data item.
In the Properties pane on the right, use the selection list to change the value of the data item to Landscape.
In the Options pane in the middle, double-click Paper Type in the Pagination and General Styles folder.
In the Properties pane on the right, select A4 from the selection list.
Save the stylesheet.
Generate the report wsvar-report.xml in PDF format using customheader.rgs..
The PDF report appears with horizontally oriented pages of slightly different dimensions.
This example shows how to change the font size in a report to a value derived from other values. You do this by editing the PDF report's XML source directly.
Open the default print stylesheet for PDF documents.
In the Options pane in the middle, select and expand the Property Sets folder.
In the Options pane, double-click the Section Title Level1 Properties data item.
The Properties pane on the right appears as follows.
In the Attributes area of the Properties pane on the right, click Font Size - <xml>.
The Report Explorer looks as follows.
The font size value is a product of $body.font.master and 2.0736. To change the font size to a larger size, change the multiplication factor to 3.0736.
Tip You specify the value for the $body.font.master data item in the Body Font Master property. This property is in the Pagination and General Styles category in the Options pane in the middle. The default value of this data item is 10. Changing this value causes the derived values to change accordingly.