/** * Return the string content of this text run * * @return the text of this text run or <code>null</code> if not set */ public String getText(int pos) { return run.sizeOfTArray() == 0 ? null : run.getTArray(pos) .getStringValue(); }
text.append(((CTText) o).getStringValue());
String tmpText = tArray[j].getStringValue(); int startChar = 0, endChar = tmpText.length() - 1; if ((j == textBegin) && (i == runBegin)) {
if (o instanceof CTText) { if (textPos >= startText) { String candidate = ((CTText) o).getStringValue(); if (runPos == startRun) { charPos = startChar;
@Override protected void visitText( CTText docxText, boolean pageNumber, IITextContainer pdfParagraphContainer ) throws Exception { Font font = currentRunFontAscii; Font fontAsian = currentRunFontEastAsia; Font fontComplex = currentRunFontHAnsi; createAndAddChunks( pdfParagraphContainer, docxText.getStringValue(), currentRunUnderlinePatterns, currentRunBackgroundColor, pageNumber, font, fontAsian, fontComplex ); }
@Override protected void visitText( CTText docxText, boolean pageNumber, IITextContainer pdfParagraphContainer ) throws Exception { Font font = currentRunFontAscii; Font fontAsian = currentRunFontEastAsia; Font fontComplex = currentRunFontHAnsi; createAndAddChunks( pdfParagraphContainer, docxText.getStringValue(), currentRunUnderlinePatterns, currentRunBackgroundColor, pageNumber, font, fontAsian, fontComplex ); }
@Override protected void visitText(CTText docxText, boolean pageNumber, IITextContainer pdfParagraphContainer) throws Exception { Font font = currentRunFontAscii; Font fontAsian = currentRunFontEastAsia; Font fontComplex = currentRunFontHAnsi; createAndAddChunks(pdfParagraphContainer, docxText.getStringValue(), currentRunUnderlinePatterns, currentRunBackgroundColor, pageNumber, font, fontAsian, fontComplex); }
@Override protected void visitText(CTText docxText, boolean pageNumber, IITextContainer pdfParagraphContainer) throws Exception { Font font = currentRunFontAscii; Font fontAsian = currentRunFontEastAsia; Font fontComplex = currentRunFontHAnsi; createAndAddChunks(pdfParagraphContainer, docxText.getStringValue(), currentRunUnderlinePatterns, currentRunBackgroundColor, pageNumber, font, fontAsian, fontComplex); }
/** * Returns the instr text of the given run and null otherwise. * * @param r * @return */ public static String getInstrText( CTR r ) { List<CTText> instrTextList = r.getInstrTextList(); if ( instrTextList == null || instrTextList.size() < 1 ) { return null; } if ( instrTextList.size() == 1 ) { return instrTextList.get( 0 ).getStringValue(); } StringBuilder instrText = new StringBuilder(); for ( CTText ctText : instrTextList ) { instrText.append( ctText.getStringValue() ); } return instrText.toString(); }
/** * Returns the instr text of the given run and null otherwise. * * @param r * @return */ public static String getInstrText( CTR r ) { List<CTText> instrTextList = r.getInstrTextList(); if ( instrTextList == null || instrTextList.size() < 1 ) { return null; } if ( instrTextList.size() == 1 ) { return instrTextList.get( 0 ).getStringValue(); } StringBuilder instrText = new StringBuilder(); for ( CTText ctText : instrTextList ) { instrText.append( ctText.getStringValue() ); } return instrText.toString(); }
/** * Return the string content of this text run * * @return the text of this text run or <code>null</code> if not set */ public String getText(int pos) { return run.sizeOfTArray() == 0 ? null : run.getTArray(pos) .getStringValue(); }
/** * Return the string content of this text run * * @return the text of this text run or <code>null</code> if not set */ public String getText(int pos) { return run.sizeOfTArray() == 0 ? null : run.getTArray(pos) .getStringValue(); }
public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream(new File("transformed.docx")); XWPFDocument doc = new XWPFDocument(new FileInputStream(new File("original.docx"))); for(XWPFParagraph p:doc.getParagraphs()){ for(XWPFRun r:p.getRuns()){ for(CTText ct:r.getCTR().getTList()){ String str = ct.getStringValue(); if(str.contains("NAME")){ str = str.replace("NAME", "Java Dev"); ct.setStringValue(str); } } } } doc.write(fos); }
text.append(((CTText) o).getStringValue());
String tmpText = tArray[j].getStringValue(); int startChar = 0, endChar = tmpText.length() - 1; if ((j == textBegin) && (i == runBegin)) {
endText = textEnd; for(int j=startText;j<=endText;j++){ String tmpText = paragraph.getRArray(i).getTArray(j).getStringValue(); int startChar=0, endChar = tmpText.length()-1; if((j==textBegin)&&(i==runBegin))
/** * @param prgrph The paragraph of text to work on * @param outputHyperlinkUrls Should we output the links too, or just the link text? */ public XWPFHyperlinkDecorator(XWPFParagraph prgrph, XWPFParagraphDecorator nextDecorator, boolean outputHyperlinkUrls) { super(prgrph, nextDecorator); hyperlinkText = new StringBuffer(); // loop over hyperlink anchors for(CTHyperlink link : paragraph.getCTP().getHyperlinkList()){ for (CTR r : link.getRList()) { // Loop over text runs for (CTText text : r.getTList()){ hyperlinkText.append(text.getStringValue()); } } if(outputHyperlinkUrls && paragraph.getDocument().getHyperlinkByID(link.getId()) != null) { hyperlinkText.append(" <"+paragraph.getDocument().getHyperlinkByID(link.getId()).getURL()+">"); } } }
@Override protected void visitText( CTText ctText, boolean pageNumber, Object paragraphContainer ) throws Exception { if ( currentRunAttributes != null ) { startElement( SPAN_ELEMENT, currentRunAttributes ); } String text = ctText.getStringValue(); if ( StringUtils.isNotEmpty( text ) ) { // Escape with HTML characters characters( StringEscapeUtils.escapeHtml( text ) ); } // else // { // characters( SPACE_ENTITY ); // } if ( currentRunAttributes != null ) { endElement( SPAN_ELEMENT ); } }
@Override protected void visitText( CTText ctText, boolean pageNumber, Object paragraphContainer ) throws Exception { if ( currentRunAttributes != null ) { startElement( SPAN_ELEMENT, currentRunAttributes ); } String text = ctText.getStringValue(); if ( StringUtils.isNotEmpty( text ) ) { // Escape with HTML characters characters( StringEscapeUtils.escapeHtml( text ) ); } // else // { // characters( SPACE_ENTITY ); // } if ( currentRunAttributes != null ) { endElement( SPAN_ELEMENT ); } }
@Override protected void visitRun( XWPFRun run, XHTMLPageContentBuffer paragraphContainer ) throws Exception { // HTML style CTString rStyle = getRStyle( run ); XWPFStyle runStyle = super.getXWPFStyle( rStyle != null ? rStyle.getVal() : null ); StringBuilder htmlStyle = XHTMLStyleUtil.getStyle( run, runStyle, super.getXWPFStyle( run.getParagraph().getStyle() ), defaults ); List<CTBr> brs = run.getCTR().getBrList(); for ( @SuppressWarnings( "unused" ) CTBr br : brs ) { paragraphContainer.startEndElement( BR_ELEMENT ); } List<CTText> texts = run.getCTR().getTList(); for ( CTText ctText : texts ) { paragraphContainer.startElementNotEnclosed( SPAN_ELEMENT ); setAttributStyleIfNeeded( paragraphContainer, htmlStyle ); paragraphContainer.endElementNotEnclosed(); // Set the text by escaping it with HTML. paragraphContainer.setText( StringEscapeUtils.escapeHtml( ctText.getStringValue() ) ); paragraphContainer.endElement( SPAN_ELEMENT ); } super.visitPictures( run, paragraphContainer ); }