Refine search
CTTextParagraph thisP = getXmlObject(); CTTextParagraph otherP = other.getXmlObject(); for (XSLFTextRun tr : other.getTextRuns()) { XmlObject xo = tr.getXmlObject(); XSLFTextRun run = (xo instanceof CTTextLineBreak) ? newTextRun((CTTextLineBreak)xo) : newTextRun(xo); run.copy(tr); _runs.add(run); TextAlign srcAlign = other.getTextAlign(); if(srcAlign != getTextAlign()){ setTextAlign(srcAlign); boolean isBullet = other.isBullet(); if(isBullet != isBullet()){ setBullet(isBullet); if(isBullet) { String buFont = other.getBulletFont(); if(buFont != null && !buFont.equals(getBulletFont())){ setBulletFont(buFont); String buChar = other.getBulletCharacter(); if(buChar != null && !buChar.equals(getBulletCharacter())){ setBulletCharacter(buChar); PaintStyle buColor = other.getBulletFontColor(); if(buColor != null && !buColor.equals(getBulletFontColor())){
firstPara = !newParagraph; para = _paragraphs.get(_paragraphs.size() - 1); CTTextParagraph ctp = para.getXmlObject(); otherPPr = ctp.getPPr(); List<XSLFTextRun> runs = para.getTextRuns(); if (!runs.isEmpty()) { XSLFTextRun r0 = runs.get(runs.size() - 1); otherRPr = r0.getRPr(false); if (otherRPr == null) { otherRPr = ctp.getEndParaRPr(); if (!firstPara) { if (para != null) { CTTextParagraph ctp = para.getXmlObject(); CTTextCharacterProperties unexpectedRPr = ctp.getEndParaRPr(); if (unexpectedRPr != null && unexpectedRPr != otherRPr) { para = addNewTextParagraph(); if (otherPPr != null) { para.getXmlObject().setPPr(otherPPr); for (String runText : lineTxt.split("[\u000b]")) { if (!firstRun) { para.addLineBreak(); run = para.addNewTextRun(); run.setText(runText); if (otherRPr != null) { run.getRPr(true).set(otherRPr);
@Override public String toString(){ return "[" + getClass() + "]" + getText(); }
@Override public void setBulletStyle(Object... styles) { if (styles.length == 0) { setBullet(false); } else { setBullet(true); for (Object ostyle : styles) { if (ostyle instanceof Number) { setBulletFontSize(((Number)ostyle).doubleValue()); } else if (ostyle instanceof Color) { setBulletFontColor((Color)ostyle); } else if (ostyle instanceof Character) { setBulletCharacter(ostyle.toString()); } else if (ostyle instanceof String) { setBulletFont((String)ostyle); } else if (ostyle instanceof AutoNumberingScheme) { setBulletAutoNumber((AutoNumberingScheme)ostyle, 0); } } } }
Color fontColor = null; String fontFamily = null; double fontSize = 0.0; boolean italic = false; boolean bold = false; boolean underline = false; for (XSLFTextParagraph paragraph : autoShape.getTextParagraphs()) { for (XSLFTextRun text : paragraph.getTextRuns()) { fontColor = text.getFontColor(); fontFamily = text.getFontFamily(); fontSize = text.getFontSize(); italic = text.isItalic(); bold = text.isBold(); underline = text.isUnderline(); } } autoShape.clearText(); XSLFTextParagraph addNewTextParagraph = autoShape.addNewTextParagraph(); XSLFTextRun addNewTextRun = addNewTextParagraph.addNewTextRun(); addNewTextRun.setText(values.get(0)[1]); addNewTextRun.setFontColor(fontColor); addNewTextRun.setFontFamily(fontFamily); addNewTextRun.setFontSize(fontSize); addNewTextRun.setItalic(italic); addNewTextRun.setBold(bold); addNewTextRun.setUnderline(underline);
Placeholder ph = txt.getTextType(); if (skipPlaceholders && ph != null) { continue; for (XSLFTextParagraph p : txt.getTextParagraphs()) { xhtml.startElement("p"); if (! config.getIncludeHeadersAndFooters() && p.isHeaderOrFooter()) { continue; for (XSLFTextRun run : p.getTextRuns()) { Hyperlink hyperlink = run.getHyperlink(); inHyperlink = true; xhtml.characters(run.getRawText()); if (inHyperlink == true) { xhtml.endElement("a");
p1.setIndentLevel(0); p1.setBullet(true); XSLFTextRun r1 = p1.addNewTextRun(); r1.setText("Bullet1"); p2.setLeftMargin(60d); p2.setIndent(-40d); p2.setBullet(true); p2.setBulletFontColor(Color.red); p2.setBulletFont("Wingdings"); p2.setBulletCharacter("\u0075"); p2.setIndentLevel(1); XSLFTextRun r2 = p2.addNewTextRun(); r2.setText("Bullet2"); p3.setBulletAutoNumber(AutoNumberingScheme.alphaLcParenRight, 1); p3.setIndentLevel(2); XSLFTextRun r3 = p3.addNewTextRun(); r3.setText("Numbered List Item - 1"); p4.setBulletAutoNumber(AutoNumberingScheme.alphaLcParenRight, 2); p4.setIndentLevel(2); XSLFTextRun r4 = p4.addNewTextRun(); r4.setText("Numbered List Item - 2"); p5.setBulletAutoNumber(AutoNumberingScheme.alphaLcParenRight, 3); p5.setIndentLevel(2);
XSLFTableRow titleRow = tbl.addRow(); titleRow.setHeight(50); XSLFTableCell titleCell1 = titleRow.addCell(); XSLFTextParagraph p1 = titleCell1.addNewTextParagraph(); p1.setTextAlign(TextAlign.CENTER); XSLFTextRun r1 = p1.addNewTextRun(); r1.setText("Column title"); r1.setBold(true); r1.setFontColor(new Color(0, 104, 145)); titleCell1.setFillColor(new Color(190, 230, 245)); r1.setFontSize(25.0); titleCell1.setVerticalAlignment(VerticalAlignment.MIDDLE);
public void setText(String text){ clearText(); addNewTextParagraph().addNewTextRun().setText(text); }
XSLFTextParagraph par = tb.addNewTextParagraph(); tb.setVerticalAlignment(VerticalAlignment.DISTRIBUTED); par.setTextAlign(TextAlign.CENTER); XSLFTextRun run = par.addNewTextRun(); run.setText("unicode ->\u30B4\u30DF\u7BB1<-"); run.setFontFamily("GE Inspira"); run.setFontSize(12.0); return ss;
if(_runs.size() == 0) ensureNotEmpty(); String text = getRenderableText(); if(text.length() == 0) return _lines; AttributedString at = getAttributedString(graphics); AttributedCharacterIterator it = at.getIterator(); LineBreakMeasurer measurer = new LineBreakMeasurer(it, graphics.getFontRenderContext()) ; double wrappingWidth = getWrappingWidth(_lines.size() == 0, graphics) + 1; // add a pixel to compensate rounding errors TextAlign hAlign = getTextAlign(); if(hAlign == TextAlign.JUSTIFY || hAlign == TextAlign.JUSTIFY_LOW) { layout = layout.getJustifiedLayout((float)wrappingWidth); if(isBullet() && !emptyParagraph) { String buCharacter = getBulletCharacter(); String buFont = getBulletFont(); if(buFont == null) buFont = getTextRuns().get(0).getFontFamily(); if(buCharacter != null && buFont != null && _lines.size() > 0) { AttributedString str = new AttributedString(buCharacter); Color buColor = getBulletFontColor(); str.addAttribute(TextAttribute.FOREGROUND, buColor == null ? bit.getAttribute(TextAttribute.FOREGROUND) : buColor); float buSz = (float)getBulletFontSize(); if(buSz > 0) fontSize *= buSz* 0.01; else fontSize = -buSz;
textShape.clearText(); XSLFTextParagraph p = textShape.addNewTextParagraph(); XSLFTextRun r1 = p.addNewTextRun(); r1.setText("The"); r1.setFontColor(Color.blue); r1.setFontSize(24.);
XSLFTextRun r1 = p1.addNewTextRun(); r1.setText("Paragraph Formatting"); r1.setFontSize(24d); r1.setFontColor(new Color(85, 142, 213)); p2.setSpaceBefore(-20d); // 20 pt from the previous paragraph p2.setSpaceAfter(300d); // 3 lines after the paragraph XSLFTextRun r2 = p2.addNewTextRun(); r2.setText("Paragraph properties apply to all text residing within the corresponding paragraph."); r2.setFontSize(16d); XSLFTextRun r3 = p3.addNewTextRun(); r3.setText("Run Formatting"); r3.setFontSize(24d); p4.setSpaceBefore(-20d); // 20 pt from the previous paragraph p4.setSpaceAfter(300d); // 3 lines after the paragraph XSLFTextRun r4 = p4.addNewTextRun(); r4.setFontSize(16d); r4.setText(
XSLFTextShape[] phs = slide[i].getPlaceholders(); for (XSLFTextShape ts : phs) { java.util.List<XSLFTextParagraph> tpl = ts.getTextParagraphs(); for(XSLFTextParagraph tp: tpl) { java.util.List<XSLFTextRun> trs = tp.getTextRuns(); for(XSLFTextRun tr: trs) { logger.info(tr.getFontFamily()); tr.setFontFamily("SimSun"); } } }
/** * ensure that the paragraph contains at least one character. * We need this trick to correctly measure text */ private void ensureNotEmpty(){ XSLFTextRun r = addNewTextRun(); r.setText(" "); CTTextCharacterProperties endPr = _p.getEndParaRPr(); if(endPr != null) { if(endPr.isSetSz()) r.setFontSize(endPr.getSz() / 100); } }
XSLFTableRow headerRow = table.addRow(); for(int i = 0; i < 3; i++) { XSLFTableCell th = headerRow.addCell(); XSLFTextParagraph p = th.addNewTextParagraph(); XSLFTextRun r = p.addNewTextRun(); r.setText("Text"); }
public static void main(String[] args) throws IOException{ try (XMLSlideShow ppt = new XMLSlideShow()) { XSLFSlide slide1 = ppt.createSlide(); XSLFSlide slide2 = ppt.createSlide(); XSLFTextBox shape1 = slide1.createTextBox(); shape1.setAnchor(new Rectangle(50, 50, 200, 50)); XSLFTextRun r1 = shape1.addNewTextParagraph().addNewTextRun(); XSLFHyperlink link1 = r1.createHyperlink(); r1.setText("http://poi.apache.org"); // visible text link1.setAddress("http://poi.apache.org"); // link address XSLFTextBox shape2 = slide1.createTextBox(); shape2.setAnchor(new Rectangle(300, 50, 200, 50)); XSLFTextRun r2 = shape2.addNewTextParagraph().addNewTextRun(); XSLFHyperlink link2 = r2.createHyperlink(); r2.setText("Go to the second slide"); // visible text link2.linkToSlide(slide2); // link address try (FileOutputStream out = new FileOutputStream("hyperlinks.pptx")) { ppt.write(out); } } } }
try { FileInputStream fis = new FileInputStream("C:\\sample\\sample.pptx"); XMLSlideShow pptxshow = new XMLSlideShow(fis); XSLFSlide[] slide2 = pptxshow.getSlides(); for (int i = 0; i < slide2.length; i++) { System.out.println(i); try { XSLFNotes mynotes = slide2[i].getNotes(); for (XSLFShape shape : mynotes) { if (shape instanceof XSLFTextShape) { XSLFTextShape txShape = (XSLFTextShape) shape; for (XSLFTextParagraph xslfParagraph : txShape.getTextParagraphs()) { System.out.println(xslfParagraph.getText()); } } } } catch (Exception e) { } } } catch (IOException e) { }
@Override public void setBulletFontColor(PaintStyle color) { XSLFTextParagraph.this.setBulletFontColor(color); }
Placeholder ph = txt.getTextType(); if (skipPlaceholders && ph != null) { continue; for (XSLFTextParagraph p : txt.getTextParagraphs()) { xhtml.startElement("p"); if (! config.getIncludeHeadersAndFooters() && p.isHeaderOrFooter()) { continue; for (XSLFTextRun run : p.getTextRuns()) { Hyperlink hyperlink = run.getHyperlink(); inHyperlink = true; xhtml.characters(run.getRawText()); if (inHyperlink == true) { xhtml.endElement("a");