Class TextFrame
Paragraphs of text lines, wrapped at the width of the frame, with an optional border. A frame with a height draws as much of the text as fits and keeps the rest for the next frame, so text flows from frame to frame. A frame without a height draws all of the text. Drawing consumes the text: a second DrawOn draws what is left, so build a new frame to draw the same text again.
Use a TextFrame for text that continues from one frame to the next: the columns of an article, or the pages of a long text. Use a TextColumn to draw paragraphs in one place, with justified text or a rotation, and a TextBlock for one run of text in one font. Please see Example_14 and Example_15.
public class TextFrame : IDrawable
- Inheritance
-
TextFrame
- Implements
- Inherited Members
Constructors
TextFrame(Font, List<string>)
Creates a text frame from strings, one paragraph each, in the font at its size. An empty line separates the paragraphs.
public TextFrame(Font f1, List<string> inputList)
Parameters
TextFrame(List<Paragraph>)
Creates a text frame from paragraphs of text lines. An empty line separates the paragraphs unless SetParagraphGap sets another gap.
public TextFrame(List<Paragraph> paragraphs)
Parameters
Methods
DrawOn(PDF, List<Page>, PageSize)
Draws the text on as many new pages as it needs, at the location and the width of this frame on each: a whole book, page after page. The height of the frame is the height of the text on each page; a frame without one reaches down to the margin its location leaves at the top, so text at 72, 72 keeps 72 points free at the bottom too. The pages are created detached and added to the list, so that a footer or a page number can be drawn on each before they are added to the PDF. A frame with no text left needs no page.
public float[] DrawOn(PDF pdf, List<Page> pages, PageSize pageSize)
Parameters
pdfPDFthe PDF document.
pagesList<Page>the list that receives the new pages.
pageSizePageSizethe page size, for example Letter.PORTRAIT.
Returns
- float[]
the x and y coordinates of the bottom right corner of this frame on the last page.
DrawOn(Page)
Draws the text on the page: all of it when this frame has no height, or as much as fits in the height, keeping the rest for the next frame. The first line of a frame is drawn even when it does not fit, so the text always flows, and a word wider than the frame is broken. With no page nothing is drawn, the paragraphs get their coordinates and the text is kept. Returns the x and y coordinates of the bottom right corner of this frame, or of the text when the frame has no height.
public float[] DrawOn(Page page)
Parameters
pagePage
Returns
- float[]
GetHeight()
Returns the height of this text frame.
public float GetHeight()
Returns
GetWidth()
Returns the width of this text frame.
public float GetWidth()
Returns
HasMoreText()
Returns true if some of the text has not been drawn yet.
public bool HasMoreText()
Returns
SetBorderColor(int)
Sets the border color as a 0xRRGGBB value and draws a border around this text frame. Color.transparent removes the border.
public TextFrame SetBorderColor(int color)
Parameters
colorint
Returns
SetBorderColor(float[])
Sets the border color from an array of red, green and blue values and draws a border around this text frame.
public TextFrame SetBorderColor(float[] rgbColor)
Parameters
rgbColorfloat[]
Returns
SetBorderDashPattern(string)
Sets the dash pattern of the border, for example "[3] 0".
public TextFrame SetBorderDashPattern(string borderPattern)
Parameters
borderPatternstring
Returns
SetBorderWidth(float)
Sets the border width.
public TextFrame SetBorderWidth(float borderWidth)
Parameters
borderWidthfloat
Returns
SetBorders(bool)
Sets whether a border is drawn around this text frame.
public TextFrame SetBorders(bool border)
Parameters
borderbool
Returns
SetHeight(float)
Sets the height of this text frame. With a height of 0, the default, the frame draws all of its text.
public TextFrame SetHeight(float h)
Parameters
hfloat
Returns
SetLocation(float, float)
Sets the location of the top left corner of this text frame.
public TextFrame SetLocation(float x, float y)
Parameters
Returns
SetParagraphGap(float)
Sets the space between paragraphs, in points, 0 or more: from the bottom of the text of a paragraph to the top of the text of the next, so paragraphs never overlap. The default is one empty line in the size of the next paragraph, so a heading is not followed by an empty line of its own size. A negative gap is taken as 0.
public TextFrame SetParagraphGap(float paragraphGap)
Parameters
paragraphGapfloat
Returns
SetWidth(float)
Sets the width at which the lines wrap.
public TextFrame SetWidth(float w)
Parameters
wfloat