Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
docxtemplater-image-module
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
docxtemplater-image-module
Commits
eca28cc1
Commit
eca28cc1
authored
Jul 20, 2016
by
Edgar HIPP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update checks == null
parent
ca42a850
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
7 deletions
+7
-7
es6/imgManager.js
+1
-1
es6/imgReplacer.js
+3
-3
es6/index.js
+3
-3
es6/test.js
+0
-0
No files found.
es6/imgManager.js
View file @
eca28cc1
...
@@ -31,7 +31,7 @@ module.exports = class ImgManager {
...
@@ -31,7 +31,7 @@ module.exports = class ImgManager {
}
}
loadImageRels
()
{
loadImageRels
()
{
const
file
=
this
.
zip
.
files
[
`word/_rels/
${
this
.
endFileName
}
.xml.rels`
]
||
this
.
zip
.
files
[
"word/_rels/document.xml.rels"
];
const
file
=
this
.
zip
.
files
[
`word/_rels/
${
this
.
endFileName
}
.xml.rels`
]
||
this
.
zip
.
files
[
"word/_rels/document.xml.rels"
];
if
(
file
==
=
undefined
)
{
return
;
}
if
(
file
==
null
)
{
return
;
}
const
content
=
DocUtils
.
decodeUtf8
(
file
.
asText
());
const
content
=
DocUtils
.
decodeUtf8
(
file
.
asText
());
this
.
xmlDoc
=
DocUtils
.
str2xml
(
content
);
this
.
xmlDoc
=
DocUtils
.
str2xml
(
content
);
// Get all Rids
// Get all Rids
...
...
es6/imgReplacer.js
View file @
eca28cc1
...
@@ -71,10 +71,10 @@ module.exports = class ImgReplacer {
...
@@ -71,10 +71,10 @@ module.exports = class ImgReplacer {
return
;
return
;
}
}
const
tagrId
=
xmlImg
.
getElementsByTagName
(
"a:blip"
)[
0
];
const
tagrId
=
xmlImg
.
getElementsByTagName
(
"a:blip"
)[
0
];
if
(
tagrId
==
=
undefined
)
{
throw
new
Error
(
"tagRiD undefined !"
);
}
if
(
tagrId
==
null
)
{
throw
new
Error
(
"tagRiD undefined !"
);
}
const
rId
=
tagrId
.
getAttribute
(
"r:embed"
);
const
rId
=
tagrId
.
getAttribute
(
"r:embed"
);
const
tag
=
xmlImg
.
getElementsByTagName
(
"wp:docPr"
)[
0
];
const
tag
=
xmlImg
.
getElementsByTagName
(
"wp:docPr"
)[
0
];
if
(
tag
==
=
undefined
)
{
throw
new
Error
(
"tag undefined"
);
}
if
(
tag
==
null
)
{
throw
new
Error
(
"tag undefined"
);
}
// if image is already a replacement then do nothing
// if image is already a replacement then do nothing
if
(
tag
.
getAttribute
(
"name"
).
substr
(
0
,
6
)
===
"Copie_"
)
{
return
;
}
if
(
tag
.
getAttribute
(
"name"
).
substr
(
0
,
6
)
===
"Copie_"
)
{
return
;
}
const
imgName
=
this
.
imgManager
.
getImageName
();
const
imgName
=
this
.
imgManager
.
getImageName
();
...
@@ -86,7 +86,7 @@ module.exports = class ImgReplacer {
...
@@ -86,7 +86,7 @@ module.exports = class ImgReplacer {
tag
.
setAttribute
(
"name"
,
`
${
imgName
}
`
);
tag
.
setAttribute
(
"name"
,
`
${
imgName
}
`
);
tagrId
.
setAttribute
(
"r:embed"
,
`rId
${
newId
}
`
);
tagrId
.
setAttribute
(
"r:embed"
,
`rId
${
newId
}
`
);
const
imageTag
=
xmlImg
.
getElementsByTagName
(
"w:drawing"
)[
0
];
const
imageTag
=
xmlImg
.
getElementsByTagName
(
"w:drawing"
)[
0
];
if
(
imageTag
==
=
undefined
)
{
throw
new
Error
(
"imageTag undefined"
);
}
if
(
imageTag
==
null
)
{
throw
new
Error
(
"imageTag undefined"
);
}
const
replacement
=
DocUtils
.
xml2Str
(
imageTag
);
const
replacement
=
DocUtils
.
xml2Str
(
imageTag
);
this
.
xmlTemplater
.
content
=
this
.
xmlTemplater
.
content
.
replace
(
match
[
0
],
replacement
);
this
.
xmlTemplater
.
content
=
this
.
xmlTemplater
.
content
.
replace
(
match
[
0
],
replacement
);
...
...
es6/index.js
View file @
eca28cc1
...
@@ -7,9 +7,9 @@ const ImgReplacer = require("./imgReplacer");
...
@@ -7,9 +7,9 @@ const ImgReplacer = require("./imgReplacer");
class
ImageModule
{
class
ImageModule
{
constructor
(
options
)
{
constructor
(
options
)
{
this
.
options
=
options
||
{};
this
.
options
=
options
||
{};
if
(
!
(
this
.
options
.
centered
!=
null
)
)
{
this
.
options
.
centered
=
false
;
}
if
(
this
.
options
.
centered
==
null
)
{
this
.
options
.
centered
=
false
;
}
if
(
!
(
this
.
options
.
getImage
!=
null
)
)
{
throw
new
Error
(
"You should pass getImage"
);
}
if
(
this
.
options
.
getImage
==
null
)
{
throw
new
Error
(
"You should pass getImage"
);
}
if
(
!
(
this
.
options
.
getSize
!=
null
)
)
{
throw
new
Error
(
"You should pass getSize"
);
}
if
(
this
.
options
.
getSize
==
null
)
{
throw
new
Error
(
"You should pass getSize"
);
}
this
.
qrQueue
=
[];
this
.
qrQueue
=
[];
this
.
imageNumber
=
1
;
this
.
imageNumber
=
1
;
}
}
...
...
es6/test.js
View file @
eca28cc1
This diff is collapsed.
Click to expand it.
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