The C1PdfDocument.DrawString method returns an integer. This is the index of the first character that was not printed because it did not fit the output rectangle. You can use this value make text flow from page to page or from one frame to another within a page. For example:
Visual Basic |
Copy Code
|
---|---|
'Render a string spanning multiple pages. While True ' Render as much as will fit into the rectangle. Dim nextChar As Integer nextChar = _c1pdf.DrawString(text, font, Colors.Black, rectPage) ' Break when done. If nextChar >= text.Length Then Exit While End If ' Get rid of the part that was rendered. Text = text.Substring(nextChar) ' Move on to the next page. _c1pdf.NewPage() End While |
C# |
Copy Code
|
---|---|
// Render a string spanning multiple pages. While (true) { // Render as much as will fit into the rectangle. Int nextChar = _c1pdf.DrawString(text, font, Colors.Black, rectPage); // Break when done. If (nextChar >= text.Length) { break; } // Get rid of the part that was rendered. Text = text.Substring(nextChar); // Move on to the next page. _c1pdf.NewPage(); } |
By combining the C1PdfDocument.MeasureString and C1PdfDocument.DrawString methods, you can develop rendering routines that provide extensive control over how paragraphs are rendered, including keeping paragraphs together on a page, keeping with the next paragraph, and controlling widows and orphans (single lines that render on the current or next page).