org.docx4j.TextUtils Java Examples
The following examples show how to use
org.docx4j.TextUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WordprocessingMLPackageExtractor.java From docx4j-template with Apache License 2.0 | 5 votes |
public void extract(WordprocessingMLPackage wmlPackage,Writer out) throws Exception { MainDocumentPart documentPart = wmlPackage.getMainDocumentPart(); org.docx4j.wml.Document wmlDocumentEl = documentPart.getContents(); TextUtils.extractText(wmlDocumentEl, out); //out.flush(); //out.close(); }
Example #2
Source File: WordToTextRenditionProvider.java From spring-content with Apache License 2.0 | 5 votes |
@Override public InputStream convert(InputStream fromInputSource, String toMimeType) { try { WordprocessingMLPackage pkg = WordprocessingMLPackage.load(fromInputSource); MainDocumentPart documentPart = pkg.getMainDocumentPart(); org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document) documentPart .getJaxbElement(); OutputStream os = new FileOutputStream("/tmp/temp.txt"); Writer out = new OutputStreamWriter(os); TextUtils.extractText(wmlDocumentEl, out); out.close(); if (pkg.getMainDocumentPart().getFontTablePart() != null) { pkg.getMainDocumentPart().getFontTablePart() .deleteEmbeddedFontTempFiles(); } // This would also do it, via finalize() methods pkg = null; return new FileInputStream("/tmp/temp.txt"); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #3
Source File: DocxFormatterDelegate.java From yarg with Apache License 2.0 | 5 votes |
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(); }
Example #4
Source File: WmlElementUtils.java From docx4j-template with Apache License 2.0 | 4 votes |
public static String getElementContent(Object obj) throws Exception { StringWriter stringWriter = new StringWriter(); TextUtils.extractText(obj, stringWriter); return stringWriter.toString(); }
Example #5
Source File: Docx4j_工具类_S3_Test.java From docx4j-template with Apache License 2.0 | 4 votes |
public String getElementContent(Object obj) throws Exception { StringWriter stringWriter = new StringWriter(); TextUtils.extractText(obj, stringWriter); return stringWriter.toString(); }
Example #6
Source File: Docx4j_读取内容控件_S4_Test.java From docx4j-template with Apache License 2.0 | 4 votes |
public String getSdtContentContent(SdtContent contentAcc) throws Exception { StringWriter stringWriter = new StringWriter(); TextUtils.extractText(contentAcc, stringWriter); return stringWriter.toString(); }
Example #7
Source File: Docx4j_读取内容控件_S3_Test.java From docx4j-template with Apache License 2.0 | 4 votes |
public String getContentAccessorContent(SdtContent contentAcc) throws Exception { StringWriter stringWriter = new StringWriter(); TextUtils.extractText(contentAcc, stringWriter); return stringWriter.toString(); }