mlreportgen.dom.Watermark Class
Namespace: mlreportgen.dom
Add watermark to pages in sections of PDF reports
Description
Creates a watermark object that you can add to a section of a PDF report. A watermark
is an image that appears in the background of a page, such as the word Draft or Confidential. It runs behind the text on each page you apply it to. You
can use any of these file types:
.emf.gif.jpg.pdf.png.svg.tiff
The mlreportgen.dom.Watermark class is a handle class.
Creation
Description
creates a
wm = Watermark(image)Watermark object based on the specified image, and
returns a Watermark object.
Input Arguments
Image to use as the watermark, specified as the image path name. Use any of these file types:
.emf.gif.jpg.pdf.png.svg.tiff
Properties
Path of image file, specified as a character vector or string scalar.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Transient | true |
Data Types: char | string
Watermark height, specified as character vector or string scalar that
contains a number followed by an abbreviation for a unit of measurement. For
example, "10px" specifies 10 pixels. Valid abbreviations
are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Alternatively, You can specify the height using the
Watermark.Style property. For example:
Watermark.Style = {Height("4in")};Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Watermark width, specified as character vector or string scalar that
contains a number followed by an abbreviation for a unit of measurement. For
example, "10px" specifies 10 pixels. Valid abbreviations
are:
"px"— Pixels"cm"— Centimeters"in"— Inches"mm"— Millimeters"pc"— Picas"pt"— Points
Alternatively, you can specify the width using the
Watermark.Style property. For example:
Watermark.Style = {Width("4in")};Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Format specification for this document element object, specified as an array of DOM
format objects. The formats specified by this property override corresponding formats
specified by the StyleName property of this element. Formats that
do not apply to this document element object are ignored.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Custom attributes of the document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be
supported by the output format of the document element to which this object is
appended.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Tag, specified as a character vector or string scalar. The DOM API generates a
session-unique tag as part of the creation of this object. The generated tag has the
form CLASS:ID, where
CLASS is the object class and
ID is the value of the
Id property of the object. Use this value to help identify
where an issue occurs during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Examples
This example shows how to create a watermark programmatically and then apply it to the current layout. Creating the watermark programmatically simplifies files management, because you do not need to store the image file and keep track of its location.
Using MATLAB® commands, create an image file programmatically. Using an SVG image file maintains the resolution as the image scales. After you write the image to a file, you can delete the figure.
wmname = 'wm'; wmtype = 'svg'; wmfilename = [wmname '.' wmtype]; subplot('Position',[0, 0, 1, 1]); axis('off'); text(0.25, 0.25,'Draft', ... 'Rotation', 45, ... 'Color', [0.85, 0.85, 0.85], ... 'FontSize',72); print(wmfilename, ['-d' wmtype]); delete(gcf);
Create the watermark object wm and apply it to the current page layout. After you generate the report, you can delete the image file specified by the variable wmfilename.
import mlreportgen.dom.*; d = Document('myreport','pdf'); open(d); wm = Watermark(wmfilename); wm.Width = '12in'; wm.Height = []; d.CurrentPageLayout.Watermark = wm; append(d,'Hello'); append(d, PageBreak); append(d,'World'); close(d); rptview(d.OutputPath); delete(wmfilename);
Version History
Introduced in R2016bReport Generator no longer supports BMP (bitmap) as an output image format. This affects
snapshots, images from files, and watermarks in both the Report Explorer and the Report,
DOM, and PPT APIs. See print for more information.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)