TextBuilder

遗产: java.lang.Object

public final class TextBuilder

将文本对象附加到 Pdf 页面。

构造函数

构造函数描述
TextBuilder(Page page)为 Pdf 页面初始化 TextBuilder 类的新实例。
TextBuilder(Page page, BaseOperatorCollection operatorCollection)为 Pdf 页面初始化 TextBuilder 类的新实例。

方法

方法描述
appendParagraph(TextParagraph textParagraph)将文本段落附加到 Pdf 页面。
appendParagraph(TextParagraph textParagraph, int rotation)附加段落旋转
appendText(TextFragment textFragment)将文本片段附加到 Pdf 页面
appendText(List textFragments)
equals(Object arg0)
getClass()
getSegmenter()获取 TextSegmenter 对象
hashCode()
notify()
notifyAll()
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

TextBuilder(Page page)

public TextBuilder(Page page)

为 Pdf 页面初始化 TextBuilder 类的新实例。

参数:

范围类型描述
pagePage页面对象。

TextBuilder 允许将文本对象附加到 Pdf 页面。|

TextBuilder(Page page, BaseOperatorCollection operatorCollection)

public TextBuilder(Page page, BaseOperatorCollection operatorCollection)

为 Pdf 页面初始化 TextBuilder 类的新实例。

参数:

范围类型描述
pagePage页面对象。
operatorCollectionBaseOperatorCollection运算符集合。

appendParagraph(TextParagraph textParagraph)

public void appendParagraph(TextParagraph textParagraph)

将文本段落附加到 Pdf 页面。


The example demonstrates how to create text paragraph object and append it to the Pdf page.
 
 Document doc = new Document(inFile);
 Page page = (Page)doc.getPages().get(1);
 //创建文本段落
 TextParagraph paragraph = new TextParagraph();
            
 //设置段落矩形
 paragraph.setRectangle ( new Rectangle(100, 600, 200, 700));
 //设置自动换行选项
 paragraph.getFormattingOptions().setWrapMode ( TextFormattingOptions.WordWrapMode.ByWords);
 //附加字符串行
 paragraph.appendLine("the quick brown fox jumps over the lazy dog");
 paragraph.appendLine("line2");
 paragraph.appendLine("line3");
 //使用 TextBuilder 将段落附加到 Pdf 页面
 TextBuilder textBuilder = new TextBuilder(page);
 textBuilder.appendParagraph(paragraph);
 //保存 Pdf 文件
 doc.save(outFile);

参数:

范围类型描述
textParagraphTextParagraph文本段落对象。

appendParagraph(TextParagraph textParagraph, int rotation)

public void appendParagraph(TextParagraph textParagraph, int rotation)

附加段落旋转

参数:

范围类型描述
textParagraphTextParagraphTextParagraph 对象
rotationint整数值

appendText(TextFragment textFragment)

public void appendText(TextFragment textFragment)

将文本片段附加到 Pdf 页面


The example demonstrates how to create text fragment object, customize it's text segments and append it to the Pdf page.
 
 Document doc = new Document(inFile);
 Page page = (Page)doc.getPages().get(1);
 //创建文本片段
 TextFragment tf = new TextFragment("main text");
 tf.Position = new Position(100, 600);
 //设置它的文本属性
 tf.getTextState().setFontSize ( 5);
 tf.getTextState().setFont ( FontRepository.FindFont("TimesNewRoman"));
 tf.getTextState().setBackgroundColor ( Color.GREY);
 tf.getTextState().setForegroundColor ( Color.Red);
 //在文本片段的 Segments 集合中再添加一个片段
 TextSegment segment2 = new TextSegment();
 segment2.setText ( "another segment");
 tf.getSegments.add(segment2);
 //创建 TextBuilder 对象
 TextBuilder builder = new TextBuilder(page);
 //将文本片段附加到 Pdf 页面
 builder.appendText(tf);
 //保存文档
 doc.save(outFile);

参数:

范围类型描述
textFragmentTextFragment文本片段对象。

appendText(List textFragments)

public final void appendText(List<TextFragment> textFragments)

参数:

范围类型描述
textFragmentsjava.util.List<com.aspose.pdf.TextFragment>

equals(Object arg0)

public boolean equals(Object arg0)

参数:

范围类型描述
arg0java.lang.Object

退货: 布尔值

getClass()

public final native Class<?> getClass()

退货: java.lang.Class

getSegmenter()

public TextSegmenter getSegmenter()

获取 TextSegmenter 对象

退货: TextSegmenter - TextSegmenter 对象

hashCode()

public native int hashCode()

退货: 整数

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

toString()

public String toString()

退货: java.lang.字符串

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

参数:

范围类型描述
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

参数:

范围类型描述
arg0long
arg1int