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
1ae98fee
Commit
1ae98fee
authored
Feb 09, 2017
by
Edgar HIPP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix lint
parent
652a7641
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
.eslintrc
+1
-0
es6/test.js
+11
-11
No files found.
.eslintrc
View file @
1ae98fee
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
"parser": "babel-eslint",
"parser": "babel-eslint",
"globals":{
"globals":{
"saveAs": true,
"saveAs": true,
"Uint8Array": true,
"JSZipUtils": true
"JSZipUtils": true
},
},
"env": {
"env": {
...
...
es6/test.js
View file @
1ae98fee
...
@@ -114,28 +114,28 @@ function testStart() {
...
@@ -114,28 +114,28 @@ function testStart() {
});
});
it
(
"should work with base64 data"
,
function
()
{
it
(
"should work with base64 data"
,
function
()
{
const
base64Image
=
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg=="
const
base64Image
=
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg=="
;
this
.
name
=
"imageExample.docx"
;
this
.
name
=
"imageExample.docx"
;
function
base64DataURLToArrayBuffer
(
dataURL
)
{
function
base64DataURLToArrayBuffer
(
dataURL
)
{
const
string
_b
ase64
=
dataURL
.
replace
(
/^data:image
\/(
png|jpg
)
;base64,/
,
""
);
const
string
B
ase64
=
dataURL
.
replace
(
/^data:image
\/(
png|jpg
)
;base64,/
,
""
);
var
binary_s
tring
;
let
binaryS
tring
;
if
(
typeof
window
!==
"undefined"
)
{
if
(
typeof
window
!==
"undefined"
)
{
binary
_string
=
window
.
atob
(
string_b
ase64
);
binary
String
=
window
.
atob
(
stringB
ase64
);
}
}
else
{
else
{
binary
_string
=
new
Buffer
(
string_base64
,
'base64'
).
toString
(
'binary'
);
binary
String
=
new
Buffer
(
stringBase64
,
"base64"
).
toString
(
"binary"
);
}
}
var
len
=
binary_s
tring
.
length
;
const
len
=
binaryS
tring
.
length
;
var
bytes
=
new
Uint8Array
(
len
);
const
bytes
=
new
Uint8Array
(
len
);
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
var
ascii
=
binary_s
tring
.
charCodeAt
(
i
);
const
ascii
=
binaryS
tring
.
charCodeAt
(
i
);
bytes
[
i
]
=
ascii
;
bytes
[
i
]
=
ascii
;
}
}
return
bytes
.
buffer
;
return
bytes
.
buffer
;
}
;
}
this
.
opts
.
getImage
=
function
(
image
)
{
this
.
opts
.
getImage
=
function
(
image
)
{
return
image
;
return
image
;
}
}
;
this
.
expectedName
=
"expectedBase64.docx"
;
this
.
expectedName
=
"expectedBase64.docx"
;
this
.
data
=
{
image
:
base64DataURLToArrayBuffer
(
base64Image
)};
this
.
data
=
{
image
:
base64DataURLToArrayBuffer
(
base64Image
)};
this
.
loadAndRender
();
this
.
loadAndRender
();
...
...
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