@Override public String getMceIgnorable() { return this.getJaxbElement().getIgnorable(); }
/** Combine complex fields to w:fldSimple * */ public static void process(WordprocessingMLPackage wmlPackage) { log.info("starting"); TraversalUtil.visit(wmlPackage, false, COMBINE_VISITOR); if (log.isDebugEnabled()) { log.debug(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); } }
public static void main(String[] args) throws Exception { String inputfilepath = System.getProperty("user.dir") + "/sample-docs/Table.docx"; //String inputfilepath = System.getProperty("user.dir") + "/sample-docs/Word2007-fonts.docx"; WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath)); MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart(); org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document)documentPart.getJaxbElement(); Writer out = new OutputStreamWriter(System.out); extractText(wmlDocumentEl, out); //out.flush(); out.close(); }
@Override protected void setMceIgnorable(McIgnorableNamespaceDeclarator namespacePrefixMapper) { // NB it is up to you to jaxbElement.setIgnorable; see further McIgnorableNamespaceDeclarator // MainDocumentPartMceIgnorableHelper helper = new MainDocumentPartMceIgnorableHelper(); // this.jaxbElement.setIgnorable( // helper.getMceIgnorable(this.getJaxbElement().getBody())); namespacePrefixMapper.setMcIgnorable( this.getJaxbElement().getIgnorable() ); }
public SectPrFinder(MainDocumentPart mdp) { // Handle the body level one if (mdp.getJaxbElement().getBody().getSectPr()!=null) { bodyLevel = mdp.getJaxbElement().getBody().getSectPr(); } }
/** * Convenience method to getJaxbElement().getBody().getContent() * @since 2.7 */ public List<Object> getContent() { if (this.getJaxbElement()==null) { this.setJaxbElement( Context.getWmlObjectFactory().createDocument() ); } if (this.getJaxbElement().getBody()==null) { this.getJaxbElement().setBody( Context.getWmlObjectFactory().createBody() ); } return this.getJaxbElement().getContent(); }
public static void main(String[] args) throws Exception { boolean save=true; String inputfilepath = System.getProperty("user.dir") + "/sample-docs/word/unmarshallFromTemplateDirtyExample.docx"; WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath)); // Before .. note attributes w:rsidRDefault="00D15781" w:rsidR="00D15781" System.out.println(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); prepare(wmlPackage); System.out.println(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); // Save it if (save) { SaveToZipFile saver = new SaveToZipFile(wmlPackage); saver.save(System.getProperty("user.dir") + "/OUT_VariablePrepare.docx"); System.out.println("Saved"); } }
/** * @param args * @throws Docx4JException */ public static void main(String[] args) throws Docx4JException { WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load( new java.io.File( System.getProperty("user.dir") + "/aq1.docx")); FieldUpdater fu = new FieldUpdater(wordMLPackage); fu.update(true); System.out.println(XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true)); }
/** * If the first w:p starts with a w:sectPr, this is moved into a * new following w:p. This prevents the creation of an empty fo:flow, * which causes a validation exception in FOP. */ public static void process(WordprocessingMLPackage wmlPackage) { Body body = wmlPackage.getMainDocumentPart().getJaxbElement().getBody(); moveSectPr(body); }
/** * If a page-break w:br w:type="page" is found within a run with some formatting applied to it * then it will be generated into an fo:inline tag. This page break will be ignored by fop. This class * moves the page-breaks to the enclosing block. */ public static void process(WordprocessingMLPackage wmlPackage) { Body body = wmlPackage.getMainDocumentPart().getJaxbElement().getBody(); //TODO: Convert to visitor movePageBreaks(body); }
@Override protected Document getSourceDocument(HTMLSettings conversionSettings, HTMLConversionContext conversionContext) throws Docx4JException { WordprocessingMLPackage wmlPackage = conversionContext.getWmlPackage(); //TODO: the docx2xhtml-core.xslt only knows about the MainDocumentPart, therefore it's //unable to process any sections.... return XmlUtils.marshaltoW3CDomDocument(wmlPackage.getMainDocumentPart().getJaxbElement()); }
private void process() { propertyResolver = wmlPackage.getMainDocumentPart().getPropertyResolver(); List<Object> newContent = process(wmlPackage.getMainDocumentPart().getContent()); wmlPackage.getMainDocumentPart().getJaxbElement().getBody().getContent().clear(); wmlPackage.getMainDocumentPart().getJaxbElement().getBody().getContent().addAll(newContent); }
public static void process(WordprocessingMLPackage wmlPackage) { Body body = wmlPackage.getMainDocumentPart().getJaxbElement().getBody(); if (body==null || body.getContent().size()==0) { log.warn("w:document/w:body null or empty"); return; } Object o = body.getContent().get(0); if (o instanceof P && ((P)o).getPPr()!=null) { PPr pPr = ((P)o).getPPr(); BooleanDefaultTrue val = new BooleanDefaultTrue(); val.setVal(Boolean.FALSE); pPr.setPageBreakBefore(val); } } }
log.info(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true)); org.docx4j.wml.Document wmlDocumentEl = wmlPackage.getMainDocumentPart().getJaxbElement(); Body body = wmlDocumentEl.getBody(); log.info(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true));
Document wmlDocumentEl = (Document)documentPart.getJaxbElement(); Body body = wmlDocumentEl.getBody();
Document wmlDocumentEl = (Document)documentPart.getJaxbElement(); Body body = wmlDocumentEl.getBody();
groupAdjacentBorders(mainDocument.getJaxbElement().getBody().getContent());
Document wmlDocumentEl = (Document)documentPart.getJaxbElement(); Body body = wmlDocumentEl.getBody();
SectPr sectPr = template.getMainDocumentPart().getJaxbElement().getBody().getSectPr();
Document doc = (Document)wordMLPackage.getMainDocumentPart().getJaxbElement();