使用Apache POI的子弹点时,请正确的文本对齐



我正在使用apache poi xslf创建一个文本框,然后在其中添加一个子弹点。问题是,当子弹点是多行文本时,它添加了这样的

文本分析,ngram,幼稚的贝叶斯文本分类器,以识别对话的性质,情绪和投诉的风险

在上面的子弹点对话中,应与子弹线中的单词文本对齐,即像这样的文本对齐

  • 文本分析,ngram,幼稚的贝叶斯文本分类器,以识别
    的性质对话的情绪和投诉的风险。

以下是代码

XSLFTextBox textbox = this.slide.createTextBox(); 
textbox.setAnchor(new Rectangle(this.xAxis,this.yAxis,this.width,this.height));  XSLFTextParagraph contentPara = textbox.addNewTextParagraph(); 
XSLFTextRun bullet1TR = contentPara.addNewTextRun();      contentPara.setBullet(true);  
contentPara.setFontAlign(FontAlign.TOP); contentPara.setTextAlign(TextAlign.LEFT);

任何帮助将不胜感激。谢谢。

首先,剩下的整个段落需求与子弹点具有空间一样多。然后,第一行需要具有相同宽度的悬挂凹痕,因此,第一行(其中有子弹点)没有缩进。

示例:

import java.io.FileOutputStream;
import org.apache.poi.xslf.usermodel.*;
import org.apache.poi.sl.usermodel.*;
import java.awt.Rectangle;
public class CreatePPTXTextBoxBullet {
 public static void main(String[] args) throws Exception {
  XMLSlideShow slideShow = new XMLSlideShow();
  XSLFSlide slide = slideShow.createSlide();
  XSLFTextBox textbox = slide.createTextBox(); 
  textbox.setAnchor(new Rectangle(50, 100, 570, 100));
  XSLFTextParagraph paragraph = textbox.addNewTextParagraph(); 
  paragraph.setBullet(true);
  paragraph.setLeftMargin(25.2); //left margin = indent for the text; 25.2 pt = 25.2/72 = 0.35"
  paragraph.setIndent(-25.2);  //hanging indent first row for the bullet point; -25.2 pt, so first row indent is 0.00 in sum
  paragraph.setFontAlign(TextParagraph.FontAlign.TOP);
  paragraph.setTextAlign(TextParagraph.TextAlign.LEFT);
  XSLFTextRun run = paragraph.addNewTextRun();
  run.setText("Text analysis, nGram, Naïve Bayes Text Classifier to identify the nature of the conversation, sentiment and risk of complaint being made");
  FileOutputStream out = new FileOutputStream("CreatePPTXTextBoxBullet.pptx");
  slideShow.write(out);
  out.close();
 }
}

最新更新