Package org.docx4j.samples
package org.docx4j.samples
-
ClassesClassDescriptionThis adds an AlternativeFormatInputPart containing a docx.Add HTML, in a way that leaves it up to downstream application (eg Word) to convert the content to docx content.Create a docx containing an XHTML AltChunk, and then convert that to normal docx content.Perform certain bookmark integrity checksReplace text between w:bookmarkStarts and corresponding w:bookmarkEnds with specified data, matching on bookmark's @w:nameCreates a WordprocessingML document from scratch, and adds a comment.This sample demonstrates populating content controls from a custom xml part (based on the xpaths given in the content controls), via FLAG_BIND_BIND_XML Word does this itself automatically, for if there is a w:databinding element in the sdtPr.This sample demonstrates populating content controls from a custom xml part (based on the xpaths given in the content controls).This sample removes all content controls from the input docx, keeping their content.Creates a docx containing a CustomXml part.This simple example demonstrates populating content controls with values obtained from a Custom XML file in the docx.This simple example demonstrates populating content controls with values obtained from a Custom XML file in the docx.Copy content control content back to the custom XML part.This sample is similar to PartsList, but it provides info specific to your CustomXML parts.Show the content controls in the main document part indenting as nested.This sample demonstrates populating content controls from a custom xml part (based on the xpaths given in the content controls) In this example, the XML part is injected at runtime, and OpenDoPE extensions are supported (if present).This sample demonstrates setting the XML content of an Custom XML part, then populating content controls from that (based on the xpaths given in the content controls).This is a simple proof of concept of converting Word 2003 XML to ECMA 376 docx.Convert a docx to 'Flat OPC XML' format, which Word/Powerpoint can happily read, and which is convenient for editing in an XML editor.This sample uses XSLT (and Xalan) to produce HTML output.This sample uses XSLT (and Xalan) to produce HTML output.Demo of PDF output.Demo of PDF output.Protect document against editing in Word.Simple example showing how to see the document's XML (MainDocumentPart).Shows how to access a docx's: - Core properties (Dublin Core title, creator etc) - Extended properties (app.xml) - Custom properties (where you can store your own data, as shown here) Note there is often also /word/settings.xml (see also TemplateAttach for how to set a dotx in that part)Where Word reports an error in a very large file, XML-aware tools such as Visual Studio might have trouble opening it.Simple example of monitoring docx4j events.Implement your net.engio.mbassy.listener.HandlerExample of adding the INCLUDEPICTURE field, via simple and complex field approaches.List all field instructions found in docx (main document part, headers, footers).Example of how to process MERGEFIELD.Example of how to process mailing labels with MERGEFIELD / NEXT See http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/MERGEFIELD.htmlorg.docx4j.model.fields.merge.MailMerger has options for what to do with MERGEFIELD after processing, and that is ordinarily what you would use.Example showing how to refresh DOCPROPERTY and DOCVARIABLE fields in the docx.Example showing how to renumber SEQ fields.Remove proof error markup, rsids etc.Running Xalan extension functions on Android is problematic: http://stackoverflow.com/questions/10579339/is-it-possible-to-call-a-java-extension-function-from-xalan-on-android and generating the XSL FO via Xalan + extension functions is a bit slow, so this uses TraversalUtils to generate XSL FO output without any need for Xalan or XSLT.Simple way to check whether a font exists, and if it does, whether it contains a particular glyph.Example showing how to remove font type and size settings from throughout the document, and setting these in rPrDefault.How to add a footnoteRemove all footnotesCreate a WordML Pkg and add a header to it.This sample tells you how docx4j is interpreting headers/footers in your docx.Create a WordML Pkg and add a header to it.Fun with hyperlinks to external resources eg web pages.Examples of adding images to a docxTakes existing images internal to the package, and points at them with TargetMode="External", and r:link (instead of r:embed).<w:drawing> <wp:inline distT="0" distB="0" distL="0" distR="0"> <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"> <pic:blipFill> <a:blip r:embed="rId5" />How to add a macroBasic demo handling Office Math.This sample demonstrates how the MergeDocx utility can be used to merge docx documents.Create a docx which says "hello world"Creates a WordprocessingML document from scratch, including a numbering definitions part, and use it to demonstrate restart numbering.Simple example of opening an existing docx, and saving it again.To see what parts comprise your docx, try the PartsList sample.Example of loading an unzipped file from the file system.Example of saving a docx unzipped.'Copy' a part from one package to another.Import foreign parts, relying on docx4j to work out which part to create.Remove certain parts from docx, either the specified docx, or each one in the specified directory (beware!).Restrict formatting to an allowed set of styles.This class generates a sample document in case no document has been passed.This class generates a sample document in case no document has been passed.Microsoft Word places a hard limit on the number of styles it allows.Master and Subdocuments.Shows how to creates a WordprocessingML document from a template (dotx file), and how to attach a template (for example, instead of Normal.dot)This example uses docx4j's internal capabilities to generate a ToC.Modern versions of Word typically insert a ToC within an SDT (aka content control).This is an end-to-end example showing you how to to add and populate a ToC, then update it.This example uses docx4j's internal capabilities to update a ToC.Accept changes (r:ins, r:del) in the Main Document Part, via XSLTShows how to turn the track changes setting off (or on), for when the docx is next edited in Word.Example of how to remove w:pageBreakBefore in <w:p> <w:pPr> <w:pageBreakBefore/> </w:pPr>There are at least 3 approaches for replacing variables in a docx.There are at least 3 approaches for replacing variables in a docx.This is an example of using SAX rather than JAXB for processing.This is an example of using StAX rather than JAXB for processing.A watermark is set via the headers.This deletes complex fields of type checkBox.