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
— Image to use as watermark
path name
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
— Path of image file
character vector | string scalar
Path of image file, specified as a character vector or string scalar.
Attributes:
SetAccess | private |
NonCopyable | true |
Transient | true |
Data Types: char
| string
Height
— Watermark height
character vector | string scalar
Watermark height in the form valueUnits
, specified as a
character vector or a string scalar. Use any of these values for
units:
"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:
NonCopyable | true |
Data Types: char
| string
Width
— Watermark width
character vector | string scalar
Watermark width, specified as a character vector or string scalar in the
form valueUnits
. Use any of these values for
units:
"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:
NonCopyable | true |
Data Types: char
| string
Style
— Format specification
{}
(default) | array of DOM format objects
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:
NonCopyable | true |
CustomAttributes
— Custom attributes of document element
[]
(default) | array of mlreportgen.dom.CustomAttribute
objects
Custom attributes of this 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:
NonCopyable | true |
Tag
— Tag for mlreportgen.dom.Watermark
object
character vector | string scalar
Tag for the mlreportgen.dom.Watermark
object, 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. Specify your own tag value to help
you identify where to look when an issue occurs during document generation.
Attributes:
NonCopyable | true |
Data Types: char
| string
Id
— Object identifier for mlreportgen.dom.Watermark
object
character vector | string scalar
Object identifier for the mlreportgen.dom.Watermark
object, specified as a
character vector or string scalar. The DOM API generates a session-unique identifier
when it creates the document element object. You can specify your own value for
Id
.
Attributes:
NonCopyable | true |
Data Types: char
| string
Examples
Create and Insert Watermark
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 R2016bR2024b: Removal of BMP for image output
Report 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.
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)