Flow documents – part 2

A flow document it constructed by adding multiple flow content objects to it. The flow content objects are added to the document using the PdfFlowDocument.AddContent() method.

XFINIUM.PDF 6.1 supports these types of flow content:

  • text
  • image
  • table

1. Common flow content properties

All flow content classes inherit from PdfFlowContent class. The properties below are available to all flow content objects:
InnerMargins – the space between flow content bounding rectangle and the actual displayed content.
OuterMargins – the space between flow content bounding rectangle and the parent container.
BackgroundColor – the back color for the flow content. It fills the entire bounding rectangle. The inner margins area is filled with back color, the outer margins are is not filled.
DestinationName – when set to a non-null non-empty string a named destination is created at the top of the flow content. Outlines and links can reference this destination through a PdfNamedDestination object.

2. Text content

Text content is represented by PdfFlowTextContent class. It is used to add simple or formatted text to a flow document.
Flow text content is created from a PdfFormattedText object. More details on the PdfFormattedContent class are available here and in the FormattedContent sample.
When flow text content is added to a document, the text bounding rectangle is computed as the page width – page margins – content outer margins. If the text content has also inner margins those are subtracted from the bounding rectangle and the remaining space is used for laying out the text.

3. Image content

Images are added to a flow document through the PdfFlowImageContent class. When creating a PdfFlowImageContent object the image to be drawn is specified and optionally the image width and height. The image size can also be specified through the ImageWidth and ImageHeight properties. These properties can specify either absolute values or relative values based on the SizeIsRelativeToAvailableSpace property. Relative values are given in percentages based on the available space for the image.
Within the available space the image can be aligned on horizontal and vertical through the HorizontalAlign and VerticalAlign properties. When Center or Far values are used for vertical alignment, the page is completed after drawing the image and a new page is created for the next content object.
When the image size is larger than the available space, the right margins are ignored and the image is drawn as specified.

The following part will present in detail the table content.

Leave a Reply