{"id":235,"date":"2013-10-18T07:43:31","date_gmt":"2013-10-17T21:43:31","guid":{"rendered":"http:\/\/www.docx4java.org\/blog\/?p=235"},"modified":"2013-10-18T07:49:03","modified_gmt":"2013-10-17T21:49:03","slug":"docx4j-3-0-what-you-need-to-know","status":"publish","type":"post","link":"https:\/\/www.docx4java.org\/blog\/2013\/10\/docx4j-3-0-what-you-need-to-know\/","title":{"rendered":"docx4j 3.0 &#8211; what you need to know"},"content":{"rendered":"<p>docx4j 3.0 (beta for which will be available shortly) contains a lot of changes, some big, some small.<\/p>\n<p>Here are the most visible (see our <a href=\"https:\/\/github.com\/plutext\/docx4j\/blob\/master\/CHANGELOG.md\">changelog<\/a> for the rest):<\/p>\n<p><strong>Logging<\/strong><\/p>\n<p>docx4j 3.0 uses slf4j, instead of log4j.<\/p>\n<p>As the slf4j website puts it:<\/p>\n<blockquote><p>The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at\u00a0<em>deployment<\/em> time.<\/p><\/blockquote>\n<p>So you need the slf4j api jar on your classpath:<\/p>\n<p>&lt;dependency&gt;<br \/>\n&lt;groupId&gt;org.slf4j&lt;\/groupId&gt;<br \/>\n&lt;artifactId&gt;slf4j-api&lt;\/artifactId&gt;<br \/>\n&lt;version&gt;1.7.5&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<p>If you want to use log4j, then include it, and:<\/p>\n<p>&lt;dependency&gt;<br \/>\n&lt;groupId&gt;org.slf4j&lt;\/groupId&gt;<br \/>\n&lt;artifactId&gt;slf4j-log4j12&lt;\/artifactId&gt;<br \/>\n&lt;version&gt;1.7.5&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<p><strong>XHTML Import<\/strong><\/p>\n<p>The XHTML Import functionality is now a <a href=\"https:\/\/github.com\/plutext\/docx4j-ImportXHTML\">separate project on GitHub<\/a>.<\/p>\n<p>The reason being that its main dependency &#8211; Flying Saucer &#8211;\u00a0is licensed under LGPL v2.1 (as opposed to ASL v2, which docx4j&#8217;s other dependencies use).<\/p>\n<p>If you want this functionality, you have to add these jars to your classpath. \u00a0We&#8217;ll update this post with their coordinates once they are in Maven Central.<\/p>\n<p><strong>Docx4j facade<\/strong><\/p>\n<p><strong> <\/strong><\/p>\n<div>3.0 contains a <a href=\"https:\/\/github.com\/plutext\/docx4j\/blob\/master\/src\/main\/java\/org\/docx4j\/Docx4J.java\">facade<\/a> providing clean access to some typical uses of docx4j:<\/div>\n<div>\n<ul>\n<li>Loading a document<\/li>\n<li>Saving a document<\/li>\n<li>Binding xml to content controls in a document<\/li>\n<li>Exporting the document (to HTML, or PDF and other formats supported by the FO renderer)<\/li>\n<\/ul>\n<\/div>\n<p>You don&#8217;t have to use this &#8211; in that existing code should continue to work &#8211; but the facade is the right way to do things. \u00a0Behind the facade is a major rethink\/cleanup to the export architecture\/implementation, contributed by Alberto.<\/p>\n<p><strong>MOXy<\/strong><\/p>\n<p>The key technology underlying docx4j &#8211; and a major differentiator from Apache POI &#8211; is JAXB.<\/p>\n<p>There is a JAXB reference implementation; the JAXB baked into Java 6 and 7 is based on it.<\/p>\n<p>Prior to v3, you had to use the reference implementation, or the implementation included in the JDK.<\/p>\n<p>With v3, you can choose to use <a href=\"http:\/\/www.eclipse.org\/eclipselink\/moxy.php\">EclipseLink MOXy<\/a> instead. \u00a0To do so, simply include <a href=\"http:\/\/www.docx4java.org\/docx4j\/docx4j-MOXy-JAXBContext-3.0.0.jar\">docx4j-MOXy-JAXBContext-3.0.0.jar<\/a> and the MOXy jars on your classpath.<\/p>\n<p><strong>Sample code<\/strong><\/p>\n<p>The docx4j samples have relocated to\u00a0<a href=\"https:\/\/github.com\/plutext\/docx4j\/tree\/master\/src\/samples\">src\/samples<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>docx4j 3.0 (beta for which will be available shortly) contains a lot of changes, some big, some small. Here are the most visible (see our changelog for the rest): Logging docx4j 3.0 uses slf4j, instead of log4j. As the slf4j website puts it: The Simple Logging Facade for Java (SLF4J) serves as a simple facade [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":3,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":237,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions\/237"}],"wp:attachment":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}