{"id":1196,"date":"2012-05-29T16:00:00","date_gmt":"2012-05-29T16:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/using-groovy-scriptlets-inside-a-docx-document.html"},"modified":"2012-10-26T08:31:56","modified_gmt":"2012-10-26T08:31:56","slug":"using-groovy-scriptlets-inside-docx","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html","title":{"rendered":"Using Groovy scriptlets inside a *.docx document"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\"><strong>Introduction<\/strong><\/p>\n<p>One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length. One contract form can be applied for many customers so the document is a template with customer info put in certain places. <\/p>\n<p>In this article I am going to show you how I solved this problem. <\/p>\n<p><strong>Requirements<\/strong><\/p>\n<p>This is an initial version of formalized requirements : <\/p>\n<p><i>Specified data must be placed in marked places of a complex DOC\/DOCX file<\/i><\/p>\n<p>The requirements were subsequently refined and expanded : <\/p>\n<ol start=\"1\">\n<li><i>Specified data must be placed in marked places of a complex DOCX file.<\/i><\/li>\n<li><i>Output markup must be scriptlet-like: ${}, &lt;%%&gt;, &lt;%=%&gt;.<\/i><\/li>\n<li><i>Output data may be not only strings but also hashes and objects. Field access must be an option.<\/i><\/li>\n<li><i>Output language must be brief and script-friendly: Groovy, JavaScript.<\/i><\/li>\n<li><i>A possibility to display list of objects in a table, each cell displaying a field.<\/i><\/li>\n<\/ol>\n<p><strong>Background<\/strong><\/p>\n<p>It turned out that the existing products in the field (I&#8217;m talking about Java world) do not fit into initial requirements. <\/p>\n<p>A brief overview of the products: <\/p>\n<p><strong>Jasper reports<\/strong><\/p>\n<p><a href=\"http:\/\/jasperforge.org\/projects\/jasperreports\">Jasper Reports<\/a>uses *.jrxml files as templates.  Template file in combination with input data (SQL result set or a Map of params) are given to a processor which forms any of these formats: PDF, XML, HTML, CSV, XLS, RTF, TXT. <\/p>\n<p>Did not fit in: <\/p>\n<ol start=\"1\">\n<li>It\u2019s not a WYSIWYG, even with help of iReport \u2014 a visual tool to create jrxml-templates.<\/li>\n<li>JasperReports API must be learned well to create and style a complex template.<\/li>\n<li>JR does not output in a suitable format. PDF might be okay, but ability of hand-editing is preferable.<\/li>\n<\/ol>\n<p><strong>Docx4java<\/strong><\/p>\n<p><a href=\"http:\/\/www.docx4java.org\/\">Docx4j<\/a>is a Java library for creating and manipulating Microsoft Open XML (Word docx, Powerpoint pptx, and Excel xlsx) files. <\/p>\n<p>&nbsp;Did not fit in: <\/p>\n<ol start=\"1\">\n<li>There is no case meeting my requirements in docx4java <a href=\"http:\/\/www.docx4java.org\/svn\/docx4j\/trunk\/docx4j\/docs\/Docx4j_GettingStarted.html\">documentation<\/a>.  A brief note about XMLUtils.unmarshallFromTemplate functionality is present but it only does simpliest substitutions. <\/li>\n<li>Repeats of output is done with prepared XML-sources and XPath, <a href=\"http:\/\/www.opendope.org\/opendope_conventions_v2.3.html\">link<\/a><\/li>\n<\/ol>\n<p><strong>Apache POI<\/strong><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"http:\/\/poi.apache.org\/\">Apache POI<\/a> is a Java tool for creating and manipulating parts of *. doc, *.ppt, *.xls documents. A major use of the Apache POI api is for Text Extraction applications such as web spiders, index builders, and content management systems. <\/p>\n<p>Did not fit in: <\/p>\n<ol start=\"1\">\n<li>Does not have any options that meet my requirements.<\/li>\n<\/ol>\n<p><strong>Word Content Control Toolkit<\/strong><\/p>\n<p><a href=\"http:\/\/dbe.codeplex.com\/\">Word Content Control Toolkit<\/a> is a stand-alone, light-weight tool that opens any Word Open XML document and lists all of the content controls inside of it. <\/p>\n<p>After I developed my own solution with scriptlets I heard of a solution based on combination of this tool and XSDT-transformations. It may work for somebody but I did not bother digging because it simply takes less steps to use my solution straightforward. <\/p>\n<p><strong>Solution of the problem<\/strong><\/p>\n<p>It was fun! <\/p>\n<p><strong>1<\/strong>.  Document text content is stored as Open XML file inside a zip-archive. Traditional JDK 6 zipper does not support an explicit encoding parameter. That is, a broken docx-file may be produced using this zipper. I had to use a Groovy-wrapper AntBuilder for zipping, which does have an encoding parameter. <\/p>\n<p><strong>2<\/strong>.  Any text inside you enter in MS Word may be \u201carbitrary\u201d broken into parts wrapped with XML. So, I had to solve the problem of cleaning pads generated from the template xml. I used regular expressions for this task. I did not try to use XSLT or anything because I thought RegEx would be faster. <\/p>\n<p><strong>3<\/strong>.  I decided to use Groovy as a scripting language because of its simplicity, Java-nature, and a built-in <a href=\"http:\/\/groovy.codehaus.org\/Groovy+Templates\">template processor<\/a>. I found an interesting issue related to the processor. It turned out that even in a small 10-sheet document one can easily run into a restriction on the length of a string between two scriptlets.<br \/>\nI had to substitute the text going between a pair of scriptlets with a UUID-string, run the Groovy template processor using the modified text, and finally swich back those UUID-placeholders with the initial text fragments. <\/p>\n<p>After overcoming these difficulties, I tried out the project in real life. It turned out well! <\/p>\n<p>I created a project website and published it. <\/p>\n<p>Project address: <a href=\"http:\/\/snowindy.github.com\/scriptlet4docx\/\">snowindy.github.com\/scriptlet4docx\/<\/a><\/p>\n<p><strong>Code example<\/strong><\/p>\n<pre class=\"brush:java\">HashMap&lt;String, Object&gt; params = new HashMap&lt;String, Object&gt;();\r\nparams.put(\"name\",\"John\");\r\nparams.put(\"sirname\",\"Smith\");\r\n\r\nDocxTemplater docxTemplater = new DocxTemplater(new File(\"path_to_docx_template\/template.docx\"));\r\ndocxTemplater.process(new File(\"path_to_result_docx\/result.docx\"), params); \r\n<\/pre>\n<p><strong>Scriptlet types explanation<\/strong><\/p>\n<p><strong>${ data }<\/strong><br \/>\nEquivalent to out.print(data) <\/p>\n<p><strong>&lt;%= data %&gt;<\/strong><br \/>\nEquivalent to out.print(data) <\/p>\n<p><strong>&lt;% any_code %&gt;<\/strong><br \/>\nEvaluates containing code. No output applied. May be used for divided conditions: <\/p>\n<pre class=\"brush:java\">&lt;% if (cond) { %&gt;\r\nThis text block will be printed in case of \"cond == true\"\r\n&lt;% } else { %&gt;\r\nThis text block will be printed otherwise.\r\n&lt;% } %&gt; \r\n<\/pre>\n<p><strong>$[ @listVar.field ]<\/strong><\/p>\n<p>This is a custom Scriptlet4docx scriptlet type designed to output collection of objects to docx tables. It must be used inside a table cell. <\/p>\n<p>Say, we have a list of person objects. Each has two fields: &#8216;name&#8217; and &#8216;address&#8217;. We want to output them to a two-column table. <\/p>\n<ol start=\"1\">\n<li>Create a binding with key &#8216;personList&#8217; referencing that collection.<\/li>\n<li>Create a two-column table inside a template docx-document: two columns, one row.<\/li>\n<li>$[@person.name] goes to the first column cell; $[@person.address] goes to the second.<\/li>\n<li>Voila, the whole collection will be printed to the table.<\/li>\n<\/ol>\n<p><strong>Live template example<\/strong><\/p>\n<p>You can check all mentioned scriptlets usage in a <a href=\"https:\/\/github.com\/downloads\/snowindy\/scriptlet4docx\/template-example.docx\">demonstration template<\/a><\/p>\n<p><strong>Project future<\/strong><\/p>\n<p>If I actually developed a new approach to processing docx-templates, it would be nice to popularize it. <\/p>\n<p>Projects TODOs: <\/p>\n<ol start=\"1\">\n<li>Preprocessed templates caching,<\/li>\n<li>Scriptlets support in lists<\/li>\n<li>Streaming API<\/li>\n<\/ol>\n<p><strong><i>Reference: <\/i><\/strong><i>Using Groovy scriptlets inside a *.docx document<\/i> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/w4g.html\">W4G partner<\/a> <a href=\"http:\/\/www.linkedin.com\/in\/eugene1sapozhnikov\">Eugene Polyhaev<\/a>   <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length. One contract form can be applied for many customers so the document is a template with customer info put in certain places. In this article I am going to show you how &hellip;<\/p>\n","protected":false},"author":314,"featured_media":132,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[480,481,479,206],"class_list":["post-1196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-groovy","tag-eugene-polyhaev","tag-script","tag-templates-word","tag-w4g"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Groovy scriptlets inside a *.docx document - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Groovy scriptlets inside a *.docx document - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-05-29T16:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-26T08:31:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Eugene Polyhaev\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eugene Polyhaev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html\"},\"author\":{\"name\":\"Eugene Polyhaev\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ce9080f41c740c0b869735e10a5e3763\"},\"headline\":\"Using Groovy scriptlets inside a *.docx document\",\"datePublished\":\"2012-05-29T16:00:00+00:00\",\"dateModified\":\"2012-10-26T08:31:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html\"},\"wordCount\":891,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/groovy-logo.jpg\",\"keywords\":[\"Eugene Polyhaev\",\"script\",\"Templates Word\",\"W4G\"],\"articleSection\":[\"Groovy\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html\",\"name\":\"Using Groovy scriptlets inside a *.docx document - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/groovy-logo.jpg\",\"datePublished\":\"2012-05-29T16:00:00+00:00\",\"dateModified\":\"2012-10-26T08:31:56+00:00\",\"description\":\"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/groovy-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/groovy-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/using-groovy-scriptlets-inside-docx.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JVM Languages\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/jvm-languages\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Groovy\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/jvm-languages\\\/groovy\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Using Groovy scriptlets inside a *.docx document\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ce9080f41c740c0b869735e10a5e3763\",\"name\":\"Eugene Polyhaev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g\",\"caption\":\"Eugene Polyhaev\"},\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/eugene-polyhaev\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Groovy scriptlets inside a *.docx document - Java Code Geeks","description":"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html","og_locale":"en_US","og_type":"article","og_title":"Using Groovy scriptlets inside a *.docx document - Java Code Geeks","og_description":"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.","og_url":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-05-29T16:00:00+00:00","article_modified_time":"2012-10-26T08:31:56+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg","type":"image\/jpeg"}],"author":"Eugene Polyhaev","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Eugene Polyhaev","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html"},"author":{"name":"Eugene Polyhaev","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ce9080f41c740c0b869735e10a5e3763"},"headline":"Using Groovy scriptlets inside a *.docx document","datePublished":"2012-05-29T16:00:00+00:00","dateModified":"2012-10-26T08:31:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html"},"wordCount":891,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg","keywords":["Eugene Polyhaev","script","Templates Word","W4G"],"articleSection":["Groovy"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html","url":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html","name":"Using Groovy scriptlets inside a *.docx document - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg","datePublished":"2012-05-29T16:00:00+00:00","dateModified":"2012-10-26T08:31:56+00:00","description":"Introduction One of my recent projects required automated generation of contracts for customers. Contract is a legal document of about 10 pages length.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/groovy-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/using-groovy-scriptlets-inside-docx.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JVM Languages","item":"https:\/\/www.javacodegeeks.com\/category\/jvm-languages"},{"@type":"ListItem","position":3,"name":"Groovy","item":"https:\/\/www.javacodegeeks.com\/category\/jvm-languages\/groovy"},{"@type":"ListItem","position":4,"name":"Using Groovy scriptlets inside a *.docx document"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ce9080f41c740c0b869735e10a5e3763","name":"Eugene Polyhaev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3619fefe55cc854395f9628deb405600bfad7a143249f2d3f755e58be1fa1391?s=96&d=mm&r=g","caption":"Eugene Polyhaev"},"url":"https:\/\/www.javacodegeeks.com\/author\/eugene-polyhaev"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/314"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1196"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/132"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}