Flow documents let you create good looking PDF files fast and easy. You just pump content into them and they take care of all the layout tasks.
The central class in XFINIUM.PDF library when working with flow documents is
PdfFlowDocument class. It can be initialized with default values for page size, rotation and margins (top, bottom, left, right).
A flow document does not have an explicit collection of pages. The pages are managed internally, they are created as needed based on content added to the document.
When a new page is created the
PageCreated event is fired. The event arguments provide the default settings for the page and the page represented by a
PdfPage object. In this event content can be added to the page using the standard fixed layout mode (using the page’s Graphics property) that has been available so far. Any content added later in flow mode will be drawn on top of the content created in this event.
When the current page is full with flow content the
PageCompleted event is fired. The event arguments give access to the page object which can be used to add additional content in fixed layout mode. This new content will appear on top of previously added flow content.
StartNewPage method closes the current page (no matter how much content it contains) and starts a new page.
The main method for adding content to a flow document is
AddContent. It takes as parameter a flow content object, an instance of any class that inherits from
Before a content object is drawn on the current page the
BeforeContentDraw event is fired. The event arguments provide information about the position of the content on the page. After the content is drawn on the page the
AfterContentDraw event is fired. The event arguments also provide information about the position of the content on the page.
Save method allows to save the flow document to a stream.
The next part will provide information about the available types of flow content.