Table of Contents

Class TextFlow

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Headings, paragraphs and images flowed onto as many pages as they need, one below the other between the margins: a report, a manual, a long letter. Paragraphs break across pages between their lines, as a TextFrame breaks them; an image goes whole, to the top of the next page when it does not fit below the text, with its caption; a heading goes to the next page with what follows it rather than end a page. The pages are created detached and added to a list, so that a footer or a page number can be drawn on each before they are added to the PDF.

Use a TextFrame to place text by hand, in frames on the same page or on others, the text flowing from one to the next; use TextFlow to pour the text and the images in, page after page. The order they are added in is the reading order of a PDF/UA document: the paragraphs are tagged as a TextFrame tags them, the images as figures with their alternate descriptions. Use Markdown instead for a text written in Markdown. Please see Example_22.

public class TextFlow
Inheritance
TextFlow
Inherited Members

Constructors

TextFlow(PDF, PageSize)

Creates a flow of text and images onto pages of the size, with margins of 72 points, an inch, on every side.

public TextFlow(PDF pdf, PageSize pageSize)

Parameters

pdf PDF

the PDF document.

pageSize PageSize

the page size, for example Letter.PORTRAIT.

Methods

Add(Image)

Adds an image at the left margin. An image wider than the text is made as wide as the text, and one taller than the space between the top and the bottom margins as tall as that space, keeping its shape; it is never cut. A paragraph of StructElem.CAPTION added right after it, after a space or not, is its caption, and goes to the next page with it when the two do not fit.

public TextFlow Add(Image image)

Parameters

image Image

the image to add.

Returns

TextFlow

this flow.

Add(Image, Alignment)

Adds an image as Add(image) does, at the left margin, in the center of the text, or at the right margin: Alignment.LEFT, Alignment.CENTER or Alignment.RIGHT.

public TextFlow Add(Image image, Alignment alignment)

Parameters

image Image

the image to add.

alignment Alignment

where the image goes across the text.

Returns

TextFlow

this flow.

Add(Paragraph)

Adds a paragraph: a heading, when its structure type is StructElem.H1 to StructElem.H6, or a paragraph of text, a caption, a line.

public TextFlow Add(Paragraph paragraph)

Parameters

paragraph Paragraph

the paragraph to add.

Returns

TextFlow

this flow.

Add(List<Paragraph>, float)

Adds paragraphs with gap points between them, which flow across pages as the text of a TextFrame does.

public TextFlow Add(List<Paragraph> paragraphs, float gap)

Parameters

paragraphs List<Paragraph>

the paragraphs to add.

gap float

the space between two paragraphs, in points.

Returns

TextFlow

this flow.

AddSpace(float)

Adds points of space below what was added before. A space at the top of a page is left out, as the gap between two paragraphs is.

public TextFlow AddSpace(float points)

Parameters

points float

the space, in points.

Returns

TextFlow

this flow.

DrawOn(Page, List<Page>)

Draws what was added as DrawOn(pages) does, starting on first, a page with other content above the flow, which SetFirstPageTop puts the flow under. The next pages are new and are added to the list; first is not.

public float[] DrawOn(Page first, List<Page> pages)

Parameters

first Page

the page the flow starts on.

pages List<Page>

the list that receives the new pages.

Returns

float[]

the x and y coordinates of the bottom right corner of what was drawn on the last page, where something drawn after it can go.

DrawOn(List<Page>)

Draws what was added on as many new pages as it needs, created detached and added to the list; add them to the PDF afterwards.

public float[] DrawOn(List<Page> pages)

Parameters

pages List<Page>

the list that receives the new pages.

Returns

float[]

the x and y coordinates of the bottom right corner of what was drawn on the last page, where something drawn after it can go.

SetFirstPageTop(float)

Sets where the flow starts on the first page that DrawOn(first, pages) is given, below what is drawn there already, such as a heading or a letterhead. Without it the flow starts at the top margin.

public TextFlow SetFirstPageTop(float y)

Parameters

y float

the y coordinate the flow starts at on the first page.

Returns

TextFlow

this flow.

SetMargins(float)

Sets the margins of every side of the pages, in points. The text and the images are as wide as the page less the left and right margins.

public TextFlow SetMargins(float margin)

Parameters

margin float

the margin of every side.

Returns

TextFlow

this flow.

SetMargins(float, float, float, float)

Sets the margins of the pages, in points: top, right, bottom and left, the order CSS gives them.

public TextFlow SetMargins(float top, float right, float bottom, float left)

Parameters

top float

the top margin.

right float

the right margin.

bottom float

the bottom margin.

left float

the left margin.

Returns

TextFlow

this flow.