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
7358d564
Commit
7358d564
authored
Feb 06, 2017
by
Edgar HIPP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with fileType mandatory for pptx
parent
ddc6b911
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
CHANGELOG.md
+4
-0
es6/index.js
+2
-2
es6/test.js
+4
-10
No files found.
CHANGELOG.md
View file @
7358d564
### unreleased (master branch)
### unreleased (master branch)
### 3.0.2
-
Fix issue with PPTX : Before, you had to add to your options : {fileType: "pptx"} in the module options passed as argument in the constructor of the module. Now, the fileType is retrieved from the main docxtemplater.
### 3.0.1
### 3.0.1
-
Add support for PPTX.
-
Add support for PPTX.
...
...
es6/index.js
View file @
7358d564
...
@@ -75,7 +75,7 @@ class ImageModule {
...
@@ -75,7 +75,7 @@ class ImageModule {
postparse
(
parsed
)
{
postparse
(
parsed
)
{
let
expandTo
;
let
expandTo
;
let
getInner
;
let
getInner
;
if
(
this
.
options
.
fileType
===
"pptx"
)
{
if
(
this
.
fileType
===
"pptx"
)
{
expandTo
=
"p:sp"
;
expandTo
=
"p:sp"
;
getInner
=
getInnerPptx
;
getInner
=
getInnerPptx
;
}
}
...
@@ -112,7 +112,7 @@ class ImageModule {
...
@@ -112,7 +112,7 @@ class ImageModule {
const
size
=
[
DocUtils
.
convertPixelsToEmus
(
sizePixel
[
0
]),
DocUtils
.
convertPixelsToEmus
(
sizePixel
[
1
])];
const
size
=
[
DocUtils
.
convertPixelsToEmus
(
sizePixel
[
0
]),
DocUtils
.
convertPixelsToEmus
(
sizePixel
[
1
])];
const
centered
=
(
this
.
options
.
centered
||
part
.
centered
);
const
centered
=
(
this
.
options
.
centered
||
part
.
centered
);
let
newText
;
let
newText
;
if
(
this
.
options
.
fileType
===
"pptx"
)
{
if
(
this
.
fileType
===
"pptx"
)
{
newText
=
this
.
getRenderedPartPptx
(
part
,
rId
,
size
,
centered
);
newText
=
this
.
getRenderedPartPptx
(
part
,
rId
,
size
,
centered
);
}
}
else
{
else
{
...
...
es6/test.js
View file @
7358d564
...
@@ -38,11 +38,10 @@ beforeEach(function () {
...
@@ -38,11 +38,10 @@ beforeEach(function () {
};
};
this
.
loadAndRender
=
function
()
{
this
.
loadAndRender
=
function
()
{
const
fileType
=
(
testutils
.
pptX
[
this
.
name
])
?
"pptx"
:
"docx"
;
const
fileType
=
testutils
.
pptX
[
this
.
name
]
?
"pptx"
:
"docx"
;
const
file
=
(
fileType
===
"pptx"
)
?
testutils
.
pptX
[
this
.
name
]
:
testutils
.
docX
[
this
.
name
];
const
file
=
fileType
===
"pptx"
?
testutils
.
pptX
[
this
.
name
]
:
testutils
.
docX
[
this
.
name
];
this
.
doc
=
new
Docxtemplater
();
this
.
doc
=
new
Docxtemplater
();
this
.
doc
.
setOptions
({
fileType
});
this
.
doc
.
setOptions
({
fileType
});
this
.
opts
.
fileType
=
fileType
;
const
inputZip
=
new
JSZip
(
file
.
loadedContent
);
const
inputZip
=
new
JSZip
(
file
.
loadedContent
);
this
.
doc
.
loadZip
(
inputZip
).
setData
(
this
.
data
);
this
.
doc
.
loadZip
(
inputZip
).
setData
(
this
.
data
);
const
imageModule
=
new
ImageModule
(
this
.
opts
);
const
imageModule
=
new
ImageModule
(
this
.
opts
);
...
@@ -59,7 +58,6 @@ function testStart() {
...
@@ -59,7 +58,6 @@ function testStart() {
this
.
name
=
"imageExample.docx"
;
this
.
name
=
"imageExample.docx"
;
this
.
expectedName
=
"expectedOneImage.docx"
;
this
.
expectedName
=
"expectedOneImage.docx"
;
this
.
data
=
{
image
:
"examples/image.png"
};
this
.
data
=
{
image
:
"examples/image.png"
};
this
.
fileType
=
"docx"
;
this
.
loadAndRender
();
this
.
loadAndRender
();
});
});
...
@@ -119,11 +117,7 @@ function testStart() {
...
@@ -119,11 +117,7 @@ function testStart() {
testutils
.
setExamplesDirectory
(
path
.
resolve
(
__dirname
,
".."
,
"examples"
));
testutils
.
setExamplesDirectory
(
path
.
resolve
(
__dirname
,
".."
,
"examples"
));
testutils
.
setStartFunction
(
testStart
);
testutils
.
setStartFunction
(
testStart
);
fileNames
.
forEach
(
function
(
filename
)
{
fileNames
.
forEach
(
function
(
filename
)
{
if
(
filename
.
indexOf
(
".pptx"
)
===
filename
.
length
-
5
)
{
const
loader
=
/
\.
pptx$/
.
test
(
filename
)
?
testutils
.
loadPptx
:
testutils
.
loadDocx
;
testutils
.
loadFile
(
filename
,
testutils
.
loadPptx
);
testutils
.
loadFile
(
filename
,
loader
);
}
else
{
testutils
.
loadFile
(
filename
,
testutils
.
loadDocx
);
}
});
});
testutils
.
start
();
testutils
.
start
();
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