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: .bmp
, .jpg
,
.png
, .svg
, and
.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:
.bmp
.jpg
.pdf
(for PDF output types only).png
.svg
.tiff
Properties
Height
— Watermark height
character vector
Character vector 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 height using the
Watermark.Style
property. For example:
Watermark.Style = {Height('4in')};
Path
— Path of image file
character vector
Path of image file, specified as a character vector.
Style
— Format specification
{}
(default) | array of format objects
Format specification for this document element object, specified as an array of 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 element are ignored.
Attributes:
NonCopyable | true |
Data Types: cell
Width
— Watermark width
character vector
Watermark width, specified as a character vector 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')};
Tag
— Tag for mlreportgen.dom.Watermark
object
character vector | string scalar
Tag for 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
— Identifier for mlreportgen.dom.Watermark
object
character vector | string scalar
Object identifier for 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 R2016b
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
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)