AddTextBlock

Description

Adds a text block to the current PDFRichText object.

Applies to

PDFRichText object

Syntax

AddTextBlock(PDFTextBlock textBlock)
PDFTextBlock AddTextBlock(string text)
PDFTextBlock AddTextBlock(string text, PDFFont font)
PDFTextBlock AddTextBlock(string text, PDFFont font, PDFColor textColor)
PDFTextBlock AddTextBlock(string text, PDFColor textColor)
PDFTextBlock AddTextBlock(string name, string text)
PDFTextBlock AddTextBlock(string name, string text, PDFFont font)
PDFTextBlock AddTextBlock(string name, string text, PDFFont font, PDFColor textColor)
PDFTextBlock AddTextBlock(string name, string text, PDFColor textColor)

Argument

Description

textBlock

The PDFTextBlock object to be added in the current PDFRichText object.

text The text to be added in the current PDFRichText object. It is supported to pass an empty string to this argument.
font The font of the text to be added in the current PDFRichText object.
color The color of the text to be added in the current PDFRichText object.
name The name of text to be added in the current PDFRichText object. It is supported to pass an empty string to this argument.

Return value

PDFTextBlock object. Returns the PDFTextBlock object created in the PDFRichText object if it succeeds, or null if it fails.

Usage

PDFTextBlock is a formatted text block, and must be used with the PDFRichText object, for organizing and managing the content in PDFRichText. When text is added in to a PDFRichText object,a PDFTextBlock object is created for the text in the PDFRichText object.

Examples

This example adds a PDFTextBlock object to the lpdf_rtext (PDFRichText) object using the syntax AddTextBlock(PDFTextBlock textBlock).

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFrichtext lpdf_rtext
PDFtextblock lpdf_block

lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_rtext = create PDFrichtext
lpdf_block = create PDFtextblock

lpdf_block.content = "add textblock"
lpdf_block.textcolor.r = 255
lpdf_rtext.width = lpdf_page.getwidth( )
lpdf_rtext.addtextblock( lpdf_block)
lpdf_page.addcontent( lpdf_rtext)
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\save\richtext_addtextblock.pdf")

This example directly adds text to the lpdf_rtext (PDFRichText) object and sets the text font, color, and size using the syntax PDFTextBlock AddTextBlock(string text, PDFFont font, PDFColor textColor).

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFrichtext lpdf_rtext
PDFfont lpdf_font
PDFcolor lpdf_color

String ls_text
lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_rtext = create PDFrichtext
lpdf_font = create PDFfont
lpdf_color = create PDFcolor

lpdf_rtext.width = lpdf_page.getwidth( )
ls_text = "Addtextblock text"
lpdf_font.fontname = "simsunb"
lpdf_font.fontsize = 32
lpdf_color.rgb = rgb(255,0,0)
lpdf_rtext.addtextblock(ls_text,lpdf_font,lpdf_color)
lpdf_page.addcontent( lpdf_rtext)
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\save\richtext_addtextblock.pdf")

This example adds text to the lpdf_rtext (PDFRichText) object and sets the text name, font, color, and size using the syntax PDFTextBlock AddTextBlock(string name, string text, PDFFont font, PDFColor textColor).

PDFdocument lpdf_doc
PDFpage lpdf_page
PDFrichtext lpdf_rtext
PDFfont lpdf_font
PDFcolor lpdf_color

String ls_text
lpdf_doc = create PDFdocument
lpdf_page = create PDFpage
lpdf_rtext = create PDFrichtext
lpdf_font = create PDFfont
lpdf_color = create PDFcolor

lpdf_rtext.width = lpdf_page.getwidth( )
ls_text = "Addtextblock(string name,string text) text"
lpdf_font.fontname = "simsunb"
lpdf_font.fontsize = 32
lpdf_color.rgb = rgb(255,0,0)
lpdf_rtext.addtextblock("block",ls_text,lpdf_font,lpdf_color)
lpdf_page.addcontent( lpdf_rtext)
lpdf_doc.addpage( lpdf_page)
lpdf_doc.save( "D:\save\richtext_addtextblock.pdf")

See also

Clone

GetOverflowPageText

GetTextBlock

GetTextBlockCount

GetWrapImage

GetWrapImageCount

IsOverflowPage

RemoveTextBlock

RemoveWrapImage

WrapImage