/** * Extract contents of descendant <w:t> elements. * * @param o * @param jcSVG JAXBContext * @return */ public static void extractText(Object o, Writer w) throws Exception { extractText(o, w, Context.jc); }
/** * Extract contents of descendant <w:t> elements. * * @param o * @return String * @since 6.0.0 */ public static String getText(Object o) { StringWriter w = new StringWriter(); try { extractText(o, w, Context.jc); } catch (Exception e) { log.warn(e.getMessage()); return null; } return w.toString(); }
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(); }
/** * @since 3.0.0 */ public String getTitle() { if (this.getDocPropsCorePart()==null) { return null; } JAXBElement<SimpleLiteral> sl = this.getDocPropsCorePart().getJaxbElement().getTitle(); if (sl == null) return null; StringWriter sw = new StringWriter(); try { TextUtils.extractText(sl, sw, Context.jcDocPropsCore); } catch (Exception e) { log.error(e.getMessage(), e); } return sw.toString(); }
TextUtils.extractText(p, out); } catch (Exception e) { e.printStackTrace();
/** * Extract contents of descendant <w:t> elements. * * @param o * @param jcSVG JAXBContext * @return */ public static void extractText(Object o, Writer w) throws Exception { extractText(o, w, Context.jc); }
/** * Extract contents of descendant <w:t> elements. * * @param o * @return String * @since 6.0.0 */ public static String getText(Object o) { StringWriter w = new StringWriter(); try { extractText(o, w, Context.jc); } catch (Exception e) { log.warn(e.getMessage()); return null; } return w.toString(); }
public String getElementText(Object element) { StringWriter w = new StringWriter(); try { TextUtils.extractText(element, w); } catch (Exception e) { throw docxFormatter.wrapWithReportingException("An error occurred while rendering docx template.", e); } return w.toString(); }
public String getElementText(Object element) { StringWriter w = new StringWriter(); try { TextUtils.extractText(element, w); } catch (Exception e) { throw docxFormatter.wrapWithReportingException("An error occurred while rendering docx template.", e); } return w.toString(); }
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(); }
/** * @since 3.0.0 */ public String getTitle() { if (this.getDocPropsCorePart()==null) { return null; } JAXBElement<SimpleLiteral> sl = this.getDocPropsCorePart().getJaxbElement().getTitle(); if (sl == null) return null; StringWriter sw = new StringWriter(); try { TextUtils.extractText(sl, sw, Context.jcDocPropsCore); } catch (Exception e) { log.error(e.getMessage(), e); } return sw.toString(); }
TextUtils.extractText(p, out); } catch (Exception e) { e.printStackTrace();