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 @@
"parser": "babel-eslint",
"globals":{
"saveAs": true,
"Uint8Array": true,
"JSZipUtils": true
},
"env": {
...
...
es6/test.js
View file @
1ae98fee
...
...
@@ -114,28 +114,28 @@ function testStart() {
});
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"
;
function
base64DataURLToArrayBuffer
(
dataURL
)
{
const
string
_b
ase64
=
dataURL
.
replace
(
/^data:image
\/(
png|jpg
)
;base64,/
,
""
);
var
binary_s
tring
;
const
string
B
ase64
=
dataURL
.
replace
(
/^data:image
\/(
png|jpg
)
;base64,/
,
""
);
let
binaryS
tring
;
if
(
typeof
window
!==
"undefined"
)
{
binary
_string
=
window
.
atob
(
string_b
ase64
);
binary
String
=
window
.
atob
(
stringB
ase64
);
}
else
{
binary
_string
=
new
Buffer
(
string_base64
,
'base64'
).
toString
(
'binary'
);
binary
String
=
new
Buffer
(
stringBase64
,
"base64"
).
toString
(
"binary"
);
}
var
len
=
binary_s
tring
.
length
;
var
bytes
=
new
Uint8Array
(
len
);
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
var
ascii
=
binary_s
tring
.
charCodeAt
(
i
);
const
len
=
binaryS
tring
.
length
;
const
bytes
=
new
Uint8Array
(
len
);
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
const
ascii
=
binaryS
tring
.
charCodeAt
(
i
);
bytes
[
i
]
=
ascii
;
}
return
bytes
.
buffer
;
}
;
}
this
.
opts
.
getImage
=
function
(
image
)
{
return
image
;
}
}
;
this
.
expectedName
=
"expectedBase64.docx"
;
this
.
data
=
{
image
:
base64DataURLToArrayBuffer
(
base64Image
)};
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