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
f128d57a
Commit
f128d57a
authored
Dec 03, 2014
by
Edgar Hipp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
centering should work as it is inline now
parent
1c982f48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
20 deletions
+6
-20
coffee/index.coffee
+2
-16
coffee/test.coffee
+4
-4
No files found.
coffee/index.coffee
View file @
f128d57a
...
...
@@ -107,28 +107,14 @@ class ImageModule
"""
<w:p>
<w:pPr>
<w:pStyle w:val="Normal"/>
<w:jc w:val="center"/>
<w:rPr/>
</w:pPr>
<w:r>
<w:rPr/>
<w:drawing>
<wp:anchor behindDoc="0" distT="0" distB="0" distL="0" distR="0" simplePos="0" locked="0" layoutInCell="1" allowOverlap="1" relativeHeight="0">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:align>center</wp:align>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:align>top</wp:align>
</wp:positionV>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="2060575" cy="1939290"/>
<wp:effectExtent l="0" t="0" r="0" b="0"/>
<wp:wrapSquare wrapText="largest"/>
<wp:docPr id="0" name="Picture" descr=""/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
...
...
@@ -163,7 +149,7 @@ class ImageModule
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:
anchor
>
</wp:
inline
>
</w:drawing>
</w:r>
</w:p>
...
...
coffee/test.coffee
View file @
f128d57a
...
...
@@ -78,8 +78,8 @@ describe 'image adding with {% image} syntax', ()->
documentContent
=
documentFile
.
asText
()
# expect(documentContent).to.equal("""<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wx=\"http://schemas.microsoft.com/office/word/2003/auxHint\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:body><w:p>\n\t<w:pPr>\n\t<w:jc w:val=\"center\"/>\n </w:pPr>\n <w:r>\n\t<w:rPr/>\n\t<w:drawing>\n\t <wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\n\t\t<wp:extent cx=\"1905000\" cy=\"1905000\"/>\n\t\t<wp:docPr id=\"15\" name=\"rId6.png\"/>\n\t\t<a:graphic>\n\t\t <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">\n\t\t\t<pic:pic>\n\t\t\t <pic:nvPicPr>\n\t\t\t\t<pic:cNvPr id=\"15\" name=\"rId6.png\"/>\n\t\t\t\t<pic:cNvPicPr/>\n\t\t\t </pic:nvPicPr>\n\t\t\t <pic:blipFill>\n\t\t\t\t<a:blip r:embed=\"rId6\"/>\n\t\t\t\t</pic:blipFill>\n\t\t\t <pic:spPr>\n\t\t\t\t<a:xfrm>\n\t\t\t\t <a:off x=\"0\" y=\"0\"/>\n\t\t\t\t <a:ext cx=\"1905000\" cy=\"1905000\"/>\n\t\t\t\t</a:xfrm>\n\t\t\t\t<a:prstGeom prst=\"rect\">\n\t\t\t\t <a:avLst/>\n\t\t\t\t</a:prstGeom>\n\t\t\t </pic:spPr>\n\t\t\t</pic:pic>\n\t\t </a:graphicData>\n\t\t </a:graphic>\n\t\t </wp:inline>\n\t\t </w:drawing>\n\t</w:r>\n</w:p><w:sectPr><w:headerReference w:type=\"default\" r:id=\"hId0\"/><w:type w:val=\"continuous\"/><w:pgSz w:w=\"12240\" w:h=\"15840\" w:orient=\"portrait\"/><w:pgMar w:top=\"2810\" w:left=\"1800\" w:right=\"1800\" w:bottom=\"1440\"/><w:cols w:num=\"1\" w:sep=\"off\" w:equalWidth=\"1\"/></w:sectPr></w:body></w:document>""")
#
expect
(
documentContent
).
to
.
contain
(
'align'
)
expect
(
documentContent
).
to
.
contain
(
'center'
)
#
expect(documentContent).to.contain('align')
#
expect(documentContent).to.contain('center')
fs
.
writeFile
(
"test_center.docx"
,
zip
.
generate
({
type
:
"nodebuffer"
}));
...
...
@@ -87,7 +87,7 @@ describe 'image adding with {% image} syntax', ()->
it
'should work with loops'
,()
->
name
=
'imageLoopExample.docx'
imageModule
=
new
ImageModule
({
centered
:
fals
e
})
imageModule
=
new
ImageModule
({
centered
:
tru
e
})
docX
[
name
].
attachModule
(
imageModule
)
out
=
docX
[
name
]
...
...
@@ -115,7 +115,7 @@ describe 'image adding with {% image} syntax', ()->
documentFile
=
zip
.
files
[
'word/document.xml'
]
expect
(
documentFile
?
).
to
.
equal
(
true
)
documentContent
=
documentFile
.
asText
()
expect
(
documentContent
).
to
.
equal
(
"""<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?><w:document xmlns:r=
\"
http://schemas.openxmlformats.org/officeDocument/2006/relationships
\"
xmlns:v=
\"
urn:schemas-microsoft-com:vml
\"
xmlns:wx=
\"
http://schemas.microsoft.com/office/word/2003/auxHint
\"
xmlns:wp=
\"
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing
\"
xmlns:m=
\"
http://schemas.openxmlformats.org/officeDocument/2006/math
\"
xmlns:a=
\"
http://schemas.openxmlformats.org/drawingml/2006/main
\"
xmlns:pic=
\"
http://schemas.openxmlformats.org/drawingml/2006/picture
\"
xmlns:w=
\"
http://schemas.openxmlformats.org/wordprocessingml/2006/main
\"
><w:body><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=
\"
preserve
\"
></w:t></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:drawing>
\n
<wp:inline distT=
\"
0
\"
distB=
\"
0
\"
distL=
\"
0
\"
distR=
\"
0
\"
>
\n
<wp:extent cx=
\"
1905000
\"
cy=
\"
1905000
\"
/>
\n
<wp:effectExtent l=
\"
0
\"
t=
\"
0
\"
r=
\"
0
\"
b=
\"
0
\"
/>
\n
<wp:docPr id=
\"
2
\"
name=
\"
Image 2
\"
descr=
\"
description
\"
/>
\n
<wp:cNvGraphicFramePr>
\n
<a:graphicFrameLocks xmlns:a=
\"
http://schemas.openxmlformats.org/drawingml/2006/main
\"
noChangeAspect=
\"
1
\"
/>
\n
</wp:cNvGraphicFramePr>
\n
<a:graphic xmlns:a=
\"
http://schemas.openxmlformats.org/drawingml/2006/main
\"
>
\n
<a:graphicData uri=
\"
http://schemas.openxmlformats.org/drawingml/2006/picture
\"
>
\n
<pic:pic xmlns:pic=
\"
http://schemas.openxmlformats.org/drawingml/2006/picture
\"
>
\n
<pic:nvPicPr>
\n
<pic:cNvPr id=
\"
0
\"
name=
\"
Picture 1
\"
descr=
\"
description
\"
/>
\n
<pic:cNvPicPr>
\n
<a:picLocks noChangeAspect=
\"
1
\"
noChangeArrowheads=
\"
1
\"
/>
\n
</pic:cNvPicPr>
\n
</pic:nvPicPr>
\n
<pic:blipFill>
\n
<a:blip r:embed=
\"
rId6
\"
>
\n
<a:extLst>
\n
<a:ext uri=
\"
{28A0092B-C50C-407E-A947-70E740481C1C}
\"
>
\n
<a14:useLocalDpi xmlns:a14=
\"
http://schemas.microsoft.com/office/drawing/2010/main
\"
val=
\"
0
\"
/>
\n
</a:ext>
\n
</a:extLst>
\n
</a:blip>
\n
<a:srcRect/>
\n
<a:stretch>
\n
<a:fillRect/>
\n
</a:stretch>
\n
</pic:blipFill>
\n
<pic:spPr bwMode=
\"
auto
\"
>
\n
<a:xfrm>
\n
<a:off x=
\"
0
\"
y=
\"
0
\"
/>
\n
<a:ext cx=
\"
1905000
\"
cy=
\"
1905000
\"
/>
\n
</a:xfrm>
\n
<a:prstGeom prst=
\"
rect
\"
>
\n
<a:avLst/>
\n
</a:prstGeom>
\n
<a:noFill/>
\n
<a:ln>
\n
<a:noFill/>
\n
</a:ln>
\n
</pic:spPr>
\n
</pic:pic>
\n
</a:graphicData>
\n
</a:graphic>
\n
</wp:inline>
\n
</w:drawing></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=
\"
preserve
\"
></w:t></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:drawing>
\n
<wp:inline distT=
\"
0
\"
distB=
\"
0
\"
distL=
\"
0
\"
distR=
\"
0
\"
>
\n
<wp:extent cx=
\"
1905000
\"
cy=
\"
1905000
\"
/>
\n
<wp:effectExtent l=
\"
0
\"
t=
\"
0
\"
r=
\"
0
\"
b=
\"
0
\"
/>
\n
<wp:docPr id=
\"
2
\"
name=
\"
Image 2
\"
descr=
\"
description
\"
/>
\n
<wp:cNvGraphicFramePr>
\n
<a:graphicFrameLocks xmlns:a=
\"
http://schemas.openxmlformats.org/drawingml/2006/main
\"
noChangeAspect=
\"
1
\"
/>
\n
</wp:cNvGraphicFramePr>
\n
<a:graphic xmlns:a=
\"
http://schemas.openxmlformats.org/drawingml/2006/main
\"
>
\n
<a:graphicData uri=
\"
http://schemas.openxmlformats.org/drawingml/2006/picture
\"
>
\n
<pic:pic xmlns:pic=
\"
http://schemas.openxmlformats.org/drawingml/2006/picture
\"
>
\n
<pic:nvPicPr>
\n
<pic:cNvPr id=
\"
0
\"
name=
\"
Picture 1
\"
descr=
\"
description
\"
/>
\n
<pic:cNvPicPr>
\n
<a:picLocks noChangeAspect=
\"
1
\"
noChangeArrowheads=
\"
1
\"
/>
\n
</pic:cNvPicPr>
\n
</pic:nvPicPr>
\n
<pic:blipFill>
\n
<a:blip r:embed=
\"
rId7
\"
>
\n
<a:extLst>
\n
<a:ext uri=
\"
{28A0092B-C50C-407E-A947-70E740481C1C}
\"
>
\n
<a14:useLocalDpi xmlns:a14=
\"
http://schemas.microsoft.com/office/drawing/2010/main
\"
val=
\"
0
\"
/>
\n
</a:ext>
\n
</a:extLst>
\n
</a:blip>
\n
<a:srcRect/>
\n
<a:stretch>
\n
<a:fillRect/>
\n
</a:stretch>
\n
</pic:blipFill>
\n
<pic:spPr bwMode=
\"
auto
\"
>
\n
<a:xfrm>
\n
<a:off x=
\"
0
\"
y=
\"
0
\"
/>
\n
<a:ext cx=
\"
1905000
\"
cy=
\"
1905000
\"
/>
\n
</a:xfrm>
\n
<a:prstGeom prst=
\"
rect
\"
>
\n
<a:avLst/>
\n
</a:prstGeom>
\n
<a:noFill/>
\n
<a:ln>
\n
<a:noFill/>
\n
</a:ln>
\n
</pic:spPr>
\n
</pic:pic>
\n
</a:graphicData>
\n
</a:graphic>
\n
</wp:inline>
\n
</w:drawing></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=
\"
preserve
\"
></w:t></w:r><w:bookmarkStart w:id=
\"
20
\"
w:name=
\"
_GoBack
\"
/><w:bookmarkEnd w:id=
\"
20
\"
/></w:p><w:sectPr><w:headerReference w:type=
\"
default
\"
r:id=
\"
hId0
\"
/><w:type w:val=
\"
continuous
\"
/><w:pgSz w:w=
\"
12240
\"
w:h=
\"
15840
\"
w:orient=
\"
portrait
\"
/><w:pgMar w:top=
\"
2810
\"
w:left=
\"
1800
\"
w:right=
\"
1800
\"
w:bottom=
\"
1440
\"
/><w:cols w:num=
\"
1
\"
w:sep=
\"
off
\"
w:equalWidth=
\"
1
\"
/></w:sectPr></w:body></w:document>"""
)
#
expect(documentContent).to.equal("""<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wx=\"http://schemas.microsoft.com/office/word/2003/auxHint\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:body><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\"></w:t></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:drawing>\n <wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\n <wp:extent cx=\"1905000\" cy=\"1905000\"/>\n <wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>\n <wp:docPr id=\"2\" name=\"Image 2\" descr=\"description\"/>\n <wp:cNvGraphicFramePr>\n <a:graphicFrameLocks xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" noChangeAspect=\"1\"/>\n </wp:cNvGraphicFramePr>\n <a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\n <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">\n <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">\n <pic:nvPicPr>\n <pic:cNvPr id=\"0\" name=\"Picture 1\" descr=\"description\"/>\n <pic:cNvPicPr>\n <a:picLocks noChangeAspect=\"1\" noChangeArrowheads=\"1\"/>\n </pic:cNvPicPr>\n </pic:nvPicPr>\n <pic:blipFill>\n <a:blip r:embed=\"rId6\">\n <a:extLst>\n <a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\">\n <a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/>\n </a:ext>\n </a:extLst>\n </a:blip>\n <a:srcRect/>\n <a:stretch>\n <a:fillRect/>\n </a:stretch>\n </pic:blipFill>\n <pic:spPr bwMode=\"auto\">\n <a:xfrm>\n <a:off x=\"0\" y=\"0\"/>\n <a:ext cx=\"1905000\" cy=\"1905000\"/>\n </a:xfrm>\n <a:prstGeom prst=\"rect\">\n <a:avLst/>\n </a:prstGeom>\n <a:noFill/>\n <a:ln>\n <a:noFill/>\n </a:ln>\n </pic:spPr>\n </pic:pic>\n </a:graphicData>\n </a:graphic>\n </wp:inline>\n</w:drawing></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\"></w:t></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:drawing>\n <wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\n <wp:extent cx=\"1905000\" cy=\"1905000\"/>\n <wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>\n <wp:docPr id=\"2\" name=\"Image 2\" descr=\"description\"/>\n <wp:cNvGraphicFramePr>\n <a:graphicFrameLocks xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" noChangeAspect=\"1\"/>\n </wp:cNvGraphicFramePr>\n <a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">\n <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">\n <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">\n <pic:nvPicPr>\n <pic:cNvPr id=\"0\" name=\"Picture 1\" descr=\"description\"/>\n <pic:cNvPicPr>\n <a:picLocks noChangeAspect=\"1\" noChangeArrowheads=\"1\"/>\n </pic:cNvPicPr>\n </pic:nvPicPr>\n <pic:blipFill>\n <a:blip r:embed=\"rId7\">\n <a:extLst>\n <a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\">\n <a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/>\n </a:ext>\n </a:extLst>\n </a:blip>\n <a:srcRect/>\n <a:stretch>\n <a:fillRect/>\n </a:stretch>\n </pic:blipFill>\n <pic:spPr bwMode=\"auto\">\n <a:xfrm>\n <a:off x=\"0\" y=\"0\"/>\n <a:ext cx=\"1905000\" cy=\"1905000\"/>\n </a:xfrm>\n <a:prstGeom prst=\"rect\">\n <a:avLst/>\n </a:prstGeom>\n <a:noFill/>\n <a:ln>\n <a:noFill/>\n </a:ln>\n </pic:spPr>\n </pic:pic>\n </a:graphicData>\n </a:graphic>\n </wp:inline>\n</w:drawing></w:r></w:p><w:p><w:pPr></w:pPr></w:p><w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\"></w:t></w:r><w:bookmarkStart w:id=\"20\" w:name=\"_GoBack\"/><w:bookmarkEnd w:id=\"20\"/></w:p><w:sectPr><w:headerReference w:type=\"default\" r:id=\"hId0\"/><w:type w:val=\"continuous\"/><w:pgSz w:w=\"12240\" w:h=\"15840\" w:orient=\"portrait\"/><w:pgMar w:top=\"2810\" w:left=\"1800\" w:right=\"1800\" w:bottom=\"1440\"/><w:cols w:num=\"1\" w:sep=\"off\" w:equalWidth=\"1\"/></w:sectPr></w:body></w:document>""")
buffer
=
zip
.
generate
({
type
:
"nodebuffer"
})
fs
.
writeFile
(
"test_multi.docx"
,
buffer
);
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