Customized Style Sheets
Number Pages in Reports
This example shows how to edit a style sheet cell to number the upper-right side of all pages in the generated report.
Define a basic style sheet cell in the Header Content cell group with a condition of
right
.Open a PDF style sheet 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.Click Append.
Add Graphics to Headers in PDF Reports
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 style sheet. This example uses the report
setup file mfile-report.rpt
.
You can use any 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.jpg
image, which is
shown here.
Note
PDF reports only support 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:setedit mfile-report
Create a custom style sheet.
Select Tools > Edit Style Sheet 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 style sheet for PDF
.As Description, enter
Company logo in center of header
.Save the style sheet as
logo_style sheet.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 tosample_logo.jpg
in the Value (XML) field.Save the style sheet.
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 with1.0in
.Save the style sheet.
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 Style Sheet area of the Properties pane on the right:
Specify
Acrobat (PDF)
for File formatSpecify
Logo style sheet for PDF
.
Click Report on the toolbar to generate the report.
Change Font Size, Page Orientation, and Paper Type of a Generated 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 style sheet by editing an existing style sheet 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:
setedit wsvar-report
In the Report Format and Style Sheet 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 Style Sheet 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 style sheet.
In the Properties pane on the right, enter
Custom Large Section Headers
as the style sheet 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 style sheet.
In the Options pane in the middle, select Section Title Level 1 Properties.
In the Properties pane on the right, click Add to current style sheet.
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
style sheet.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 text, 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 style sheet.
Save the style sheet as
customheader.rgs
, in a folder in your MATLAB path.The
customheader.rgs
style sheet appears as an available style sheet in the Options pane in the middle of the Report Explorer. It also appears as an option in the File Converter.
Use the new style sheet to convert the current XML source file.
In the Edit Style Sheet: Main Properties pane on the right, click Send to File Converter
The File Converter appears, with the
customheader.rgs
style sheet 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 style sheet.
Generate the report
wsvar-report.xml
in PDF format usingcustomheader.rgs
..The PDF report appears with horizontally oriented pages of slightly different dimensions.
Edit Font Size as a Derived Value in XML
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 style sheet 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.