Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
c28883f1
Commit
c28883f1
authored
Mar 13, 2017
by
Sergey Luzyanin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
watermark in builder
parent
657dab84
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
11 deletions
+41
-11
word/apiBuilder.js
word/apiBuilder.js
+41
-11
No files found.
word/apiBuilder.js
View file @
c28883f1
...
@@ -1503,17 +1503,47 @@
...
@@ -1503,17 +1503,47 @@
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
/**
/**
* Insert watermark
in the header
of document
* Insert watermark
on each page
of document
* @param {?string} } [sText="W
atermark
"]
* @param {?string} } [sText="W
ATERMARK
"]
* @param {?boolean} [bIsDiagonal=true]
* @param {?boolean} [bIsDiagonal=true]
*/
*/
ApiDocument
.
prototype
.
InsertWatermark
=
function
(
sText
,
bIsDiagonal
){
ApiDocument
.
prototype
.
InsertWatermark
=
function
(
sText
,
bIsDiagonal
){
var
oSectPrMap
=
{};
var
oApiSection
=
this
.
GetFinalSection
();
if
(
this
.
Document
.
SectPr
){
if
(
oApiSection
){
oSectPrMap
[
this
.
Document
.
SectPr
.
Get_Id
()]
=
this
.
Document
.
SectPr
;
privateInsertWatermarkToContent
(
oApiSection
.
GetHeader
(
"
title
"
,
false
),
sText
,
bIsDiagonal
);
}
privateInsertWatermarkToContent
(
oApiSection
.
GetHeader
(
"
even
"
,
false
),
sText
,
bIsDiagonal
);
var
oElement
;
privateInsertWatermarkToContent
(
oApiSection
.
GetHeader
(
"
default
"
,
true
),
sText
,
bIsDiagonal
);
for
(
var
i
=
0
;
i
<
this
.
Document
.
Content
.
length
;
++
i
){
oElement
=
this
.
Document
.
Content
[
i
];
if
(
oElement
instanceof
Paragraph
){
if
(
oElement
.
SectPr
){
oSectPrMap
[
oElement
.
SectPr
.
Get_Id
()]
=
oElement
.
SectPr
;
}
}
}
var
oHeadersMap
=
{};
var
oApiSection
,
oHeader
;
for
(
var
sId
in
oSectPrMap
){
if
(
oSectPrMap
.
hasOwnProperty
(
sId
)){
oApiSection
=
new
ApiSection
(
oSectPrMap
[
sId
]);
oHeader
=
oApiSection
.
GetHeader
(
"
title
"
,
false
);
if
(
oHeader
){
oHeadersMap
[
oHeader
.
Document
.
Get_Id
()]
=
oHeader
;
}
oHeader
=
oApiSection
.
GetHeader
(
"
even
"
,
false
);
if
(
oHeader
){
oHeadersMap
[
oHeader
.
Document
.
Get_Id
()]
=
oHeader
;
}
oHeader
=
oApiSection
.
GetHeader
(
"
default
"
,
true
);
if
(
oHeader
){
oHeadersMap
[
oHeader
.
Document
.
Get_Id
()]
=
oHeader
;
}
}
}
for
(
var
sId
in
oHeadersMap
){
if
(
oHeadersMap
.
hasOwnProperty
(
sId
)){
privateInsertWatermarkToContent
(
this
.
Document
.
Api
,
oHeadersMap
[
sId
],
sText
,
bIsDiagonal
);
}
}
}
};
};
/**
/**
...
@@ -4948,7 +4978,7 @@
...
@@ -4948,7 +4978,7 @@
}
}
function
private_CreateWatermark
(
sText
,
bDiagonal
){
function
private_CreateWatermark
(
sText
,
bDiagonal
){
var
sText2
=
((
typeof
(
sText
)
===
"
string
"
)
&&
(
sText
.
length
>
0
))
?
sText
:
"
W
atermark
"
;
var
sText2
=
((
typeof
(
sText
)
===
"
string
"
)
&&
(
sText
.
length
>
0
))
?
sText
:
"
W
ATERMARK
"
;
var
sFontName2
=
undefined
;
var
sFontName2
=
undefined
;
var
nFontSize2
=
2
;
var
nFontSize2
=
2
;
var
oTextFill2
=
AscFormat
.
CreateUnfilFromRGB
(
127
,
127
,
127
);
var
oTextFill2
=
AscFormat
.
CreateUnfilFromRGB
(
127
,
127
,
127
);
...
@@ -5034,7 +5064,7 @@
...
@@ -5034,7 +5064,7 @@
}
}
function
privateInsertWatermarkToContent
(
oContent
,
sText
,
bIsDiagonal
){
function
privateInsertWatermarkToContent
(
o
Api
,
o
Content
,
sText
,
bIsDiagonal
){
if
(
oContent
){
if
(
oContent
){
var
nElementsCount
=
oContent
.
GetElementsCount
();
var
nElementsCount
=
oContent
.
GetElementsCount
();
for
(
var
i
=
0
;
i
<
nElementsCount
;
++
i
){
for
(
var
i
=
0
;
i
<
nElementsCount
;
++
i
){
...
@@ -5045,7 +5075,7 @@
...
@@ -5045,7 +5075,7 @@
}
}
}
}
if
(
i
===
nElementsCount
){
if
(
i
===
nElementsCount
){
oElement
=
Api
.
CreateParagraph
();
oElement
=
o
Api
.
CreateParagraph
();
oElement
.
AddDrawing
(
private_CreateWatermark
(
sText
,
bIsDiagonal
));
oElement
.
AddDrawing
(
private_CreateWatermark
(
sText
,
bIsDiagonal
));
oContent
.
Push
(
oElement
);
oContent
.
Push
(
oElement
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment