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
7ea09b92
Commit
7ea09b92
authored
Apr 16, 2018
by
MaxRcd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed support for PPTX documents and centered images
parent
77664b68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
es6/index.js
+17
-17
No files found.
es6/index.js
View file @
7ea09b92
...
...
@@ -20,16 +20,18 @@ function getInnerPptx({part, left, right, postparsed}) {
return
concat
+
item
.
value
;
},
""
);
const
xmlDoc
=
new
DOMParser
().
parseFromString
(
"<xml>"
+
xmlString
+
"</xml>"
);
part
.
offset
=
{
x
:
0
,
y
:
0
};
part
.
ext
=
{
cx
:
0
,
cy
:
0
};
const
offset
=
xmlDoc
.
getElementsByTagName
(
"a:off"
);
const
ext
=
xmlDoc
.
getElementsByTagName
(
"a:ext"
);
part
.
ext
=
{
cx
:
parseInt
(
ext
[
0
].
getAttribute
(
"cx"
),
10
),
cy
:
parseInt
(
ext
[
0
].
getAttribute
(
"cy"
),
10
),
}
;
part
.
offset
=
{
x
:
parseInt
(
offset
[
0
].
getAttribute
(
"x"
),
10
),
y
:
parseInt
(
offset
[
0
].
getAttribute
(
"y"
),
10
),
}
;
if
(
ext
.
length
>
0
)
{
part
.
ext
.
cx
=
parseInt
(
ext
[
ext
.
length
-
1
].
getAttribute
(
"cx"
),
10
);
part
.
ext
.
cy
=
parseInt
(
ext
[
ext
.
length
-
1
].
getAttribute
(
"cy"
),
10
);
}
if
(
offset
.
length
>
0
)
{
part
.
offset
.
x
=
parseInt
(
offset
[
offset
.
length
-
1
].
getAttribute
(
"x"
),
10
);
part
.
offset
.
y
=
parseInt
(
offset
[
offset
.
length
-
1
].
getAttribute
(
"y"
),
10
);
}
return
part
;
}
...
...
@@ -119,17 +121,15 @@ class ImageModule {
return
{
value
:
newText
};
}
getRenderedPartPptx
(
part
,
rId
,
size
,
centered
)
{
const
offset
=
{
x
:
part
.
offset
.
x
,
y
:
part
.
offset
.
y
};
const
cellCX
=
part
.
ext
.
cx
;
const
cellCY
=
part
.
ext
.
cy
;
const
imgW
=
size
[
0
];
const
imgH
=
size
[
1
];
const
offset
=
{
x
:
parseInt
(
part
.
offset
.
x
,
10
),
y
:
parseInt
(
part
.
offset
.
y
,
10
)};
const
cellCX
=
parseInt
(
part
.
ext
.
cx
,
10
)
||
1
;
const
cellCY
=
parseInt
(
part
.
ext
.
cy
,
10
)
||
1
;
const
imgW
=
parseInt
(
size
[
0
],
10
)
||
1
;
const
imgH
=
parseInt
(
size
[
1
],
10
)
||
1
;
if
(
centered
)
{
offset
.
x
+=
cellCX
/
2
-
imgW
/
2
;
offset
.
y
+=
cellCY
/
2
-
imgH
/
2
;
offset
.
x
=
Math
.
round
(
offset
.
x
+
(
cellCX
/
2
)
-
(
imgW
/
2
))
;
offset
.
y
=
Math
.
round
(
offset
.
y
+
(
cellCY
/
2
)
-
(
imgH
/
2
))
;
}
return
templates
.
getPptxImageXml
(
rId
,
[
imgW
,
imgH
],
offset
);
}
getRenderedPartDocx
(
rId
,
size
,
centered
)
{
...
...
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