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
652a7641
Commit
652a7641
authored
Feb 09, 2017
by
Edgar HIPP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add base64image test
parent
303222ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
es6/test.js
+29
-0
examples/expectedBase64.docx
+0
-0
No files found.
es6/test.js
View file @
652a7641
...
...
@@ -20,6 +20,7 @@ const fileNames = [
"expectedLoopCentered.docx"
,
"withoutRels.docx"
,
"expectedWithoutRels.docx"
,
"expectedBase64.docx"
,
"tagImage.pptx"
,
"expectedTagImage.pptx"
,
"tagImageCentered.pptx"
,
...
...
@@ -111,6 +112,34 @@ function testStart() {
this
.
data
=
{
image
:
"examples/image.png"
};
this
.
loadAndRender
();
});
it
(
"should work with base64 data"
,
function
()
{
const
base64Image
=
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg=="
this
.
name
=
"imageExample.docx"
;
function
base64DataURLToArrayBuffer
(
dataURL
)
{
const
string_base64
=
dataURL
.
replace
(
/^data:image
\/(
png|jpg
)
;base64,/
,
""
);
var
binary_string
;
if
(
typeof
window
!==
"undefined"
)
{
binary_string
=
window
.
atob
(
string_base64
);
}
else
{
binary_string
=
new
Buffer
(
string_base64
,
'base64'
).
toString
(
'binary'
);
}
var
len
=
binary_string
.
length
;
var
bytes
=
new
Uint8Array
(
len
);
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
var
ascii
=
binary_string
.
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
();
});
});
}
...
...
examples/expectedBase64.docx
0 → 100644
View file @
652a7641
File added
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